HowTo:  Calculate feature centroids

相关信息
Article ID: 41027
Software:
ArcGIS - ArcEditor 10
ArcGIS - ArcInfo 10
ArcGIS - ArcView 10
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
ArcGIS for Desktop Basic 10.1
Platforms:
Windows XP, Vista, Windows 7, Windows 8

问题描述
Feature centroids can be calculated in several ways. Depending on how the centroid needs to calculated, there are several possible methods: calculate the features' central XY coordinates, use the Feature to Point tool, or use Python to retrieve centroid coordinates. Instructions provided below describe these methods.
已邀请:

EsriSupport

赞同来自:

解决方案
  1. Calculate the x,y coordinates of the feature using Calculate Geometry This method uses the Calculate Geometry function to find the latitude (y-coordinate of the centroid) and longitude (x-coordinate) of the centroids and constructs an XY Event Layer to display them.
  2. Use the Feature To Point (Data Management) tool This method uses the center of gravity of the polygon; the geometric center of a feature. For line, polygon, or three-dimensional features, it is the center of mass (or center of gravity) and may fall inside the feature or outside the feature. For multipoint, polyline, or polygon feature classes with multiple parts, the centroid is computed using the weighted mean center of all feature parts.
    This tool is only available at the Advanced, ArcInfo, license level.The Feature to Point tool is used to create a new feature class containing points generated from the representative locations of input features. The algorithms for the specific calculation are proprietary, but there are two basic concepts used. The tool calculates the centroid of multipoint, line, or polygon input using a center of gravity-based algorithm. The center of gravity calculation uses the geometric center model to output the new point feature class. For lines, polygons, or three-dimensional features, it is the center of mass (center of gravity) and may fall inside or outside the feature. For multipoint, polylines, or polygons with multiple parts, it is computed using the weighted mean center of all feature parts. Within the tool parameters there is an option to calculate the centroid that falls within the feature boundaries; this option can be enabled by checking the box for 'inside'. Enabling this parameter forces the tool to calculate a centroid that is inside the feature boundaries, if it originally falls outside the boundaries the point will be adjusted to what is considered the center of gravity within the boundaries. 
  3. Use Python to calculate and build centroid points In the following sample, the Data Access Module is used to easily retrieve the centroid coordinates using the SHAPE@xy token. These coordinates are then used to build point geometry, which is then written to a new feature class.
    The Data Access cursors are available only at ArcGIS 10.1 and higher. See Reading Geometries and Writing Geometries for alternative workflows for version 10.
    import arcpyinput_fc = "C:\\temp\\geodatabase.gdb\\states"output_fc = "C:\\temp\\geodatabase.gdb\\state_centroids"cursor = arcpy.da.SearchCursor(input_fc, "SHAPE@xy")centroid_coords = []for feature in cursor:    centroid_coords.append(feature[0])point = arcpy.Point()pointGeometryList = []for pt in centroid_coords:    point.X = pt[0]    point.Y = pt[1]    pointGeometry = arcpy.PointGeometry(point)    pointGeometryList.append(pointGeometry)arcpy.CopyFeatures_management(pointGeometryList, output_fc)


其它相关参考
  1. Feature To Point (Data Management)
  2. Find the centroid of polygons using Calculate GeometryInstructions provided describe how to find the centroid of polygons using Calculate Geometry.
  3. PointGeometry (arcpy)
  4. SearchCursor (arcpy.da)


创建及修改时间
Created: 3/26/2013

Last Modified: 12/2/2014
原文链接
http://support.esri.com/en/kno ... 41027

要回复问题请先登录注册