I'm trying to figure out lengths of polyline features in a feature class with a WGS 1984 coordinate system.
Here's code to list lengths:
>>> import arcpy>>> inFc = r"C:\Users\e1b8\Desktop\E1B8\GIS_Stackexchange\data.gdb\test">>> sr = arcpy.Describe (inFc).spatialReference>>> sr.nameu'GCS_WGS_1984'>>> with arcpy.da.SearchCursor (inFc, "SHAPE@") as cursor: for geom, in cursor: print geom.length0.0007855686067520.0007845582024050.001171661382220.000816779544786I'm not sure what units these lengths are in. I know it's generally in the coordinate system's linear units, but WGS 1984 has no linear units.
>>> sr.linearUnitNameu''Ultimately I'd like to be able to write code that works with distances and is compatible with both projected and geographic coordinate systems. Usually I use the spatial reference's metersPerUnit property to get to a common unit regardless of the coordinate system's unit, but this throws an error for WGS 1984:
>>> sr.metersPerUnitTraceback (most recent call last): File "", line 1, in sr.metersPerUnitAttributeError: SpatialReference: Get attribute metersPerUnit does not existSo again, how can I get the length of features? And preferably, how do I figure out their lengths in meters?
أكثر...
Here's code to list lengths:
>>> import arcpy>>> inFc = r"C:\Users\e1b8\Desktop\E1B8\GIS_Stackexchange\data.gdb\test">>> sr = arcpy.Describe (inFc).spatialReference>>> sr.nameu'GCS_WGS_1984'>>> with arcpy.da.SearchCursor (inFc, "SHAPE@") as cursor: for geom, in cursor: print geom.length0.0007855686067520.0007845582024050.001171661382220.000816779544786I'm not sure what units these lengths are in. I know it's generally in the coordinate system's linear units, but WGS 1984 has no linear units.
>>> sr.linearUnitNameu''Ultimately I'd like to be able to write code that works with distances and is compatible with both projected and geographic coordinate systems. Usually I use the spatial reference's metersPerUnit property to get to a common unit regardless of the coordinate system's unit, but this throws an error for WGS 1984:
>>> sr.metersPerUnitTraceback (most recent call last): File "", line 1, in sr.metersPerUnitAttributeError: SpatialReference: Get attribute metersPerUnit does not existSo again, how can I get the length of features? And preferably, how do I figure out their lengths in meters?
أكثر...