{"id":869,"date":"2012-11-04T10:38:19","date_gmt":"2012-11-04T18:38:19","guid":{"rendered":"http:\/\/blog.light42.com\/wordpress\/?p=869"},"modified":"2013-07-07T13:44:27","modified_gmt":"2013-07-07T20:44:27","slug":"check-for-validity","status":"publish","type":"post","link":"http:\/\/blog.light42.com\/wordpress\/?p=869","title":{"rendered":"Check for Validity"},"content":{"rendered":"<pre><code>SELECT \r\n  name, state_name, fips, \r\n  st_summary(the_geom), \r\n  st_isvalidreason(the_geom) \r\nFROM usa_counties \r\n  WHERE not st_isvalid(the_geom);\r\n<\/code><\/pre>\n<pre><code>NOTICE:  Ring Self-intersection at or near point -70.82466 42.26050\r\n-[ RECORD 1 ]----+-------------------------------------------------\r\nname             | Plymouth\r\nstate_name       | Massachusetts\r\nfips             | 25023\r\nst_summary       | MultiPolygon[B] with 1 elements\r\n                 |   Polygon[] with 1 rings\r\n                 |    ring 0 has 31 points\r\nst_isvalidreason | Ring Self-intersection[-70.8246609058028 42.2605069326982]\r\n\r\nTime: 268.654 ms\r\n<\/code><\/pre>\n<pre><code>UPDATE usa_counties \r\n  set the_geom = ST_MakeValid(the_geom) where name='Plymouth' and fips = '25023'; \r\n<\/code><\/pre>\n<p><code><\/p>\n<pre>SELECT \r\n  name, state_name, fips, \r\n  st_summary(the_geom), st_isvalidreason(the_geom) \r\nFROM usa_counties where not st_isvalid(the_geom); \r\n\r\n name | state_name | fips | st_summary | st_isvalidreason\r\n------+------------+------+------------+------------------ \r\n(0 rows) \r\n<\/pre>\n<p><\/code><br \/>\n<code><\/p>\n<pre>\r\nselect postgis_version();\r\n            postgis_version            \r\n---------------------------------------\r\n 2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1\r\n(1 row)\r\n<\/pre>\n<p><\/code><\/p>\n<p><img decoding=\"async\" src=\"wp-content\/uploads\/2012\/11\/ogc_invalid_geometries.png\" \/><br \/>\n&nbsp;&nbsp;<i>examples of invalid multipolygon<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SELECT name, state_name, fips, st_summary(the_geom), st_isvalidreason(the_geom) FROM usa_counties WHERE not st_isvalid(the_geom); NOTICE: Ring Self-intersection at or near point -70.82466 42.26050 -[ RECORD 1 ]&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- name | Plymouth state_name | Massachusetts fips | 25023 st_summary | MultiPolygon[B] with 1 elements | Polygon[] with 1 rings | ring 0 has 31 points st_isvalidreason | Ring Self-intersection[-70.8246609058028 42.2605069326982] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/869"}],"collection":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=869"}],"version-history":[{"count":35,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/869\/revisions"}],"predecessor-version":[{"id":1208,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/869\/revisions\/1208"}],"wp:attachment":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=869"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}