wiki:BldgsGeomMisc

Version 59 (modified by darkblueb, 5 years ago) ( diff )

--

Microsoft Buildings dataset, snapshot feb19 valid/invalid in postgis

https://trac.osgeo.org/geos/attachment/ticket/987/msft-osm-CA_ex0sm.jpg

Invalid Polygons Datafile

https://trac.osgeo.org/geos/attachment/ticket/987/feb19_reason.csv

https://github.com/Microsoft/USBuildingFootprints

CA scan for invalid polygons:

select gid,st_isvalidreason(geom) from msft_ca_jul18 where not st_isvalid(geom);
--

   gid   |                   st_isvalidreason                    
---------+-------------------------------------------------------
 1932577 | Self-intersection[-117.879309006686 34.0939527158598]
 1083503 | Self-intersection[-118.151041032252 34.1665520003544]
   88756 | Ring Self-intersection[-119.076734 35.415403]
     ...   ....
 4354462 | Ring Self-intersection[-118.565846 34.078259]
 5310650 | Self-intersection[-117.885100999011 34.1099770731587]
 5244655 | Self-intersection[-116.344896 33.719872]
(43 rows)

Import to postgis

https://trac.osgeo.org/geos/attachment/ticket/987/do_import_msft.sql

https://trac.osgeo.org/geos/attachment/ticket/987/feb19_invalids.csv

Screenshots of Invalid Geometry

https://trac.osgeo.org/geos/attachment/ticket/987/OGC_fail-11.png

https://trac.osgeo.org/geos/attachment/ticket/987/invalid-8039880-46.png

https://trac.osgeo.org/geos/attachment/ticket/987/ex-28.png

=# SELECT postgis_full_version();
-----------------------------------
 POSTGIS="2.4.3" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d6" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.3.3, released 2018/12/14" LIBXML="2.9.3" LIBJSON="0.11.99" LIBPROTOBUF="1.2.1"  RASTER

Sample CA Msft Buildings

{
  "type":"FeatureCollection",
  "features":
  [
    {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-118.254638,33.7843],[-118.254637,33.784231],[-118.254556,33.784232],[-118.254559,33.784339],[-118.254669,33.784338],[-118.254668,33.7843],[-118.254638,33.7843]]]},"properties":{}},
    {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-118.254414,33.784255],[-118.254232,33.784255],[-118.254232,33.784355],[-118.254414,33.784355],[-118.254414,33.784255]]]},"properties":{}},
    {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-118.253019,33.784683],[-118.253153,33.784683],[-118.253153,33.78458],[-118.253019,33.78458],[-118.253019,33.784683]]]},"properties":{}},
   ....
    {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-120.941051,39.935173],[-120.941051,39.935087],[-120.940869,39.935087],[-120.940869,39.935208],[-120.940976,39.935208],[-120.940976,39.935173],[-120.941051,39.935173]]]},"properties":{}},
    {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-120.947556,39.933526],[-120.947556,39.933446],[-120.947403,39.933446],[-120.947403,39.933526],[-120.947556,39.933526]]]},"properties":{}}
  ]
}


OSM California Polygon Invalids

