How To Create ShapeLength 0 Line

482
3
10-17-2019 05:46 AM
DaveTenney
Occasional Contributor III

All,

in an attempt to qc certain possibilities we wanted to try and create a line feature that has a valid geometry but 0.0 shape length. we actually saw this in real-world data, unfortunately, we no longer have the data set where we saw this, so i was wondering if it is even possible to create such a feature?

thanks

Dave

0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

conceptually, a 2 point line where the start and end coordinate 

 pl = arcpy.Polyline(arcpy.Array([arcpy.Point(0.0, 0.0), arcpy.Point(0., 0.)]))

pl.length
0.0

identical

0 Kudos
DaveTenney
Occasional Contributor III

my original thought was that the start and end coordinates would have to be the same, but ArcMAP doesnt allow that to be saved. the user is notified that there is invalid geometry and edits cannot be saved.

thanks

dave

0 Kudos
DanPatterson_Retired
MVP Emeritus

You can create the feature but not the featureclass... Geometry is validated when you try to create it (eg as a shapefile or a featureclass). You would need to have a file that contains bad geometry to begin with I suppose so that you could use Check Geometry and/or Repair Geometry.

Try creating a 2 point line in ArcMap and/or Pro, then edit the coordinates there to see if it will save.  Attempts to use 

arcpy.management.CreateFeatureclass and an arcpy.da.InsertCursor and a CopyFeatures just create a null geometry as you can see from the attached shapefile

0 Kudos