3

ArcMap 10.7.1 — Oracle 18c SDE.ST_GEOMETRY


I have a polyline FC that has true curves.

And I have an ArcPy script that updates the M-values of the vertices in the lines:

import arcpy
connection = "Database Connections\my_conn.sde"
feature_class = connection + "\my_owner.my_fc"
spatial_reference = arcpy.Describe(feature_class).spatialReference

with arcpy.da.Editor(connection) as edit_session:
    with arcpy.da.UpdateCursor(feature_class, "SHAPE@") as cursor:
        for row in cursor:
            geometry = row[0].densify("ANGLE", 10000, 0.174533)
            parts = arcpy.Array()
            for part in geometry:
                points = arcpy.Array()
                for point in part:
                    point.M = geometry.measureOnLine(point)
                    points.append(point)
                parts.append(points)
            row[0] = arcpy.Polyline(parts, spatial_reference)
            cursor.updateRow(row)

The script reconstructs and replaces the geometry of the lines. So, unfortunately, it removes the true curves from the shapes.

Before running script:

enter image description here

After running script:

enter image description here


Question:

With ArcPy, is there a way to edit vertices without removing true curves from the SHAPE?

For example, is there way to do something like this?

UpdateVertex (shape, partNum, vertexNum, [x, y, z, m]) 

Related:

True Curves = True Evil

Idea: ArcPy - Edit vertex without removing true curves

5
  • 1
    You've got a huge corruption-ready bug in this script. All arcpy.Geometry constructors should always be provided with a SpatialReference parameter. Failure to do so means the default resolution will be applied at construction, then the actual SpatialReference silently applied on insert, resulting in truncation of coordinate values to 3 or 4 decimal places and possible geometry corruption (depending on magnitude). The Geometry itself has a hasCurves property which will let you know if you are about to corrupt the shape, but only ArcObjects can capture and re-apply the CAD (maybe).
    – Vince
    Feb 3, 2022 at 22:17
  • @Vince Thanks. Regarding the hasCurves property: it looks like that property isn't available in ArcGIS Desktop 10.7.1. desktop.arcgis.com/en/arcmap/10.7/analyze/arcpy-classes/…
    – User1974
    Feb 4, 2022 at 18:23
  • All the more reason to migrate to Pro, I guess.
    – Vince
    Feb 4, 2022 at 21:41
  • @Vince : Regarding "You've got a huge corruption-ready bug in this script." I've updated the script in this post. How does it look now? (For what it's worth, I also posted it on the Code Review Stack Exchange site: Loop through polyline vertices and update coordinate.)
    – User1974
    Feb 5, 2022 at 6:32
  • with obviates need for the del lines, and string math is inefficient/clumsy compared to using os.path.join().
    – Vince
    Feb 5, 2022 at 11:46

1 Answer 1

2

I guess you can manipulate it using JSON.

For example, this field calculator expression, when I run it on a buffer of a point:

import json
def wJson(shp):
 pnts = json.loads(shp.JSON)
 #esriJSON = arcpy.AsShape(pnts, True)
 return str(pnts)
#----
wJson( !Shape!)

Returns:

{u'curveRings': [[[1727075.9359999998, 5946765.4923], {u'a': [[1727075.9359999998, 5946765.4923], [1717013.4664801424, 5946765.4923], 0, 1]}]], u'spatialReference': {u'wkid': 2193, u'latestWkid': 2193}}

Which is just a dictionary. You can use:

esriJSON = arcpy.AsShape(pnts, True)

after amending the dictionary.

Also see getPart() method returns incorrect geometry from buffer in ArcGIS

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.