https://trac.osgeo.org/geos/attachment/ticket/987/osm_invalids_sample56.png

 POLYGON((-116.282708 33.7294822,-116.2824887 33.7294855,-116.2824857 33.7293452,-116.2825882 33.7293437,-116.2825891 33.7293853,-116.2826191 33.7293849,-116.2826181 33.7293383,-116.2826411 33.729338,-116.28278 33.7293368,-116.2827417 33.7293365,-116.2827433 33.7294112,-116.2827065 33.7294117,-116.282708 33.7294822))
 POLYGON((-116.2755448 33.7440069,-116.2755475 33.7440693,-116.2756384 33.7440675,-116.275638 33.7441183,-116.2756344 33.7441182,-116.2756339 33.7441885,-116.2756398 33.7441878,-116.2756394 33.7442332,-116.2756635 33.7442333,-116.2756685 33.7443933,-116.2756401 33.7443938,-116.2756387 33.744241,-116.2756112 33.7442405,-116.2756065 33.7440682,-116.275631 33.7440069,-116.2755448 33.7440069))
 POLYGON((-121.1453045 38.6882284,-121.1453156 38.6882104,-121.14536 38.6882187,-121.1454524 38.6882175,-121.1454 38.6882705,-121.1454355 38.6883041,-121.1455233 38.688238,-121.1454907 38.6882188,-121.1455356 38.6882212,-121.1455448 38.6882404,-121.1455495 38.6882777,-121.145514 38.6882825,-121.1455125 38.6883101,-121.1455032 38.688333,-121.1454617 38.6883306,-121.1454185 38.688327,-121.1453892 38.688321,-121.1453846 38.6882885,-121.1453477 38.6882753,-121.1453369 38.6882488,-121.1452937 38.68822,-121.1453045 38.6882284))
 POLYGON((-121.1385616 38.6831932,-121.1385556 38.6831924,-121.1386403 38.6832044,-121.1386495 38.683214,-121.1387358 38.683226,-121.1387376 38.6832169,-121.1387959 38.6832254,-121.138799 38.6832076,-121.1388105 38.6832128,-121.1388074 38.6832327,-121.1387874 38.6832381,-121.138752 38.6832302,-121.1387366 38.6832417,-121.138695 38.6832339,-121.1385471 38.6832224,-121.1385224 38.683223,-121.1385286 38.6832104,-121.1385548 38.6832044,-121.1385616 38.6831932))
 POLYGON((-121.1311171 38.684792,-121.1311037 38.6847962,-121.1311251 38.6846622,-121.1310916 38.6846622,-121.1309334 38.6846622,-121.1309291 38.6847437,-121.1309266 38.684792,-121.1310085 38.6847952,-121.1310125 38.6847847,-121.1311171 38.684792))
 POLYGON((-122.2777271 38.2831574,-122.2771745 38.2831878,-122.2771544 38.2831889,-122.2771352 38.2827884,-122.2771203 38.2827892,-122.2778086 38.282753,-122.2778108 38.2827783,-122.278053 38.2827653,-122.2780613 38.2828595,-122.2778704 38.2828698,-122.2778923 38.2831174,-122.2777244 38.2831265,-122.2777271 38.2831574))

--
NOTICE:  Self-intersection at or near point -116.28274171351045 33.729337130768805
NOTICE:  Self-intersection at or near point -116.27560652752226 33.744068131138171
NOTICE:  Self-intersection at or near point -121.14530502440944 38.688227549606296
NOTICE:  Self-intersection at or near point -121.13856157201428 38.683193246094113
NOTICE:  Self-intersection at or near point -121.13110451105652 38.684791121421732
NOTICE:  Self-intersection at or near point -122.2771352007823 38.282788416318006

POLY Valid-Invalids vanOosterom/Delft

1 blue Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260))

2 blue Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (160 210, 220 210, 220 170, 160 170, 160 210))

3 blue Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (160 210, 220 210, 220 170, 160 170, 160 210), (180 160, 210 160, 212 135, 181 135, 180 160))

4 blue Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (130 211, 220 211, 220 170, 130 170, 130 211))

5 blue Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (170 210, 220 210, 220 170, 170 170, 170 210), (140 170, 170 170, 170 150, 140 150, 140 170))

6 blue Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (130 211, 170 211, 170 170, 130 170, 130 211), (170 170, 200 170, 200 150, 170 150, 170 170), (200 200, 230 200, 230 170, 200 170, 200 200))

7 blue Valid
POLYGON ((200 260, 171 241, 188 226, 227 226, 227 201, 188 201, 188 223, 170 240, 100 190, 196 66, 270 210, 200 260))

8 blue Valid
POLYGON ((200 260, 171 241, 188 226, 227 226, 227 201, 188 201, 188 223, 162 245, 100 190, 196 66, 270 210, 200 260))

9 red Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (132 211, 220 170, 116 200, 132 211))

10 red Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210 ))

11 red Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 240 230, 250 260, 239 231, 200 260))

12 blue Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 240 230, 223 194, 239 231, 200 260))

13 red Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (130 232, 220 232, 220 170, 130 170, 130 232))
# another integers version, for convenience
POLYGON ((200 261, 100 190, 196 66, 270 210, 200 261), (210 236, 210 210, 163 210, 163 235, 210 236))

14 red Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (130 292, 220 292, 130 230, 130 292))

15 red Valid
POLYGON ((200 260, 108 190, 138 230, 180 292, 108 292, 132 230, 100 190, 196 66, 270 210, 200 260))

16 red Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 240 230, 169.678 100, 150.0907 125.3, 210 250, 200 260, 200 260))

17 red Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 240 230, 170 100, 210 250, 200 260, 200 260))

18 red Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260),  (157.15 230, 242 230, 242 200, 157 200, 157.15 230))

19 red Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (170 210, 242 230, 220 170, 170 170, 170 210), (131 170, 170 170, 170 150, 131 150, 131 170))

