[924] ArcGIS Pro Mapping Module - arcpy.mp
ref: Getting started with arcpy.mp tutorial
ref: Alphabetical list of arcpy.mp functions
ref: Alphabetical list of arcpy.mp classes
ref: SQL reference for query expressions used in ArcGIS
The following diagram illustrates the utility of list functions for navigating and referencing the objects within a project or a layer file. The diagram is only an example and does not display a complete set of objects.
Classes
-
ArcGISProject: The
ArcGISProject
object provides access to ArcGIS Pro project methods and properties. A reference to this object is essential for most map automation workflows. -
Map: The
Map
object is the primary object for referencing and managing layers and tables within an ArcGIS Pro project.spatialReference
(Read and Write): Provides the ability to get or set the SpatialReference associated with the map.-
listLayers ({wildcard})
: Returns a Python list of Layer objects that exist within a map. -
listTables ({wildcard})
: Returns a Python list of Table objects that exist within a map.
-
Layer: Provides access to basic layer properties and methods.
-
supports (layer_property)
: Used to determine if a particular layer type supports a property on the layer object. Not all layers support the same set of properties; the supports property can be used to test if a layer supports that property before attempting to set it. i.e.,lyr.supports("BRIGHTNESS")
andlyr.supports("NAME")
. -
listLayers ({wildcard})
: Returns a Python list of Layer objects that exist within a map. -
listTables ({wildcard})
: Returns a Python list of Table objects that exist within a map. getSelectionSet ()
: Returns a layer's selection as a Python set of object IDs.
-
-
Table: Provides access to basic table properties and methods.
-
Layout: The Layout object references a single-page layout in an ArcGIS Pro project (.aprx). It provides access to common properties like page size and a number of different export methods.
-
listElements ({element_type}, {wildcard})
: Returns a Python list of page layout elements that exist on a Layout object. The listElements method provides access to all the elements on the page layout: GraphicElement, LegendElement, MapFrameElement, MapSurroundElement, PictureElement, and TextElement.lyt.listElements("mapframe_element") exportToPDF (out_pdf, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {clip_to_elements}, {output_as_image}, {embed_color_profile}, {pdf_accessibility})
: Exports the Layout to Portable Document Format (PDF).
-
-
MapFrame: The MapFrame object is a page layout element that is used to display the contents of a map on a layout. It also provides access to page size and positioning, basic navigation methods, and export options.
-
map
(Read and Write): The Map being displayed in the map frame. camera
(Read and Write): The Camera controls the location and viewing positions of the data being displayed within a map frame.-
getLayerExtent (layer, {selection_only}, {symbolized_extent})
: Returns a layer's extent for all features or only the selected features in a layer. -
panToExtent (extent)
: Pans and centers the MapFrame using a new Extent object without changing the map frame's scale. -
zoomToAllLayers ({selection_only}, {symbolized_extent})
: Modifies the MapFrame view to match the extent of all layers or selected layers in a map.
-
-
GraphicElement: The GraphicElement object provides access to properties that enables its repositioning on the page layout, as well as methods that allow for duplicating and deleting existing graphic elements.
-
LegendElement: The LegendElement object provides access to properties that enable its positioning and resizing on the page layout as well as modifying its title. It also provides access to individual LegendItems.
-
MapsurroundElement: Provides access to properties that enables its repositioning on the page layout as well as identifying its associated map frame.
-
PictureElement: Provides access to picture properties that enable the repositioning of a picture on the page layout as well as getting and setting its data source.
-
TextElement: The TextElement object provides access to properties that enable its repositioning on the page layout as well as modifying the text string and font size.
- Camera: The Camera object provides access to 2D and 3D viewer properties that control the display in a MapFrame or MapView.
-
Extent: An extent is a rectangle specified by providing the coordinate of the lower left corner and the coordinate of the upper right corner in map units.
-
XMax
(Read Only): The extent XMax value. None if no m-value. -
XMin
(Read Only): The extent XMin value. None if no m-value. -
YMax
(Read Only): The extent YMax value. None if no m-value. -
YMin
(Read Only): The extent YMin value. None if no m-value. -
contains (second_geometry, {relation})
: Indicates if the base geometry contains the comparison geometry. contains is the opposite of within. -
equals (second_geometry)
: Indicates if the base and comparison geometries are of the same shape type and define the same set of points in the plane. This is a 2D comparison only; M and Z values are ignored.
-
-
Geometry: Geometry objects define a spatial location and an associated geometric shape.
extent
(Read and Write): The extent of the geometry.-
boundary ()
: Constructs the boundary of the geometry. (polygon to polyline) -
buffer (distance)
: Constructs a polygon at a specified distance from the geometry. -
clip (envelope)
: Constructs the intersection of the geometry and the specified extent. -
cut (cutter)
: Splits this geometry into a part left of the cutting polyline, and a part right of it. -
intersect (other, dimension)
: Constructs a geometry that is the geometric intersection of the two input geometries. Different dimension values can be used to create different shape types. The intersection of two geometries of the same shape type is a geometry containing only the regions of overlap between the original geometries. -
union (other)
: Constructs the geometry that is the set-theoretic union of the input geometries. The two geometries being unioned must be the same shape type.
-
SearchCursor: Establishes read-only access to the records of a feature class or table. It returns an iterator of tuples. The order of values in the tuple matches the order of fields specified by the field_names argument.
Geometry object properties can be accessed by specifying the token SHAPE@ in the list of fields.
Search cursors can be iterated using a for loop.
Accessing full geometry with SHAPE@ is an expensive operation. If only simple geometry information is required, such as the x,y coordinates of a point, use tokens such as SHAPE@XY, SHAPE@Z, and SHAPE@M for faster, more efficient access.SearchCursor (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause}, {datum_transformation}) -
fields (Read Only): A tuple of field names used by the cursor. The tuple will include all fields and tokens specified by the field_names argument.
-
-
Code sample:
import arcpy fc = 'c:/data/base.gdb/well' fields = ['WELL_ID', 'WELL_TYPE', 'SHAPE@XY'] # For each row, print the WELL_ID and WELL_TYPE fields, and # the feature's x,y coordinates with arcpy.da.SearchCursor(fc, fields) as cursor: for row in cursor: print(u'{0}, {1}, {2}'.format(row[0], row[1], row[2])) - SpatialReference: Each part of the spatial reference has a number of properties (especially the coordinate system) that defines what map projection options are used to define horizontal coordinates.
A SpatialReference object can also be accessed from existing datasets using the Describe spatialReference property
-
name
(Read and Write): The name of the spatial reference. -
type
(Read and Write): The type of the spatial reference.Geographic—A geographic coordinate system.
Projected— A projected coordinate system.
-
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2019-10-24 【445】Markdown Syntax
2013-10-24 【129】地图街景链接