Select to view content in your preferred language

identifying arc segments in python

2664
6
06-03-2011 08:11 AM
danbecker
Regular Contributor
In python, how would one go about identifying feat. classes that contain arc segments?

Client's oracle system wont' load feat. classes containing arcs, and I don't have ArcInfo to run generalize command!

So, best I can do is identify feat. classes, then manually fix them in ArcMap...thanks.
Tags (2)
0 Kudos
6 Replies
JakeSkinner
Esri Esteemed Contributor
If an arc exists, it's centroid and true centroid will be different values.  Therefore you can search each feature class to see if any centroids do not match the true centroids.  Ex:


lstFCs = arcpy.ListFeatureClasses("*", "Polyline")

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 
          


This will print the feature class and the OBJECTID of any arcs within that feature class.
0 Kudos
danbecker
Regular Contributor
humm, created 2 polygons inside a feat. class. OBJECTID = 1 was created using the "end arc point segment tool" and OBJECTID = 2 was created using the "straight line segment" tool.

Ran this script:
fclist = gp.listfeatureclasses("arc_test*")
            for fc in fclist:
                rows = gp.searchcursor(fc)
                row = rows.next()
                while row:
                    typ = row.Shape
                    geom = str(typ.centroid.X)
                    print row.getvalue("OBJECTID"), geom
                    truegeom = str(typ.truecentroid.X)
                    print row.getvalue("OBJECTID"), truegeom
                    row = rows.next()

Here is the output:

1 -93.0638463269
1 -93.0638463269
2 -93.0635589449
2 -93.0635589449

both geom & truegeom are the same, for both polygons, even though 1 of them contains an arc segment??
0 Kudos
JakeSkinner
Esri Esteemed Contributor
The previous code will only work for polyline feature classes.  I will have to see if there is a way to do this for polygon feature classes.
0 Kudos
danbecker
Regular Contributor
thanks Jake.

Yeah, unfortunately, most of the feat. classes I need to check are polygons
0 Kudos
ToddSmith
New Contributor II
This code works great if you want to identify lines that are not straight but I am not having much luck identifying true "arcs."  For example, if you run this code on a pipe feature class it flags almost all of them because there are not too many that are straight.  Any ideas on how to flag only the line segments that were drawn in as an end point arc segment?
Thanks,
Todd
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Truncate how many decimals are returned for the centroid and 'true' centriod.  For example:

for fc in lstFCs:
    rows = arcpy.SearchCursor(fc)
    print fc
    for row in rows:
        type = row.Shape
        geom = "%.4f" % type.centroid.X
        truegeom = "%.4f" % type.trueCentroid.X
        if geom != truegeom:
            print row.ObjectID

del row, rows


This should only return your 'true' arcs.
0 Kudos