20 red Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (130 211, 200 200, 170 170, 130 211), (170 170, 200 170, 200 150, 170 150, 170 170), (200 200, 230 200, 230 170, 200 170, 200 200))

21 red Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (160 211, 200 200, 170 170, 160 211), (170 170, 200 170, 200 150, 170 150, 170 170), (200 200, 230 200, 230 170, 200 170, 200 200))

22 red Invalid
POLYGON ((200 260, 100 190, 270 210, 200 66, 200 260))

23 red Invalid
POLYGON ((200 260, 100 190, 200 202, 270 210, 200 66, 200 202, 200 260))

24 red Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (160 210, 220 210, 220 170, 160 170, 160 210), (180 200, 210 200, 212 185, 188 185, 180 200))

25 red Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260),(160 210, 220 210, 220 170, 160 170, 160 210),(200 210, 212 185, 188 185, 200 210))

26 blue Valid
POLYGON ((200 260, 110 197, 100 190, 196 66, 270 210, 200 260))

27 green Valid
POLYGON ((200 260, 110 197, 109.9999999999999 196.9999999999999, 100 190, 196 66, 270 210, 200 260))

28 green Valid
POLYGON ((200 260, 110 197, 100 222, 109.9999999999999 196.9999999999999, 100 190, 196 66, 270 210, 200 260))

29 green Valid
POLYGON ((200 260, 110 197, 140 170, 109.9999999999999 196.9999999999999, 100 190, 196 66, 270 210, 200 260))

30 green Invalid
POLYGON ((200 260, 110 197, 248 90, 109.9999999999999 196.9999999999999, 100 190, 196 66, 270 210, 200 260))

31 green Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260),  (130.0000000000001 210.9999999999999, 220 210.9999999999999, 220 170, 130.0000000000001 170, 130.0000000000001 210.9999999999999))
  
32 green Invalid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260),(129.9999999999999 211.0000000000001, 220 211.0000000000001, 220 170, 129.9999999999999 170, 129.9999999999999 211.0000000000001))

33 green Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 240 230, 169.9 99.8, 150.333 125, 210 250, 200 260, 200 260))

34 green Valid
POLYGON ((200 260, 110 197, 212.95800000000003 99, 103 192.1, 100 190, 196 66, 270 210, 200 260))

35 green Invalid
POLYGON ((200 260, 110 197, 212.95848 99.0000000000001, 103 192.1, 100 190, 196 66, 270 210, 200 260))

36 green Valid
POLYGON ((200 260, 100 190, 196 66, 270 210, 200 260), (157.1432 230, 241.9999999999952 230, 242 190, 157.142 190, 157.1432 230))



defined Error Conditions

  BS=boundary selfintersects 
  CR=crossing rings
  EN=edge not connected to interior
  FI=floating inner ring
  NA=no area
  NC=not closed
  NH=not one homogenous portion
  NO=not orientable
  NS=no surface
  Rn=rule n (n=1,3,4,5)
  RC=ring crosses ring
  RO=rings overlap
  RT=rings touch
  SR=self crossing ring
  TE=two exterior rings
  TS=two separate areas
  WO=wrong orientation
  

Valids-Delft Lab

              Table "public.valids_delft"
  Column   |   Type   | Collation | Nullable | Default 
-----------+----------+-----------+----------+---------
 pkey      | integer  |           | not null | 
 groupname | text     |           |          | 
 refvalid  | text     |           |          | 
 wkt_base  | text     |           |          | 
 geom      | geometry |           |          | 
Indexes:
    "valids_delft_pkey" PRIMARY KEY, btree (pkey)

note: entry ten is not a closed POLYGON, and does not load into PostGIS

Postgis 2.5 | GEOS 2.7.1 | refvalid MATCH

