lee.godfrey

Null/Empty Geometry in Python

Discussion created by lee.godfrey on Aug 16, 2016
Latest reply on Aug 18, 2016 by rvburton

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[0]
                    print("{},{}".format(x,y))
                   row[1] = x
                   row[2] = y
                   cursor.updateRow(row)

 

 

 

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.

Outcomes