I have a series of Feature Classes ( Polyline/arc type) that have no Geometry associated with them. They have been converted through multiple different systems ( Mid Miff, Cable Cad ( custom viewer) and now GDB) and it was lost along the way. This is just part of the process unfortunately, and has been identified with this old set of data for years.
If I load the feature class into ArcMap and zoom to layer, nothing is visible, they have shape length of zero, going to individual ones displays nothing, as expected of having no Geometry and no shape length.
However, I can add a Double field for XCoord and YCoord, and using Calculate Geometry I can get the coordinate values for the midpoint of the line. Which allows me to then export the data out to a table, and then using display XY Coordinates I can see the locations with the associated attributes. This is the end goal of what I want, and manually in ArcMap it works.
My issues is that I have hundreds of these, and I am attempting to automate the process using Python.
I have attempted to get midpoint using: Midpoint = Feature.shape.positionAlongLine(0.50,True).firstPoint however this does not work because it states that I have Null or Empty geometry.
The below works, in that it will at least read the features, but it still returns values of None for the coordinates ( even though when I manually try in ArcMap I get values)
fields = ["SHAPE@XY","X","Y"]
with arcpy.da.UpdateCursor(path,fields) as cursor:
for row in cursor:
x,y = row
row = x
row = y
I am wondering if anyone has had any success with dealing with Null/Empty Geometries in Python coding.
Thank you anyone for your assistance
I have attached a sample of the data below in a zipped GDB.
I have tried Shape@XY, it will successfully read each line of the feature,
but it is still unable to assign the coordinate to it. When I use calculate
geometry manually in ArcMap it will assign it to them, so it does exist
somewhere, but unfortunately Shape@ does not pick them up. thank you though.
In case that you select a feature (from the attribute table) and you can zoom at, and it shows the selection in the map, but not the feature itself, you may want to check if the Spatial Index is valid. At least this has happened to me, when using an Enterprise geodatabase (Oracle in this case).
Is it possible to attache a small sample of the data to run some tests?
I did some checks with spatial index in trying to validate it but had no changes. I have attached a GDB that is some of the original data that I haven't done any tests on.
I just started an edit session and I notice that the geometries I have tested consist of two points and have the same start and end point:
That yields the SHAPE_Length is 0 and in some operations the geometry will not be considered valid.
If I run this code:
fc = r'D:\Xander\GeoNet\XYvalues\gdb\ESRIForumSampleDataSet_Lee.gdb\POLE_arc' with arcpy.da.SearchCursor(fc, ('SHAPE@')) as curs: for row in curs: polyline = row print polyline.firstPoint.X, polyline.firstPoint.Y, polyline.lastPoint.X, polyline.lastPoint.Y, polyline.length
It will yield, X and Y of the firstPoint, X and Y of the lastPoint and the length of the line:
272575.775391 741323.871826 272575.775391 741323.871826 0.0 272542.675415 741357.241821 272542.675415 741357.241821 0.0 272536.0354 741340.311829 272536.0354 741340.311829 0.0 272460.255432 741441.681824 272460.255432 741441.681824 0.0 272364.155396 741540.721802 272364.155396 741540.721802 0.0
You can see start and end are the same and the length is 0.