0

I have following two geometries.

Geometry 1 (G1): MULTIPOLYGON (((148.134707676 -34.1519003565, 148.143738823 -34.1540810687, 148.14648294 -34.1396863245, 148.143196834 -34.1392361445, 148.140859243 -34.1389158167, 148.140167574 -34.1388210316, 148.137263226 -34.1384230398, 148.137144086 -34.1390514776, 148.134707676 -34.1519003565)), ((148.127157711 -34.1375766788, 148.13687116 -34.13874378, 148.136991313 -34.1381100176, 148.137332697 -34.1381568007, 148.137468636 -34.1374507797, 148.137513814 -34.1372161475, 148.13838748 -34.1326786347, 148.128316556 -34.131510413, 148.128136102 -34.132455082, 148.128091255 -34.1326898756, 148.128070549 -34.132798268, 148.127157711 -34.1375766788)))
Geometry 2 (G2): MULTIPOLYGON (((148.12715771061104 -34.13757667877951, 148.1271063649348 -34.13784541889359, 148.12956888671459 -34.1381413736503, 148.13218218263441 -34.138455399790274, 148.13463511295583 -34.138750099589814, 148.13714408607888 -34.139051477554304, 148.13726322633426 -34.13842303982323, 148.14016757371385 -34.138821031561889, 148.14085924335836 -34.138915816684175, 148.14319683415181 -34.139236144501936, 148.14325611295016 -34.138968515921356, 148.14011850488848 -34.138538549666791, 148.13942363510321 -34.138443334273475, 148.13733269717761 -34.138156800659516, 148.13699131297133 -34.138110017649, 148.13687115978624 -34.138743779984061, 148.12715771061104 -34.13757667877951)))

I have done UnionAggregate these two geometries from the SQL Server. Which gives me below geometry.

Result from SQL Server union aggregate (G3): POLYGON ((148.143738823 -34.1540810687, 148.14648294 -34.1396863245, 148.143196834 -34.1392361445, 148.140859243 -34.1389158167, 148.14017909449052 -34.138822610347709, 148.14085924335836 -34.138915816684175, 148.14319683415181 -34.139236144501936, 148.14325611295016 -34.138968515921356, 148.14011850488848 -34.138538549666791, 148.13942363510321 -34.138443334273475, 148.13733269717761 -34.138156800659516, 148.13733269701217 -34.138156800636843, 148.137468636 -34.1374507797, 148.137513814 -34.1372161475, 148.13838748 -34.1326786347, 148.128316556 -34.131510413, 148.128136102 -34.132455082, 148.128091255 -34.1326898756, 148.128070549 -34.132798268, 148.127157711 -34.1375766788, 148.13687115978806 -34.138743779974533, 148.13687115978624 -34.138743779984061, 148.12715771061104 -34.13757667877951, 148.1271063649348 -34.13784541889359, 148.12956888671459 -34.1381413736503, 148.13218218263441 -34.138455399790274, 148.13463511295583 -34.138750099589814, 148.13714408601024 -34.139051477546062, 148.137144086 -34.1390514776, 148.134707676 -34.1519003565, 148.143738823 -34.1540810687), (148.14003283265782 -34.138802567576647, 148.13726322633008 -34.138423039845236, 148.13726322633426 -34.13842303982323, 148.14003283265782 -34.138802567576647), (148.13714475985358 -34.138131045883391, 148.13699131299023 -34.138110017651584, 148.136991313 -34.1381100176, 148.13714475985358 -34.138131045883391))

Bu the problem is this G3 does not loads up in ArcGis. So I tried to do Union from ArcGis geometry service and checked the result. Surprisingly it worked and the resulted geometry is different to G3.

Geometry service: http://mapserver/arcgis/rest/services/Utilities/Geometry/GeometryServer/union

JSON

