arcpy.cartography.GridIndexFeatures(out_feature_class, {in_features}, {intersect_feature}, {use_page_unit}, {scale}, {polygon_width}, {polygon_height}, {origin_coord}, {number_rows}, {number_columns}, {starting_page_number}, {label_from_origin})
|
名称
|
说明
|
数据类型
|
|
out_feature_class
|
生成的面索引要素的要素类。
输出要素类的坐标系按照以下方法确定:
如果坐标系是通过输出坐标系环境指定的,则输出要素类将使用此坐标系。
如果坐标系不是通过输出坐标系环境指定的,则输出要素类将使用活动地图的坐标系(ArcGIS Pro 已打开)。
如果坐标系不是通过输出坐标系环境指定的,且无活动地图(ArcGIS Pro 未打开),则输出要素类使用第一个输入要素的坐标系。
如果坐标系不是通过输出坐标系环境指定的,并且没有活动地图(ArcGIS Pro 未打开),也没有指定的输入要素,则输出要素类的坐标系为未知。
|
Feature Class
|
|
in_features
[in_features,...]
(可选)
|
输入要素可用于定义将创建的面格网的范围。
|
Feature Layer; Raster Layer
|
|
intersect_feature
(可选)
|
将输出格网要素类限制为与输入要素图层或数据集相交的区域。 输入要素的交集将用作创建索引要素。
|
Boolean
|
|
use_page_unit
(可选)
|
指定索引面的大小输入是否使用页面单位。
|
Boolean
|
|
scale
(可选)
|
地图比例。 如果索引面的高度和宽度要使用页面单位来计算,则必须指定比例。 如果该工具在活动 ArcGIS Pro 会话以外使用,则默认比例值为 1。
|
Long
|
|
polygon_width
(可选)
|
使用地图单位或页面单位指定的索引面的宽度。 如果使用页面单位,则默认值为 1 英寸。 如果使用地图单位,则默认值为 1 度。
|
Linear Unit
|
|
polygon_height
(可选)
|
使用地图单位或页面单位指定的索引面的高度。 如果使用页面单位,则默认值为 1 英寸。 如果使用地图单位,则默认值为 1 度。
|
Linear Unit
|
|
origin_coord
(可选)
|
输出格网要素类的左下角原点的坐标值。 如果输入要素已指定,则默认值由这些要素的范围的并集来确定。 如果未指定输入要素,则默认坐标为 0 和 0。
|
Point
|
|
number_rows
(可选)
|
沿原点的 y 方向创建的行数。 默认值为 10。
|
Long
|
|
number_columns
(可选)
|
沿原点的 x 方向创建的列数。 默认值为 10。
|
Long
|
|
starting_page_number
(可选)
|
各格网索引要素将分配到连续的页码,起始页码需要指定。 默认值为 1。
|
Long
|
|
label_from_origin
(可选)
|
指定页码(标注)的开始位置。
|
Boolean
|
代码示例
GridIndexFeatures 示例 1(Python 窗口)
在如下示例中,将通过输入要素的交集和以地图单位指定的索引要素的大小来创建格网索引要素。
import arcpy
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
arcpy.cartography.GridIndexFeatures("gridIndexFeatures","poly", "", "", "",
"1000 meters", "1000 meters")
GridIndexFeatures 示例 2(Python 窗口)
在如下示例中,将通过输入要素的整个范围和以页面单位指定的索引要素的大小来创建格网索引要素。
import arcpy
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
arcpy.cartography.GridIndexFeatures("gridIndexFeatures","poly",
"NO_INTERSECTFEATURE", "USEPAGEUNIT",
"100000", "5 inches", "5 inches")
GridIndexFeatures 示例 3(Python 窗口)
在如下示例中,将通过输入要素的交集、以地图单位指定的索引要素的大小以及起始页码 5 来创建格网索引要素。
import arcpy
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
arcpy.cartography.GridIndexFeatures("gridIndexFeatures","poly", "", "", "",
"1000 meters", "1000 meters", "", "",
"", "5")
GridIndexFeatures 示例 4(Python 窗口)
在如下示例中,将通过指定原点坐标、使用地图单位的索引要素尺寸、行数和列数来创建格网索引要素。
import arcpy
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
arcpy.cartography.GridIndexFeatures("gridIndexFeatures", "", "", "", "",
"1000 meters","1000 meters",
"-6000000 -1600000", "15", "20")
GridIndexFeatures 示例 5(Python 窗口)
在如下示例中,将通过指定原点坐标、使用页面单位的索引要素尺寸、行数、列数、起始页码 5 以及将在原点开始的标注来创建格网索引要素。
import arcpy
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
arcpy.cartography.GridIndexFeatures("gridIndexFeatures", "", "", "USEPAGEUNIT",
"100000", "5 inches", "5 inches",
"-6000000 -1600000", "15", "20", "5",
"LABELFROMORIGIN")
GridIndexFeatures 示例 6(独立脚本)
在如下示例中,将通过输入要素的交集和以地图单位指定的索引要素的大小来创建格网索引要素。
# gridindexfeatures_example1.py
# Description: Creates Grid Index Features using the intersection of input
# features and specified index feature dimensions in map units
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
# Set local variables
outFeatureClass = "gridIndexFeatures"
inFeatures = "poly"
polygonWidth = "1000 meters"
polygonHeight= "1000 meters"
# Run GridIndexFeatures
arcpy.cartography.GridIndexFeatures(outFeatureClass,inFeatures, "", "", "",
polygonWidth, polygonHeight)
GridIndexFeatures 示例 7(独立脚本)
在如下示例中,将通过输入要素的整个范围和以页面单位指定的索引要素的大小来创建格网索引要素。
# gridindexfeatures_example2.py
# Description: Creates Grid Index Features using the entire extent of input
# features and specified index feature dimensions in page units
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
# Set local variables
outFeatureClass = "gridIndexFeatures"
inFeatures = "poly"
noIntersect = "NO_INTERSECTFEATURE"
usePageUnit = "USEPAGEUNIT"
scale = "100000"
polygonWidth = "5 inches"
polygonHeight= "5 inches"
# Run GridIndexFeatures
arcpy.cartography.GridIndexFeatures(outFeatureClass, inFeatures, noIntersect,
usePageUnit, scale, polygonWidth,
polygonHeight)
GridIndexFeatures 示例 8(独立脚本)
在如下示例中,将通过输入要素的交集、以地图单位指定的索引要素的大小以及起始页码 5 来创建格网索引要素。
# gridindexfeatures_example3.py
# Description: Creates Grid Index Features using the intersection of input
# features, specified index feature dimensions in map units and 5 as the
# starting page number
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
# Set local variables
outFeatureClass = "gridIndexFeatures"
inFeatures = "poly"
polygonWidth = "1000 meters"
polygonHeight= "1000 meters"
startingPageNum = "5"
# Run GridIndexFeatures
arcpy.cartography.GridIndexFeatures(outFeatureClass,inFeatures, "", "", "",
polygonWidth, polygonHeight, "", "", "",
startingPageNum)
GridIndexFeatures 示例 9(独立脚本)
在如下示例中,将通过指定原点坐标、使用地图单位的索引要素尺寸、行数和列数来创建格网索引要素。
# gridindexfeatures_example4.py
# Description: Creates Grid Index Features by specifying the origin
# coordinates, the index feature dimensions in map units, the number of
# rows and the number of columns
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference("North America Albers Equal Area Conic.prj")
# Set local variables
outFeatureClass = "gridIndexFeatures"
polygonWidth = "1000 meters"
polygonHeight= "1000 meters"
originCoord = "-6000000 -1600000"
numberRows = "15"
numberColumns = "20"
# Run GridIndexFeatures
arcpy.cartography.GridIndexFeatures(outFeatureClass, "", "", "", "",
polygonWidth, polygonHeight, originCoord,
numberRows, numberColumns)
GridIndexFeatures 示例 10(独立脚本)
在如下示例中,将通过指定原点坐标、使用页面单位的索引要素尺寸、行数、列数、起始页码 5 以及将在原点开始的标注来创建格网索引要素。
# gridindexfeatures_example5.py
# Description: Creates Grid Index Features by specifying the origin
# coordinates, the index feature dimensions in page units, the number of
# rows, the number of columns, 5 as the starting page number and labeling
# to start at the origin
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:\\data\\ProjectData.gdb"
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference("North America Albers Equal Area Conic.prj")
# Set local variables
outFeatureClass = "gridIndexFeatures"
usePageUnit = "USEPAGEUNIT"
scale = "100000"
polygonWidth = "1000 meters"
polygonHeight= "1000 meters"
originCoord = "-6000000 -1600000"
numberRows = "15"
numberColumns = "20"
startingPageNum = "5"
labeling = "LABELFROMORIGIN"
# Run GridIndexFeatures
arcpy.cartography.GridIndexFeatures(outFeatureClass, "", "", usePageUnit,
scale, polygonWidth, polygonHeight,
originCoord, numberRows, numberColumns,
startingPageNum, labeling)