﻿{"id":6857,"date":"2018-11-05T06:19:22","date_gmt":"2018-11-05T05:19:22","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=6857"},"modified":"2023-04-28T14:58:52","modified_gmt":"2023-04-28T12:58:52","slug":"gis-tools-for-validating-geometries-1","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/gis-tools-for-validating-geometries-1\/","title":{"rendered":"GIS tools for validating geometries (1)"},"content":{"rendered":"\n<p>Management and treatment algorithms for GIS data are developed with the\nassumption that the geometry of the entities meets certain specifications. When\nthe data processing algorithms deal with data that does not respect these specifications,\nthe software can simply crash or, worse, the operation can succeed with no\napparent problem but the result is wrong. The subject is complicated since\nthere is almost no documentation as for what each software does. And if you\nthink that a control \u00ab\u00a0<strong>Repair<\/strong> <strong>geometries<\/strong>\u00a0\u00bb will remediate\nthis problem, you are far from reality &#8230; <br>\nAt the origin of the wrong geometries; we find, basically, the ESRI shapefiles.\nThis quite old format (from the eighties) was not designed to incorporate the\ntopology constraints of a GIS. For example, two contiguous polygons can be\nsuperimposed without problem , their boundaries can be double, there may be\nempty spaces between the two limits , &#8230; <br>\nUnfortunately , it\u2019s become a standard format for data exchange between\ndifferent GIS software , and even if all software publishers as well as the\nOpenSource projects strive to propose alternative, powerful and much safer\nmanagement formats (ESRI geodatabase, <a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/starting-with-postgres-postgis\/\">PostGIS<\/a>, Spatialite &#8230;) the users, most\noften, opt for the ease of the shapefile solution. <br>\nBut for those who opt for these current database formats, the problem is, only,\nsolved for the data created directly in these formats. When shapefiles\n(shapefile) are loaded into ESRI geodatabases (personal or files), in a PostGis\ndatabase or Spatiality, etc., geometries are copied as they are, with all the\nexisting geometry problems. The same precaution and care must be taken when\nusing other formats where these data is imported. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>The indispensable work includes two steps, conveyed by two GIS tools: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>analysing the geometry to detect abnormalities, usually under the form of a tool \u00ab\u00a0Check the geometries\u00a0\u00bb <\/li><li>correcting the detected defects, generally under the form of a tool \u00ab\u00a0Repair geometries\u00a0\u00bb <\/li><\/ul>\n\n\n\n<p>The tool Check Geometry will generate a report of all entities with\ngeometry problems in the geographical layers provided. To solve these problems,\nthe geometry repair tool will, automatically, perform the correction. This\nseems magical, but it&rsquo;s a lot more complicated\u2026<\/p>\n\n\n\n<p>Although there are different definitions for a polygon, most current GIS\nsoftware, use the definition stated by the Open Geospatial Consortium (OGC) and\nthe Organization International Standards (ISO), and provide validation\nfunctions to ensure compliance with the polygons definition. There are small\nvariations between the different implementations, but &nbsp;&nbsp;the\nvalidation of a two-dimensional polygon can be considered as a problem solved\nat the theoretical level. To have a common definition, as well as validation tools\nGIS users should be provided with the possibility to exchange data sets and use\nspatial analysis operations with these data (a valid input is a prerequisite\nfor most operations). <br>\nHowever, if a polygon does not comply with the definition, it has to be fixed.\nMost validation tools give the user a list of errors and locations where they\nare located, but the user must fix these shortcomings manually. This is a very\ntedious and time consuming task. <\/p>\n\n\n\n<p>Hence the obvious temptations to use the auto repair geometries tools. <\/p>\n\n\n\n<p>In this series of articles, we will discuss how the main GIS software behaves\nto detect and correct the geometries. Let&rsquo;s say right away that if you want one\na 100% efficient, you will be disappointed. But it is worth knowing what the\npossible shortcomings are than to pretend there are none.<\/p>\n\n\n\n<p>The first problem faced to tackle this topic is the almost total lack of\nsoftware documentation. Therefore we will consider a layer of polygons\ncontaining abnormalities and process them with the different softwares . <\/p>\n\n\n\n<p>We will use a layer of Italian municipalities provided by ISTAT, the\nItalian Statistical Institute. It is this layer that is used in the page on\nvalidating Spatialite geometries: <a href=\"https:\/\/translate.google.com\/translate?hl=en&amp;prev=_t&amp;sl=auto&amp;tl=en&amp;u=https:\/\/www.gaia-gis.it\/fossil\/libspatialite\/wiki%3Fname%3Dliblwgeom-4.0\">SQL functions based on\nliblwgeom support in version 4.0.0<\/a> . <\/p>\n\n\n\n<p>You can download this layer with the following link:  <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"459\" height=\"517\" data-attachment-id=\"6858\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/gis-tools-for-validating-geometries-1\/g1-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g1.png?fit=459%2C517&amp;ssl=1\" data-orig-size=\"459,517\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"g1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g1.png?fit=459%2C517&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g1.png?resize=459%2C517&#038;ssl=1\" alt=\"\" class=\"wp-image-6858\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g1.png?w=459&amp;ssl=1 459w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g1.png?resize=266%2C300&amp;ssl=1 266w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/figure>\n\n\n\n<p><strong>Geometry validation with ArcGis<\/strong> \n\nLet&rsquo;s state the following setting: <br>\n&#8211; we use ArcGIS 10.3 in English <br>\n&#8211; the order used is Toolbox -&gt; Data Management Tools -&gt; Features -&gt;\nCheck Geometry <br>\n&#8211; the layer to be tested is the layer com2011.shp that we have downloaded &nbsp;\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"229\" data-attachment-id=\"6859\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/gis-tools-for-validating-geometries-1\/g2-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g2.png?fit=525%2C229&amp;ssl=1\" data-orig-size=\"525,229\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"g2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g2.png?fit=525%2C229&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g2.png?resize=525%2C229&#038;ssl=1\" alt=\"\" class=\"wp-image-6859\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g2.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g2.png?resize=300%2C131&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nOnce\nthe order is executed , the table with the list of invalid records is loaded in\nArcMap \n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"293\" data-attachment-id=\"6860\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/gis-tools-for-validating-geometries-1\/g3-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g3.png?fit=525%2C293&amp;ssl=1\" data-orig-size=\"525,293\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"g3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g3.png?fit=525%2C293&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g3.png?resize=525%2C293&#038;ssl=1\" alt=\"\" class=\"wp-image-6860\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g3.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/11\/g3.png?resize=300%2C167&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>You will find that the order has not found any invalid geometry. <\/p>\n\n\n\n<p>If we search in ArcGis help, the only description of the work done by the\ncommand <strong><em>Check<\/em><\/strong> <strong><em>geometries<\/em><\/strong> is in the page <a href=\"https:\/\/translate.google.com\/translate?hl=en&amp;prev=_t&amp;sl=auto&amp;tl=en&amp;u=http:\/\/desktop.arcgis.com\/fr\/desktop\/latest\/tools\/data-management-toolbox\/check-geometry.htm\">http:\/\/desktop.arcgis.com\/en\/desktop\/latest\/tools\/data-management-toolbox\/check-geometry.htm<\/a> <\/p>\n\n\n\n<p>It becomes clear that the detected mistakes are: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Short segment: some segments are shorter than the size authorized by the units of the reference spatial system associated with the geometry. <\/li><li>Null geometry: the entity does not have any geometry or anything in the SHAPE field. <\/li><li>Incorrect ring ordering: the polygon is simple from a topological point\nof view but his loops may not be oriented correctly (external loops: clockwise, inner loops: counter clockwise). <\/li><li>Invalid segment orientation:\nindividual segments are not consistently oriented. The arrival point of the segment i must correspond to the starting point of the segment i + 1. <\/li><li>Self-intersections: a polygon should not be self-intersecting. <\/li><li>Unclosed rings: the end point of the last segment in a loop must match the starting point of the first segment. <\/li><li>Empty parts: the geometry includes several parts and one of them is empty (has any geometry). <\/li><li>Duplicate vertex: the geometry has two or more peaks with identical coordinates.<\/li><li>Mismatched attributes: the Z or M coordinate at the end of a line segment does not match the concurrent Z or M coordinate of the next segment. <\/li><li>Discontinuous parts: one of the\nparts of the geometry is composed of disconnected or discontinuous\nparts. <\/li><li>Empty Z values: the geometry presents one or many peaks including an empty Z value (NaN, for example). <\/li><li>Bad envelope: the envelope does not correspond to the\nextent of the coordinates of the geometry. <\/li><li>Bad dataset extent: the extent of the data set does not contain all entities. <\/li><\/ul>\n\n\n\n<p>Satisfied with our test, we will load this shape in a Spatialite database.\nNote that this would exactly the same if using a PostGis database, the SQL\nvalidation tools being exactly the same . In the next article, we will use\nSpatialite because you do not need to install PostGres or anything special, if\nyou have for ArcGIS or QGis. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Management and treatment algorithms for GIS data are developed with the assumption that the geometry of the entities meets certain specifications. When the data processing algorithms deal with data that does not respect these specifications, the&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"give_campaign_id":0,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1260],"tags":[],"class_list":["post-6857","post","type-post","status-publish","format-standard","hentry","category-non-classe-en"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-1MB","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/6857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/comments?post=6857"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/6857\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=6857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=6857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=6857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}