2

I have been trying for some time to find a way to eliminate the exaggerated curves in a contour curve that I usually obtain from line 0. The idea is to obtain a polyline that is more or less faithful to the coast line but that ignores specific irregularities such as, for example, the presence of a breakwater or a dike. Although it is not an excessively complex job, this process is integrated into a tool that I am building and therefore I would like to automate it. For example, if I have the following polyline fragment:

enter image description here

I would like to get roughly the following output:

enter image description here

So far I've gotten away with simplifying the line and then smoothing it out:

arcpy.SimplifyLine_cartography(in_polyline,simp_polyline,"EFFECTIVE_AREA",45,collapsed_point_option='NO_KEEP')
arcpy.SmoothLine_cartography(sim_polyline,smooth_polyline,"PAEK",45)

enter image description here

However, I do not always get the desired output and it depends a lot on the area in which I am. Therefore I have decided to consult you, since I imagine that more than one will have run into a similar problem.

2
  • 1
    See this solution here: gis.stackexchange.com/a/397907/88814 - it could provide a starting point to be adapted: identify strongly curved sections of the line, than delete them.
    – Babel
    Commented Jun 26, 2021 at 18:37
  • I removed arcpy tag, because question will get closed if it doesn't show coding attempt. BTW can be done without scripting.
    – FelixIP
    Commented Jun 27, 2021 at 1:20

1 Answer 1

4

I think the most robust way is deriving medial axis of line buffer:

enter image description here

Vector solution is hard, perhaps consider raster based solution explained here.

Workflow (tools) for raster solution:

arcpy.Buffer_analysis(in_features="ORIGINAL", out_feature_class="in_memory/BUFFER", buffer_distance_or_field="20 Meters", line_side="FULL", line_end_type="FLAT", dissolve_option="NONE", dissolve_field="", method="PLANAR")
arcpy.PolygonToLine_management(in_features="buffer", out_feature_class="in_memory/BORDER", neighbor_option="IDENTIFY_NEIGHBORS")
arcpy.Merge_management(inputs="BORDER;ORIGINAL", output="in_memory/MERGED", field_mappings='LEFT_FID "LEFT_FID" true true false 0 Long 0 0 ,First,#,BORDER,LEFT_FID,-1,-1')
arcpy.Dissolve_management(in_features="MERGED", out_feature_class="in_memory/THREE_LINES", dissolve_field="", statistics_fields="", multi_part="SINGLE_PART", unsplit_lines="DISSOLVE_LINES")
arcpy.SelectLayerByLocation_management(in_layer="THREE_LINES", overlap_type="SHARE_A_LINE_SEGMENT_WITH", select_features="ORIGINAL", search_distance="", selection_type="NEW_SELECTION", invert_spatial_relationship="INVERT")
arcpy.PolygonToRaster_conversion(in_features="buffer", value_field="OBJECTID", out_rasterdataset="in_memory/cost_3", cell_assignment="CELL_CENTER", priority_field="NONE", cellsize="F:\SCRATCH\SCRATCH.gdb\MASK")
arcpy.gp.CostAllocation_sa("THREE_LINES", "cost_3", "F:/SCRATCH/SCRATCH.gdb/ALLOCATION", "", "", "OID", "", "", "", "", "", "", "")

Output of above:

enter image description here

As one can see result is highly dependent on a quality of flat end buffer I used at the beginning - see artefact at eastern end. Perhaps smooth original first. Note it can be done with round buffer, but it is more tricky.

Convert allocation raster to polygons and delete lines on the sides:

RasterToPolygon_conversion(in_raster="ALLOCATION", out_polygon_features="in_memory/POLYGONS", simplify="NO_SIMPLIFY", raster_field="Value", create_multipart_features="SINGLE_OUTER_PART", max_vertices_per_feature="")
PolygonToLine_management(in_features="POLYGONS", out_feature_class="in_memory/LINES", neighbor_option="IDENTIFY_NEIGHBORS")
SelectLayerByAttribute_management(in_layer_or_view="LINES", selection_type="NEW_SELECTION", where_clause='"LEFT_FID" =-1')
DeleteFeatures_management(in_features="LINES")

Output shows original smoothed result line.

enter image description here

4
  • 1
    Thanks for editing the question and especially for the answer, it's a great idea. The buffer I know how to do it, however, if there is a tool to obtain the axis of a buffer I do not know it. On the other hand, in your comment, what do you mean by what can be done without scripting? Commented Jun 27, 2021 at 11:04
  • @pyGisServer if you convert the buffer to its raster equivalent you could use the Thin tool to extract the medial axis, but it will generate spurs that need dealing with.
    – Hornbydd
    Commented Jun 27, 2021 at 18:41
  • Did you figure out how raster solution works, or shall I expand my solution?
    – FelixIP
    Commented Jun 27, 2021 at 22:10
  • @FelixIP if it is not too much trouble, I would appreciate it, the truth is that I do little with rasters In any case I have already given you the answer as good because as an initial idea it seemed really great. Thank you Commented Jun 29, 2021 at 0:49

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.