microsoft / USBuildingFootprints

Computer generated building footprints for the United States
Other
2.1k stars 263 forks source link

A few topology errors detected #38

Open jwalseth-tableau opened 6 years ago

jwalseth-tableau commented 6 years ago

I used ogr2ogr to load buildings from southern Louisiana into SQL Server. That process detected a small number of topology errors. Here is a lightly edited version of the command and error messages:

ogr2ogr.exe -f "MSSQLSpatial" "MSSQL:server=mssql2016;database=Test;trusted_connection=yes;" "Louisiana.geojson" -t_srs "EPSG:4326" -a_srs "EPSG:4326" -lco "GEOM_TYPE=geography" -lco "GEOM_NAME=Geometry" -progress -clipsrc -93.911601 28.909162 -88.950615 30.485868

ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -93.360444081030153 30.248059998115576 at -93.360444081030153 30.248059998115576 ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -90.071937444444444 29.934727555555554 at -90.071937444444444 29.934727555555554 Warning 1: Ring Self-intersection at or near point -90.043338000000006 29.857880999999999 ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -90.014427003208837 29.878139898386664 at -90.014427003208837 29.878139898386664 ERROR 1: TopologyException: Input geom 0 is invalid: Ring Self-intersection at or near point -93.468692000000004 30.358803999999999 at -93.468692000000004 30.358803999999999 ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -92.034133058082276 30.273381288798021 at -92.034133058082276 30.273381288798021 ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -90.104453000000007 29.898416000000001 at -90.104453000000007 29.898416000000001 ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -91.989179968309486 30.283958535569884 at -91.989179968309486 30.283958535569884 ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -90.33083200171086 29.532288062446536 at -90.33083200171086 29.532288062446536 ERROR 1: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -90.768384909631834 30.408825994049835 at -90.768384909631834 30.408825994049835

The process was otherwise successful producing a table with 1145195 rows. Thanks for making these data available.

antifa-ev commented 6 years ago

Have you repeated with standard Postgres before reporting?

shermstats commented 5 years ago

I ran into this issue when processing buildings via the shapely Python library.

A few examples indicate that many instances of self-intersection occur when a single footprint is actually two footprints connected at a single corner. My solution was to split those into two new footprints at the shared corner.

zoharby commented 5 years ago

Also encountered a few cases of self-intersecting polygons in the dataset, for example (line 1445618 in Oklahoma.geojson): {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-95.936934,36.192659],[-95.936506,36.193613],[-95.936854,36.193715],[-95.936913,36.193583],[-95.936848,36.193564],[-95.936888,36.193474],[-95.936896,36.193476],[-95.936938,36.193381],[-95.937011,36.193402],[-95.937073,36.193263],[-95.937017,36.193247],[-95.937017,36.193247],[-95.937836,36.193487],[-95.937802,36.193563],[-95.937808,36.193565],[-95.937647,36.193923],[-95.938223,36.194092],[-95.938228,36.19408],[-95.938348,36.194115],[-95.938748,36.193226],[-95.938156,36.193053],[-95.938153,36.19306],[-95.938057,36.193032],[-95.938037,36.193077],[-95.938054,36.193082],[-95.937884,36.193461],[-95.937384,36.193314],[-95.937592,36.192851],[-95.937026,36.192685],[-95.937026,36.192686],[-95.936934,36.192659]]]},"properties":{}}

Gives: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -95.937072838161598 36.193263362831239 at -95.937072838161598 36.193263362831239

chadwilcomb commented 5 years ago

These topology errors, while a very small percentage, break the 2dsphere index in MongoDB and thus they cannot be inserted. It would be great if there was a way to make these 100% valid topologies.