PostgreSQL 10.10 (Ubuntu 10.10-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64-bit
 POSTGIS="2.5.2 r17328" [EXTENSION] PGSQL="100" GEOS="3.7.1-CAPI-1.11.1 27a5e771" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.4.2, released 2019/06/28" LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.2.1" RASTER

PostGIS 2.3 | GEOS 3.8dev | refvalid MATCH

user=# select pkey, refvalid, st_isValid(geom) from valids_delft ;
NOTICE:  Self-intersection at or near point 163.39202965708989 235.00834105653382
NOTICE:  Hole lies outside shell at or near point 130 292
NOTICE:  Interior is disconnected at or near point 170 170
NOTICE:  Interior is disconnected at or near point 170 170
NOTICE:  Self-intersection at or near point 200 201.76470588235293
NOTICE:  Self-intersection at or near point 200 202
NOTICE:  Holes are nested at or near point 180 200
NOTICE:  Self-intersection at or near point 200 210
NOTICE:  Self-intersection at or near point 219.6352644836272 111.99294710327453
NOTICE:  Self-intersection at or near point 129.99999999999989 210.99999999999991
NOTICE:  Self-intersection at or near point 212.95837780046392 99.000086530632473
 pkey | refvalid | st_isvalid 
------+----------+------------
    1 | Valid    | t
    2 | Valid    | t
    3 | Valid    | t
    4 | Valid    | t
    5 | Valid    | t
    7 | Valid    | t
    6 | Valid    | t
    8 | Valid    | t
    9 | Valid    | t
   11 | Valid    | t
   12 | Valid    | t
   13 | Invalid  | f
   14 | Invalid  | f
   15 | Valid    | t
   16 | Valid    | t
   17 | Valid    | t
   18 | Valid    | t
   19 | Valid    | t
   20 | Invalid  | f
   21 | Invalid  | f
   22 | Invalid  | f
   23 | Invalid  | f
   24 | Invalid  | f
   25 | Invalid  | f
   26 | Valid    | t
   27 | Valid    | t
   28 | Valid    | t
   29 | Valid    | t
   30 | Invalid  | f
   31 | Valid    | t
   32 | Invalid  | f
   33 | Valid    | t
   34 | Valid    | t
   35 | Invalid  | f
   36 | Valid    | t
(35 rows)

--
PostgreSQL 9.5.14 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609, 64-bit
POSTGIS="2.3.2 r15302" GEOS="3.8.0dev-CAPI-1.12.0 " PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 2.1.3, released 2017/20/01" LIBXML="2.9.3" LIBJSON="0.11.99" RASTER

PostGIS 2.4 | GEOS 3.7.2 | refvalid MATCH

dbb=# select pkey, refvalid, st_isValid(geom) from valids_delft ;
NOTICE:  Self-intersection at or near point 163.39202965708989 235.00834105653382
NOTICE:  Hole lies outside shell at or near point 130 292
NOTICE:  Interior is disconnected at or near point 170 170
NOTICE:  Interior is disconnected at or near point 170 170
NOTICE:  Self-intersection at or near point 200 201.76470588235293
NOTICE:  Self-intersection at or near point 200 202
NOTICE:  Holes are nested at or near point 180 200
NOTICE:  Self-intersection at or near point 200 210
NOTICE:  Self-intersection at or near point 219.6352644836272 111.99294710327453
NOTICE:  Self-intersection at or near point 129.99999999999989 210.99999999999991
NOTICE:  Self-intersection at or near point 212.95837780046392 99.000086530632473
 pkey | refvalid | st_isvalid 
------+----------+------------
    1 | Valid    | t
    2 | Valid    | t
    3 | Valid    | t
    4 | Valid    | t
    5 | Valid    | t
    7 | Valid    | t
    6 | Valid    | t
    8 | Valid    | t
    9 | Valid    | t
   11 | Valid    | t
   12 | Valid    | t
   13 | Invalid  | f
   14 | Invalid  | f
   15 | Valid    | t
   16 | Valid    | t
   17 | Valid    | t
   18 | Valid    | t
   19 | Valid    | t
   20 | Invalid  | f
   21 | Invalid  | f
   22 | Invalid  | f
   23 | Invalid  | f
   24 | Invalid  | f
   25 | Invalid  | f
   26 | Valid    | t
   27 | Valid    | t
   28 | Valid    | t
   29 | Valid    | t
   30 | Invalid  | f
   31 | Valid    | t
   32 | Invalid  | f
   33 | Valid    | t
   34 | Valid    | t
   35 | Invalid  | f
   36 | Valid    | t
(35 rows)

--
PostgreSQL 10.10 (Ubuntu 10.10-1.pgdg16.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609, 64-bit
POSTGIS="2.4.3" PGSQL="100" GEOS="3.7.2-CAPI-1.11.2 0" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 2.3.2, released 2018/09/21" LIBXML="2.9.3" LIBJSON="0.11.99" LIBPROTOBUF="1.2.1"

PostGIS 2.4 | GEOS 3.6.2 | refvalid MATCH

 PostgreSQL 10.10 (Ubuntu 10.10-1.pgdg16.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609, 64-bit
 POSTGIS="2.4.3" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d6" SFCGAL="1.3.0" PROJ="Rel. 4.9.3, 15 August 2016" LIBXML="2.9.3" LIBJSON="0.11.99" LIBPROTOBUF="1.2.1" 
Note: See TracWiki for help on using the wiki.