python to identify curved segments
I posted a similar question on the ESRI forums, but the posting seems to have gone cold :(
Anyone know how to identify if an ESRI feature class contains curved, (arcs) segment(s)?
I have several thousand feat. classes, something via python would be great!
thanks!
Edit: update
someone at esri has commented that you can detect if a polyline feature contains an arc segment by comparing the "truecentroid" and "centroid" of the feature. if truecent. <> cent: then the feature contains an arc. This is OK, but I'm still lacking a solution for polygons, as the above method does not work.
Here's what we have so far:
lstFCs = arcpy.ListFeatureClasses("*", "Pol开发者_StackOverflowyline")
for fc in lstFCs:
rows = arcpy.SearchCursor(fc)
print fc
for row in rows:
type = row.Shape
geom = str(type.centroid.X)
truegeom = str(type.trueCentroid.X)
if geom != truegeom:
print row.ObjectID
del row, rows
For the polygons I think you have to first loop through the rings of the polygons to find polylines and then you can examine the polylines as you do in your code.
Sorry I cannot help you any further since I don't have ArcGIS installed (and it is all long time ago I worked with ArcGIS). You might get better response on gis.stackexchange.com.
Try something like this:
import arcpy, json
arcpy.env.workspace = r"..." #Your database
lstFCs = arcpy.ListFeatureClasses("*", "Polyline")
for fc in lstFCs:
rows = arcpy.SearchCursor(fc)
print fc
for row in rows:
jsonGeometry = json.loads(row.Shape.JSON)
if 'curve' in jsonGeometry or 'curveRings' in jsonGeometry:
print row.ObjectID
del row, rows
There is a standard function in Geospatial SQL that is useful for what you want to do. It is called ST_CurvosityIndex(LineString). Applied to a feature LineString gives it an index number between 1-0. 1 means a straight line, 0 a string of lines that have start and end points at the same coordinate.
Unfortunately, I couldn't find any other information on how the algorithm behind this SQL/MM statement was implemented, but I think you can email Alessandro Furieri a.furieri@lqt.it, who developed that SQL statement, asking him about the algorithm that distinguishes how curved the LineString feature is.
精彩评论