ConvertArealUnits (arcpyproduction.generalization)

Récapitulatif

Converts native data units to area units such as square meters.

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 square kilometers.

Syntaxe

ConvertArealUnits (dValue, layer)
ParamètreExplicationType de données
dValue

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

Double
layer

The layer whose units will be converted.

Layer

Exemple de code

ConvertArealUnits example

This script converts the Facilities layer to square 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 ConverArealUnits
value=generalization.ConvertArealUnits("100 SquareMeters", inFeatLayer)

# describe inFeatLayer to determine its spatial reference units
desc=arcpy.Describe(inFeatLayer)
sr=desc.spatialReference
if sr.linearUnitName != '':
    unit=sr.linearUnitName
    print "Converted Square meters to {0} {1}".format(value,unit)
else:
    print "Converted Square meters to {0}".format(value)

Thèmes connexes

4/26/2014