{ "geometryType":"esriGeometryPolygon",


"spatialReference": {"wkid": 4283},
  "geometries":[
 {
  "rings" : [
   [[148.134707676,-34.1519003565],[148.143738823,-34.1540810687],[148.14648294,-34.1396863245],[148.143196834,-34.1392361445],[148.140859243,-34.1389158167],[148.140167574,-34.1388210316],[148.137263226,-34.1384230398],[148.137144086,-34.1390514776],[148.134707676,-34.1519003565]],    [[148.127157711,-34.1375766788],[148.13687116,-34.13874378],[148.136991313,-34.1381100176],[148.137332697,-34.1381568007],[148.137468636,-34.1374507797],[148.137513814,-34.1372161475],[148.13838748,-34.1326786347],[148.128316556,-34.131510413],[148.128136102,-34.132455082],[148.128091255,-34.1326898756],[148.128070549,-34.132798268],[148.127157711,-34.1375766788]]
  ]
 },
 {
  "rings" : [
   [[148.12715771061104,-34.13757667877951],[148.1271063649348,-34.13784541889359],[148.12956888671459,-34.1381413736503],[148.13218218263441,-34.138455399790274],[148.13463511295583,-34.138750099589814],[148.13714408607888,-34.139051477554304],[148.13726322633426,-34.13842303982323],[148.14016757371385,-34.138821031561889],[148.14085924335836,-34.138915816684175],[148.14319683415181,-34.139236144501936],[148.14325611295016,-34.138968515921356],[148.14011850488848,-34.138538549666791],[148.13942363510321,-34.138443334273475],[148.13733269717761,-34.138156800659516],[148.13699131297133,-34.138110017649],[148.13687115978624,-34.138743779984061],[148.12715771061104,-34.13757667877951]]
  ]
 }
]

}

Questions

  1. Whats wrong with G1 and G2?
  2. Why does the unionaggregated geometry from SQL Server is different to the what is generated from ArcGIS?

Also I have tried to UnionAggregate from "DotSpatial" library and "NetTopologySuite". But still the unionaggregated polygon does not load in ArcMap.

I myself am not a GIS developer, I have been trying to solve this with our GIS team and they dont know why this is happening. So it has come to a point that I have to call ArcGIS geometry service to generate unionaggregate. This results in massive change in the already production application. I dont want to go to that option with out finding the cause of the real problem.

closed as too broad by PolyGeo Jul 11 '17 at 21:51

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What error are you receiving? What geometry is returned the geoprocessing service? – Vince Dec 14 '14 at 22:58
2

Here are your starting shapes: enter image description here

At one billionth (10^9) of a degree precision (the same scale as your coordinates in the WKT), I receive a self-intersection error from the Esri geometry library. The geometry really is invalid as presented. If I increase the precision to 10 billionths (10^10), I get long slivers in the middle of the shape: enter image description here

If I back the precision off to 100 millionth of a degree, I get 35% fewer vertices, and the polygon is valid. ArcGIS server likely returns a 22-vertex shape, not the 34-vertex "polygon" generated by SQL-Server: enter image description here

I should note that a billionth of a degree is roughly equal to 0.000111 meters, so the positional difference in the coordinates of the sliver polygons is less than a tenth of a millimeter. The G2 polygon is presented with 14 places of precision, which approaches a nanometer, smaller than the transistor gates used in microprocessors.

If you use the SQL-Server Reduce() method to generalize the result to a reasonable precision, you'll likely not encounter errors in ArcGIS.

  • thanks for your reply. I tried to unionaggregate G1 and G2 and then Reduce(0.000111). But didn't work. I have a strong feeling there is something wrong with the data. – JenonD Dec 15 '14 at 4:43
  • You should probably review the Reduce documentation. The Douglas-Peucker tolerance is a deflection distance threshold, and its units are in the geometry coordinate system (not meters). Also of use are STIsValid and STMakeValid. See gis.stackexchange.com/questions/41121/… – Vince Dec 15 '14 at 15:32
  • Hi Vince, I tried both STIsValid and STMakeValid but none of them worked. Recently the spatial team updated data and it all of sudden it worked. – JenonD Dec 19 '14 at 4:58
1

The only success I have had after using UnionAggregate to use QGIS to move the feature from SQL Server to a shapefile and then ArcGIS can read it.

  • Do you think I should always use ArcGIS to create union of geometries? Now got this working because data was updated by the spatial team. What is the root cause of this problem? – JenonD Dec 22 '14 at 22:47
0

Adding an .STBuffer(0.5) to a UnionAggregate geometry outcome did the trick for ArcGIS for me.

That is,

geometry::UnionAggregate(geom).STBuffer(0.5) as geom

Vince is correct about ArcGIS being very precise about what it sees as errors in geometry. But in practice, using Reduce did not work for me either, which may be "user error" or slight waste of my time, depending on your perspective. I find the tolerance parameter in Reduce completely incomprehensible practically.

I found the little buffer trick out through some of the readme's in this SQL Server Spatial 2008 plugin: https://sqlspatialtools.codeplex.com/

Which were linked here:

http://www.bostongis.com/PrinterFriendly.aspx?content_name=sqlserver2008r2_oracle11gr2_postgis15_compare

Not the answer you're looking for? Browse other questions tagged or ask your own question.