ConvertLinearUnits (arcpyproduction.generalization)

摘要

Converts native data units to linear units such as meters, kilometers, and miles.

讨论

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.

语法

ConvertLinearUnits (dValue, layer)
参数说明数据类型
dValue

The number of units and the unit of measure to be used, for example, 1000 meters.

Double
layer

The layer whose units will be converted.

Layer

代码实例

ConvertLinearUnits example

This script converts 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)

相关主题

4/27/2014