I am trying to combine thousands of rectangles into one polygon using DbGeography. For testing, I'm starting with just two rectangles (because the thousands failed with a fullglobe result). When I use the union method of DbGeography, it returns a polygon with one rectangle subtracted from the other instead of combining them. I tried the same process with SQLGeography and got the same result. Can anyone see what I'm doing wrong? Or maybe I misunderstand the Union method?
Two separate rectangles showing overlap:
Resulting polygon after union:
Code (geog1 is upper left rectangle, geog2 is lower right):
DbGeography geogUnion = geog1;
geogUnion = geogUnion.Union(geog2);
And here are the values for the polygons I am merging and the resulting polygon:
geog1: POLYGON ((-114.964104 36.008963, -114.964104 36.005183, -114.958248 36.005183, -114.958248 36.008963, -114.964104 36.008963))
geog2: POLYGON ((-114.957387 36.006575, -114.957387 36.000681, -114.9608 36.000681, -114.9608 36.006575, -114.957387 36.006575))
geogUnion: POLYGON ((-114.957387 36.000681, -114.9608 36.000681, -114.96080000000012 36.005183034992221, -114.958248 36.005183, -114.95824799999998 36.00657500911889, -114.957387 36.006575, -114.957387 36.000681))