Available with Production Mapping license.
Summary
Converts native data units to linear units such as meters, kilometers, and miles.
Discussion
This function is useful for converting the native data units to units that are easier to measure. For example, if the data is in decimal degrees, it is easier to identify a minimum distance value in kilometers.
Syntax
ConvertLinearUnits (length_value, layer)
Parameter | Explanation | Data Type |
length_value | The number of units and the unit of measure to be used, for example, 1000 meters. | String |
layer | The layer whose units will be converted. | Layer |
Code sample
ConvertLinearUnits example
This script converts the Facilities features to meters.
import arcpy
import arcpyproduction
from arcpyproduction import generalization
# set environment
arcpy.env.workspace="c:/Data/LocalGovernment.gdb"
# Check out Production Mapping license
arcpy.CheckOutExtension("Foundation")
# Define variables
inFeatures="ReferenceData/FacilitySite"
inFeatLayer="Facilities"
# create a feature layer
arcpy.MakeFeatureLayer_management(inFeatures,inFeatLayer)
# Execute ConvertLinearUnits
value=generalization.ConvertLinearUnits("100 Meters", inFeatLayer)
# describe inFeatLayer to determine its linear units
desc=arcpy.Describe(inFeatLayer)
sr=desc.spatialReference
if sr.linearUnitName != '':
unit=sr.linearUnitName
print "Converted meters to {0} {1}".format(value,unit)
else:
print "Converted meters to {0}".format(value)