<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reconstruct shape via ArcPy: How to validate geometry? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/reconstruct-shape-via-arcpy-how-to-validate/m-p/1144700#M51572</link>
    <description>&lt;P&gt;5.&amp;nbsp; Other&lt;/P&gt;&lt;P&gt;Have you looked at what other things check for&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/validating-data/invalid-geometry.htm" target="_blank"&gt;Invalid Geometry—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;there are a whole slew of other links in the table of contents by that link that are geometry specific&lt;/P&gt;&lt;P&gt;plus the various things esri checks for&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/check-geometry.htm" target="_blank"&gt;Check Geometry (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;there is an&amp;nbsp;&amp;nbsp;&lt;EM&gt;Open Geospatial Consortium (OGC) validation method&lt;/EM&gt;&amp;nbsp; link which opens a document to their standards&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 16:24:59 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-02-16T16:24:59Z</dc:date>
    <item>
      <title>Reconstruct shape via ArcPy: How to validate geometry?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/reconstruct-shape-via-arcpy-how-to-validate/m-p/1144693#M51570</link>
      <description>&lt;P&gt;I have a field calculator Python script that I use to update the shape field of a FC.&lt;BR /&gt;&amp;nbsp;- Densifies any true curves.&lt;BR /&gt;&amp;nbsp;- Populates M-values of coordinates.&lt;BR /&gt;&amp;nbsp;- Reconstructs shape.&lt;/P&gt;&lt;PRE&gt;Expression:
-----------
new_shape( !SHAPE! )

Code Block:
-----------
&lt;SPAN class=""&gt;def&lt;/SPAN&gt; &lt;SPAN class=""&gt;new_shape&lt;/SPAN&gt;(&lt;SPAN class=""&gt;geom&lt;/SPAN&gt;):
    spatial_reference = geom.spatialReference
    geom = geom.densify(&lt;SPAN class=""&gt;"ANGLE"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;10000&lt;/SPAN&gt;, &lt;SPAN class=""&gt;0.174533&lt;/SPAN&gt;)
    parts = arcpy.Array()
    &lt;SPAN class=""&gt;for&lt;/SPAN&gt; i &lt;SPAN class=""&gt;in&lt;/SPAN&gt; &lt;SPAN class=""&gt;range&lt;/SPAN&gt;(geom.partCount):
        part = geom.getPart(i)
        points = arcpy.Array()
        &lt;SPAN class=""&gt;for&lt;/SPAN&gt; j &lt;SPAN class=""&gt;in&lt;/SPAN&gt; &lt;SPAN class=""&gt;range&lt;/SPAN&gt;(part.count):
            point = part.getObject(j)
            point.M = geom.measureOnLine(point)
            points.append(point)
        parts.append(points)
    &lt;SPAN class=""&gt;return&lt;/SPAN&gt; arcpy.Polyline(parts, spatial_reference)&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://i.stack.imgur.com/g5PUN.png" target="_self"&gt;Screenshot&lt;/A&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;I want to add logic to the script that will &lt;STRONG&gt;check the new geometry for issues.&lt;/STRONG&gt; I know from experience that problems in the code can mean that an &lt;A href="https://gis.stackexchange.com/questions/423990/why-does-for-point-in-part-work-in-a-standalone-arcpy-script-but-not-in-the" target="_self"&gt;empty geometry gets returned to the feature&lt;/A&gt; (not what I want).&lt;BR /&gt;&amp;nbsp;- I believe an empty geometry is a valid geometry. That's why the code doesn't error-out.&lt;/P&gt;&lt;P&gt;What kinds of things should I check for in the new geometry?&lt;BR /&gt;Ideas:&lt;BR /&gt;1. New shape isn't empty.&lt;BR /&gt;2. New point count vs. old point count.&lt;BR /&gt;3. New length vs. old length.&lt;BR /&gt;4. New part count vs. old part count.&lt;BR /&gt;5. Other?&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;if new_geom   and   new_geom.pointCount&amp;gt;=orig_geom.pointCount   and   abs(orig_geom.length-new_geom.length) &amp;lt; 1   and   new_geom.partCount==orig_geom.partCount:
    return new_geom
else:
    return orig_geom&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;Or is it unnecessary to check those things, other than checking for an empty shape, since ArcPy validates the geometry for us?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;I'm using ArcMap 10.7.1. But I believe this would apply to ArcGIS Pro too. (Oracle 18c SDE.ST_GEOMETRY)&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:42:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/reconstruct-shape-via-arcpy-how-to-validate/m-p/1144693#M51570</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-02-16T16:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reconstruct shape via ArcPy: How to validate geometry?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/reconstruct-shape-via-arcpy-how-to-validate/m-p/1144700#M51572</link>
      <description>&lt;P&gt;5.&amp;nbsp; Other&lt;/P&gt;&lt;P&gt;Have you looked at what other things check for&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/validating-data/invalid-geometry.htm" target="_blank"&gt;Invalid Geometry—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;there are a whole slew of other links in the table of contents by that link that are geometry specific&lt;/P&gt;&lt;P&gt;plus the various things esri checks for&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/check-geometry.htm" target="_blank"&gt;Check Geometry (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;there is an&amp;nbsp;&amp;nbsp;&lt;EM&gt;Open Geospatial Consortium (OGC) validation method&lt;/EM&gt;&amp;nbsp; link which opens a document to their standards&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:24:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/reconstruct-shape-via-arcpy-how-to-validate/m-p/1144700#M51572</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-16T16:24:59Z</dc:date>
    </item>
  </channel>
</rss>

