nursevast.blogg.se

Calculate geometry x arcpy
Calculate geometry x arcpy









calculate geometry x arcpy

This complex expression gets the individual parts of a multipart polygon, retrieves their areas, stores them in a Python list via a list comprehension, sorts the list, then takes the last (i.e. If the polygon has only one part, it returns the area of that part. sorted() returns the area of the largest part within a polygon.The area can be calculated in other units and with other measurement types, as discussed in the in my detailed post about geodesic areas. This accurate area calculation can be performed on feature classes in geographic coordinate systems (i.e. !SHAPE!.getArea("GEODESIC","SQUAREKILOMETERS") returns the geodesic area of a polygon feature in square kilometers.The area can be calculated in other units, identical to the Calculate Geometry tool in the attribute table. !SHAPE!.getArea("PLANAR","SQUAREKILOMETERS") returns the area of a polygon feature projected onto a two-dimensional plane in square kilometers.This is identical to the SHAPE_Area field automatically added in geodatabase feature classes. The units are the square of the feature’s coordinate system’s linear units. !SHAPE!.area returns the planar area of a polygon feature in the feature’s coordinate system as a floating point number.The length can be calculated in other units and with other measurement types, as discussed in my detailed post about geodesic areas. This accurate length calculation can be performed on feature classes in geographic coordinate systems (i.e. !SHAPE!.getLength("GEODESIC","KILOMETERS") returns the geodesic length of a line feature or the geodesic perimeter of a polygon feature in kilometers.!SHAPE!.getLength("PLANAR","KILOMETERS") returns the planar length of a line feature or the planar perimieter of a polygon feature in kilometers.This is identical to the SHAPE_Length field automatically added in geodatabase feature classes. !SHAPE!.length returns the planar length of a line feature or the planar perimeter of a polygon feature. The units are the feature’s coordinate system’s linear units.Passing in False for the boolean parameter will return the point at a horizontal distance along the line rather than a fraction of the line. For example, !SHAPE!.positionAlongLine(0.2, True) returns the point one-fifth of the length from the start of the feature to the end of the feature. To get the coordinates for the point at another fraction along the line, replace 0.5 with a value between 0.0 and 1.0. !SHAPE!.positionAlongLine(0.5,True).firstPoint.X and !SHAPE!.positionAlongLine(0.5,True).firstPoint.Y return the longitude and latitude coordinates of the midpoint of the feature as floating point numbers.This is identical to the true centroid above, unless that point is outside of the feature in which case the label point is returned. !SHAPE!.centroid.X and !SHAPE!.centroid.Y return the longitude and latitude coordinates of the centroid of the feature as floating point numbers.

calculate geometry x arcpy

The label point always lies within the feature, even when concave. !SHAPE!.labelPoint.X and !SHAPE!.labelPoint.Y return the longitude and latitude coordinates of the label point of the feature as floating point numbers.

calculate geometry x arcpy

a horseshoe) this point can lie outside of the feature.

  • !SHAPE!.trueCentroid.X and !SHAPE!.trueCentroid.Y return the longitude and latitude coordinates of the true centroid of the feature as floating point numbers.
  • If you immediately see an ERROR 999999 message, then it is likely that the parser is inadvertently set to VB Script. Also, don’t forget that the Python parser must be used. These examples assume that the name of the shape field is SHAPE. The doozy of an expression that inspired me to post this cheat sheet. Building on my previous post about geodesic areas, I’ve compiled some of the more useful one-line geometry field calculations. This underutilized feature allows for rapid access to data that normally requires running a separate geoprocessing tool and joining the result to the attribute table. Starting in ArcGIS 10.0, the attribute table also exposes the raw Geometry object of each feature to Field Calculator. Field Calculator is one of the most frequently used tools within ArcMap: taught as part of nearly every introductory GIS course, it offers spreadsheet-like features to the normally static attribute table.











    Calculate geometry x arcpy