2

I'm using ArcPy with ArcMap 10.7.1.

I want to densify SDE.ST_GEOMETRY polylines if (and only if) the polylines have true curves.

If I were using ArcPy with the latest version of ArcGIS Pro (instead of ArcMap), then I think the hasCurves property could be used:

for row in cursor:
    polyline = row[0]
    if polyline.hasCurves() == True:
        polyline = polyline.densify('ANGLE', 10, 0.174533) #radians

Unfortunately, the hasCurves property doesn't seem to be available for a Polyline in ArcMap 10.7.1.

#ArcPy/ArcMap 10.7.1

AttributeError: 'Polyline' object has no attribute 'hasCurves'              

In ArcMap 10.7.1, is there an alternative option for determining if polylines have true curves?

3
  • 1
    If you get extra vertices on the straight parts I think you can get rid of them by simplifying with a small tolerance.
    – user30184
    Commented Feb 4, 2022 at 19:45
  • @user30184 Good idea! In my case, these sewer lines have other lines that are snapped to existing mid-line vertices. Example: a house sewer connection is snapped to a vertex within the sewer main line (not snapped to an endpoint of the line). So I need to be careful with simplifying lines. I don't want to compromise the topological integrity (lots if manual work went into it).
    – User1974
    Commented Feb 4, 2022 at 19:54
  • 1
    Have you considered to make a sort of topological backup by saving the connections also as a separate point layer?
    – user30184
    Commented Feb 4, 2022 at 20:36

2 Answers 2

1

I can't make any guarantees about preserving topology, but I will say that I've used the WKT trick before with success. IIRC, it looked something like this:

with arcpy.da.UpdateCursor(fc, ['SHAPE@']) as cursor:
    for geom, in cursor:
        geom = arcpy.FromWKT(geom.WKT)
        cursor.updateRow([geom])

This will modify your data in-place, so make sure to have a backup.

5
  • Thanks! For our notes, here are the docs for the FromWKT function for ArcMap 10.7.1
    – User1974
    Commented Feb 4, 2022 at 20:40
  • Regarding your comment about modifying data in-place". Do you have any techniques you use for testing? What I've been doing is: in a test FC, I have features that serve as the master features. I flag them as MASTER in a field. Then, before each test, in ArcMap, I copy/paste them, and flag them as something other than MASTER. In my ArcPy script, I have a line that tells the script to ignore any features that are flagged as MASTER. ... That way, I can do my testing, and modify the data in place. But I won't need to re-create my data for each test (or if something goes wrong).
    – User1974
    Commented Feb 5, 2022 at 5:44
  • 1
    Normally I'd just stick a CopyFeatures_management() in front of the UpdateCursor, or create a new empty feature class and use a SearchCursor + an InsertCursor
    – mikewatt
    Commented Feb 7, 2022 at 17:26
  • 1
    I'd like to add that the WKT technique seems to return identical results as using Geometry.densify("ANGLE", infinity, 2*pi/202), at least for circular arcs, not bezier curves though. Not sure which is faster. Commented Jul 13, 2023 at 15:26
  • I guess those arguments only give identical results for circular polygons, WKT method must be a more fancy algorithm because it's not quite the same for other curves. In any case, densifying to a 1 degree max angular deviation seems to be around 4x faster than working with the WKT. Commented Jul 13, 2023 at 15:50
1

It occurred to me that, in my case, I might not actually need to check if a polyline has true curves or not.

My scenario is: I only want to densify segments that are true curves. But I think I can do that by applying densify() to all lines (with curve(s) or not). The trick to not densifying lines without curves (or straight segments within lines with curves) might just be to use densify() properly.

densify (type, distance, deviation)

  • TYPE: ANGLE
  • DISTANCE: a really big number that would never happen, like 10,000 metres.
    • Is there a reason this argument isn't optional?
  • Deviation: 0.174533 radians (10 degrees)
polyline.densify ("ANGLE", 10000, 0.174533)

I'm not 100% sure if that actually is the proper way to use densify() for true curves. Would welcome corrections.

Your Answer

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

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