arcgis.geometry module
The arcgis.geometry module defines useful geometry types for working with geographic information and GIS functionality.It provides functions which use geometric types as input and output as well as functions for easily convertinggeometries between different representations.
Several functions accept geometries represented as dictionaries and the geometry objects in this module behave like themas well as support the ‘.’ (dot) notation providing attribute access.
Note
It is recommended to have ArcPy or Shapely downloaded for most Geometry methods and property usage.
Examples:
# Example Point
>>>pt=Point({"x":-118.15,"y":33.80,"spatialReference":{"wkid":4326}})>>>print(pt.is_valid)True>>>print(pt.type)# POINT'POINT'>>>print(pt)'{"x" : -118.15, "y" : 33.80, "spatialReference" : {"wkid" : 4326}}'>>>print(pt.x,pt.y)(-118.15,33.80)
# Example Polyline
>>>line={ "paths" : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]], [[-97.06326,32.759],[-97.06298,32.755]]], "spatialReference" : {"wkid" : 4326}}>>>polyline=Polyline(line)>>>print(polyline)'{"paths" : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]],[[-97.06326,32.759],[-97.06298,32.755]]],"spatialReference" : {"wkid" : 4326}}'>>>print(polyline.is_valid)True
# Example INVALID Geometry
>>>line={ "paths" : [[[-97.06138],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]], [[-97.06326,32.759],[-97.06298,32.755]]], "spatialReference" : {"wkid" : 4326}}>>>polyline=Polyline(line)>>>print(polyline)'''{"paths" : [[[-97.06138],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]],[[-97.06326,32.759],[-97.06298,32.755]]],"spatialReference" : {"wkid" : 4326}}'''>>>print(polyline.is_valid)False
The same patterna can be repeated for Polygon, MultiPoint and SpatialReference.
You can create a Geometry even when you don’t know the exact type. The Geometry constructor can find thegeometry type and returns the correct type as the example below demonstrates:
# Example Unknown Geometry Type>>>geom=Geometry({"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],[-97.06326,32.759]]],"spatialReference":{"wkid":4326}})>>>print(geom.type)# Polygon'Polygon'>>>print(isinstance(geom,Polygon)True
Point
- classarcgis.geometry.Point(iterable=None,**kwargs)
The
Point
class contains x and y fields along with aSpatialReference
field. APoint
can also contain m and z fields. APoint
is empty when its xfield is present and has the valuenull or the stringNaN. An emptypoint
hasno location in space.- coordinates()
Retrieves the coordinates of the
Point
as an np.array#Usage Example>>>coords=point.coordinates()>>>coords[x1,y1,m1,z1]
- Returns:
An np.array containing coordinate values
- svg(scale_factor:float=1,fill_color:str|None=None)
Returns a SVG (Scalable Vector Graphic) circle element for the
Point
geometry.SVG defines vector-based graphics in XML format.Keys
Description
scale_factor
An optional float. Multiplication factor for the SVG circle diameter. Default is 1.
fill_color
An optional string. Hex string for fill color. Default is to use “#66cc99” if geometry isvalid, and “#ff3333” if invalid.
- Returns:
An SVG circle element
MultiPoint
- classarcgis.geometry.MultiPoint(iterable=None,**kwargs)
A
multipoint
contains an array ofPoint
, along with aSpatialReference
field. Amultipoint
can also haveboolean-valuedhasZ andhasM fields. These fields control the interpretation of elements of the pointsarray.Note
Omitting anhasZ orhasM field is equivalent to setting it tofalse.
Each element of the points array is itself an array of two, three, orfour numbers. It will have two elements for 2D points, two or threeelements for 2D points with Ms, three elements for 3D points, and threeor four elements for 3D points with Ms. In all cases, the x coordinateis at index 0 of a point’s array, and the y coordinate is at index 1.For 2D points with Ms, the m coordinate, if present, is at index 2. For3D points, the Z coordinate is required and is at index 2. For 3Dpoints with Ms, the Z coordinate is at index 2, and the M coordinate,if present, is at index 3.
Note
An empty multipoint has a points field with no elements. Empty pointsare ignored.
- coordinates()
Retrieves the coordinates of the
MultiPoint
as an np.array#Usage Example>>>coords=multiPoint.coordinates()>>>coords[[x1,y1,m1,z1],[x2,y2,m2,z2],...]
- Returns:
An np.array containing coordinate values for each point
- svg(scale_factor:float=1.0,fill_color:str|None=None)
Returns a group of SVG (Scalable Vector Graphic) circle element for the
MultiPoint
geometry.Keys
Description
scale_factor
An optional float. Multiplication factor for the SVG circle diameter. Default is 1.
fill_color
An optional string. Hex string for fill color. Default is to use “#66cc99” if geometry isvalid, and “#ff3333” if invalid.
- Returns:
A group of SVG circle elements
Polyline
- classarcgis.geometry.Polyline(iterable=None,**kwargs)
The
Polyline
contains an array of paths or curvePaths and aSpatialReference
. ForPolylines
with curvePaths, see the sections onJSON curve object andPolyline
with curve. Each path is represented asan array ofPoint
, and each point in the path is represented as anarray of numbers. APolyline
can also have boolean-valued hasM and hasZfields.Note
See the description of
MultiPoint
for details on how the point arrays are interpreted.An empty
PolyLine
is represented with an empty array for the pathsfield. Nulls and/or NaNs embedded in an otherwise defined coordinatestream forPolylines
andPolygon
objects is a syntax error.- coordinates()
Retrieves the coordinates of the
Polyline
as a np.array#Usage Example>>>coords=polyLine.coordinates()>>>coords[[x1,y1,m1,z1],[x2,y2,m2,z2],...]
- Returns:
An np.array containing coordinate values
- propertyhas_z:bool
The
has_z
method determines if the geometry has aZ value.- Returns:
A boolean indicating yes (True), or no (False)
- svg(scale_factor:float=1,stroke_color:str|None=None)
Retrieves SVG (Scalable Vector Graphic) polyline element for the LineString geometry.
Keys
Description
scale_factor
An optional float. Multiplication factor for the SVG stroke-width. Default is 1.
stroke_color
An optional string. Hex string for fill color. Default is to use “#66cc99” if geometry isvalid, and “#ff3333” if invalid.
- Returns:
The SVG polyline element for the LineString Geometry
Polygon
- classarcgis.geometry.Polygon(iterable=None,**kwargs)
The
Polygon
contains an array ofrings orcurveRings and aSpatialReference
. ForPolygons
with curveRings, see the sections onJSON curve object andPolygon
with curve. Each ring is represented asan array ofPoint
. The first point of each ring is always the same asthe last point. Each point in the ring is represented as an array ofnumbers. APolygon
can also have boolean-valued hasM and hasZ fields.An empty
Polygon
is represented with an empty array for the ringsfield.Null and/orNaNs embedded in an otherwise defined coordinatestream forPolyline
andPolygons
is a syntax error.Polygons should be topologically simple. Exterior rings are orientedclockwise, while holes are oriented counter-clockwise. Rings can touchat a vertex or self-touch at a vertex, but there should be no otherintersections. Polygons returned by services are topologically simple.When drawing a polygon, use the even-odd fill rule. The even-odd fillrule will guarantee that the polygon will draw correctly even if thering orientation is not as described above.- coordinates()
Retrieves the coordinates of the
Polygon
as an np.array#Usage Example>>>coords=polygon.coordinates()>>>coords[[x1,y1,m1,z1],[x2,y2,m2,z2],...,[x1,y1,m1,z1]]
- Returns:
An np.array containing coordinate values
- svg(scale_factor:float=1,fill_color:str|None=None)
The
svg
method retrieves SVG (Scalable Vecotr Graphic) polygon element.SVG defines vector-based graphics in XML format.Keys
Description
scale_factor
An optional float. Multiplication factor for the SVG stroke-width. Default is 1.
fill_color
An optional string. Hex string for fill color. Default is to use “#66cc99” if geometry isvalid, and “#ff3333” if invalid.
- Returns:
The SVG polygon element
Envelope
- classarcgis.geometry.Envelope(iterable=None,**kwargs)
The
Envelope
class represents a rectangle defined by a range of values for eachcoordinate and attribute. It also has aSpatialReference
field. Thefields for thez andm ranges are optional.Note
An empty
Envelope
has no points in space and is defined by the presence of anxmin field a null valueor aNaN string.- coordinates()
The
coordinates
method retrieves the coordinates of theEnvelope
as a np.array#Usage Example>>>coords=envelope.coordinates()>>>coords[[x1,y1,m1,z1],[x2,y2,m2,z2],...]
- Returns:
An np.array containing coordinate values
- propertygeohash
The
geohash
method retrieves a geohash string of the extent of the``Envelope.- Returns:
A geohash String
- propertygeohash_covers
The
geohash_covers
method retrieves a list of up to the four longest geohash strings thatfit within the extent of theEnvelope
.- Returns:
A list of geohash Strings
- propertygeohash_neighbors
Gets a list of the geohash neighbor strings for the extent of the
Envelope
.- Returns:
A list of geohash neighbor Strings
- svg(scale_factor:float=1,fill_color:str|None=None)
Returns a SVG (Scalable Vector Graphic) envelope element for the
Envelope
geometry.Keys
Description
scale_factor
An optional float. Multiplication factor for the SVG circle diameter. Default is 1.
fill_color
An optional string. Hex string for fill color. Default is to use “#66cc99” if geometry isvalid, and “#ff3333” if invalid.
- Returns:
A SVG envelope element
SpatialReference
- classarcgis.geometry.SpatialReference(iterable=None,**kwargs)
A
SpatialReference
object can be defined using awell-known ID (wkid) orwell-known text (wkt). The default tolerance and resolution values forthe associated coordinate system are used.Note
The x, y and z tolerancevalues are 1 mm or the equivalent in the unit of the coordinate system.If the coordinate system uses feet, the tolerance is 0.00328083333 ft.The resolution values are 10x smaller or 1/10 the tolerance values.Thus, 0.0001 m or 0.0003280833333 ft. For geographic coordinate systemsusing degrees, the equivalent of a mm at the equator is used.
Thewell-known ID (WKID) for a given spatial reference can occasionallychange. For example, the WGS 1984 Web Mercator (Auxiliary Sphere)projection was originally assignedWKID 102100, but was later changedto 3857. To ensure backward compatibility with older spatial dataservers, the JSONwkid property will always be the value that wasoriginally assigned to an SR when it was created.An additional property, latestWkid, identifies the currentWKID value(as of a given software release) associated with the same spatialreference.
A
SpatialReference
object can optionally include a definition for averticalcoordinate system (VCS), which is used to interpret the z-values of ageometry. AVCS defines units of measure, the location of z = 0, andwhether the positive vertical direction is up or down. When a verticalcoordinate system is specified with aWKID, the same caveat asmentioned above applies.Note
There are twoVCS WKID properties:vcsWkid andlatestVcsWkid. A VCS WKT can also be embedded in the string value ofthe wkt property. In other words, the WKT syntax can be used to definean SR with both horizontal and vertical components in one string. Ifeither part of an SR is custom, the entire SR will be serialized withonly the wkt property.
- propertyJSON
The
JSON
method retrieves an Esri JSON representation of theGeometry
object as astring.- Returns:
A string representing a
Geometry
object
- svg(scale_factor:float=1,fill_color:str|None=None)
Retrieves SVG (Scalable Vector Graphic) polygon element for a
SpatialReference
field.================ ===============================================================================KeysDescription—————- ——————————————————————————-scale_factor An optional float. Multiplication factor for the SVG stroke-width. Default is 1.—————- ——————————————————————————-fill_color An optional string. Hex string for fill color. Default is to use “#66cc99” if geometry isvalid, and “#ff3333” if invalid.
Geometry
- classarcgis.geometry.Geometry(iterable=None,**kwargs)
The base class for all geometries.
You can create a Geometry even when you don’t know the exact type. The Geometry constructor is ableto figure out the geometry type and returns the correct type as the example below demonstrates:
#Usage Example: Unknown Geometry>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>print(geom.type)# POLYGON>>>print(isinstance(geom,Polygon)# True
- propertyEWKT
Gets the
extendedwell-knowntext
(EWKT) representation for OGC geometry.It provides a portable representation of a geometry value as a textstring.Note
Any true curves in the geometry will be densified into approximatecurves in the WKT string.
- Returns:
A String
- propertyJSON
The
JSON
method retrieves an Esri JSON representation of theGeometry
object as astring.- Returns:
A string representing a
Geometry
object
- propertyWKB
Gets the
well-knownbinary
(WKB) representation for OGC geometry.It provides a portable representation of a geometry value as acontiguous stream of bytes.- Returns:
bytes
- propertyWKT
Gets the
well-knowntext
(WKT
) representation for OGC geometry.It provides a portable representation of a geometry value as a textstring.Note
Any true curves in the geometry will be densified into approximatecurves in the WKT string.
- Returns:
A string
- angle_distance_to(second_geometry:Geometry,method:str='GEODESIC')
The
angle_distance_to
method retrieves a tuple of angle and distance to anotherPoint
using a measurement type.Note
The
angle_distance_to
method requiresArcPy. IfArcPy is not installed, none is returned.Parameter
Description
second_geometry
Required Geometry. An
Geometry
object.method
Optional String. PLANAR measurements reflect the projection of geographicdata onto the 2D surface (in other words, they will not take intoaccount the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, andLOXODROME measurement types may be chosen as an alternative, if desired.
- Returns:
A tuple of angle and distance to another
Point
using a measurement type.
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.angle_distance_to(second_geometry=geom2,>>>method="PLANAR") {54.5530, 1000.1111}
- propertyarea
The
area
method retrieves the area of aPolygon
feature. The units of the returnedarea are based off theSpatialReference
field.Note
None for all other feature types.
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.area-1.869999999973911e-06
- Returns:
A float
- propertyas_arcpy
The
as_arcpy
method retrieves the Geometry as an ArcPy Geometry.IfArcPy is not installed, none is returned.
Note
The
as_arcpy
method requires ArcPy- Returns:
An
Geometry
object
- propertyas_shapely
The
as_shapely
method retrieves a shapelyGeometry
object- Returns:
A shapely
Geometry
object.If shapely is not installed, None is returned
- buffer(distance:float)
The buffer method constructs a
Polygon
at a specified distance from theGeometry
object.Note
The
buffer
method requires ArcPyParameter
Description
distance
Required float. The buffer distance. The buffer distance is in thesame units as the geometry that is being buffered.A negative distance can only be specified against a polygon geometry.
- Returns:
A
Polygon
object
- propertycentroid
The
centroid
method retrieves the center of theGeometry
objectNote
The
centroid
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.centroid(-97.06258999999994, 32.754333333000034)
- Returns:
A tuple(x,y) indicating the center
- clip(envelope:tuple(float))
The
clip
method constructs the intersection of theGeometry
object and thespecified extent.Note
The
clip
method requiresArcPy. IfArcPy is not installed, none is returned.Parameter
Description
envelope
Required tuple. The tuple must have (XMin, YMin, XMax, YMax) each valuerepresents the lower left bound and upper right bound of the extent.
- Returns:
The
Geometry
object clipped to the extent
- contains(second_geometry:Geometry,relation:str|None=None)
Indicates if the base
Geometry
object contains the comparisonGeometry
object.Note
The
contain
method requires ArcPy/ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometryrelation
Optional string. The spatial relationship type.
BOUNDARY - Relationship has no restrictions for interiors or boundaries.
CLEMENTINI - Interiors of geometries must intersect. Specifying CLEMENTINI is equivalent to specifying None. This is the default.
PROPER - Boundaries of geometries must not intersect.
- Returns:
A boolean indicating containment (True), or no containment (False)
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.contains(second_geometry=geom2, relation="CLEMENTINI") True
- convex_hull()
Constructs the
Geometry
object that is the minimal boundingPolygon
such that all outer angles are convex.- Returns:
A
Geometry
object
- crosses(second_geometry:Geometry)
Indicates if the two
Geometry
objects intersect in ageometry of a lesser shape type.Note
The
crosses
method requires ArcPy/ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A boolean indicating yes (True), or no (False)
- cut(cutter:Polyline)
Splits this
Geometry
object into a part left of the cuttingPolyline
and a part right of it.Note
The
cut
method requires ArcPyParameter
Description
cutter
Required
Polyline
. The cutting polyline geometry- Returns:
a list of two
Geometry
objects
- densify(method:str,distance:float,deviation:float)
Creates a new
Geometry
object with added verticesNote
The
densify
method requires ArcPyParameter
Description
method
Required String. The type of densification:
DISTANCE
,ANGLE
, orGEODESIC
distance
Required float. The maximum distance between vertices. The actualdistance between vertices will usually be less than the maximumdistance as new vertices will be evenly distributed along theoriginal segment. If using a type of DISTANCE or ANGLE, thedistance is measured in the units of the geometry’s spatialreference. If using a type of GEODESIC, the distance is measuredin meters.
deviation
Required float.
Densify
uses straight lines to approximate curves.You use deviation to control the accuracy of this approximation.The deviation is the maximum distance between the new segment andthe original curve. The smaller its value, the more segments willbe required to approximate the curve.- Returns:
A new
Geometry
object
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom2=geom.densify(method="GEODESIC", distance = 1244.0, deviation = 100.0)
- difference(second_geometry:Geometry)
Constructs the
Geometry
object that is composed only of theregion unique to the base geometry but not part of the other geometry.Note
The
difference
method requires ArcPy/ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A
Geometry
object
- disjoint(second_geometry:Geometry)
Indicates if the base and comparison
Geometry
objects share noPoint
objects in common.Note
The
disjoint
method requires ArcPy/ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A boolean indicating no
Point
objects in common (True), or some in common(False)
- distance_to(second_geometry:Geometry)
Retrieves the minimum distance between two
Geometry
objects. If thegeometries intersect, the minimum distance is 0.Note
Both geometries must have the same projection.
Note
The
distance_to
method requires ArcPy/ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A float
- equals(second_geometry:Geometry)
Indicates if the base and comparison
Geometry
objects are of thesame shape type and define the same set of points in the plane. This isa 2D comparison only; M and Z values are ignored.Note
The
equals
method requires ArcPy or ShapelyParameter
Description
second_geometry
Required
Geometry
. A second geometry- Returns:
Boolean indicating True if geometries are equal else False
- propertyextent
Get the extent of the
Geometry
object as a tuplecontaining xmin, ymin, xmax, ymaxNote
The
extent
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.extent(-97.06326, 32.749, -97.06124, 32.837)
- Returns:
A tuple
- propertyfirst_point
The
first
method retrieves first coordinate point of the geometry.>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.first_point{'x': -97.06138, 'y': 32.837, 'spatialReference': {'wkid': 4326, 'latestWkid': 4326}}
- Returns:
A
Geometry
object
- classmethodfrom_shapely(shapely_geometry:Geometry,spatial_reference:dict[str,Any]|None=None)
Creates a Python API Geometry object from a Shapely geometry object.
Note
Must have shapely installed
Parameter
Description
shapely_geometry
Required Shapely GeometrySingle instance of Shapely Geometry to be converted to ArcGISPython API geometry instance.
spatial_reference
Optional SpatialReferenceDefines the spatial reference for the output geometry.
- Returns:
A
Geometry
object
# Usage Example: importing shapely geometry object and setting spatial reference to WGS84Geometry.from_shapely(shapely_geometry=shapely_geometry_object,spatial_reference={'wkid':4326})
- generalize(max_offset:float)
Creates a new simplified
Geometry
object using a specifiedmaximum offset tolerance.Note
The
generalize
method requires ArcPy or Shapely**Parameter
Description
max_offset
Required float. The maximum offset tolerance.
- Returns:
A
Geometry
object
- propertygeoextent
The
geoextent
property retrieves the current feature’s extent#Usage Example>>>g=Geometry({...})>>>g.geoextent(1,2,3,4)
- Returns:
tuple
- propertygeometry_type
- Gets the geometry type:
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.geometry_type'polygon'
- Returns:
A string indicating the geometry type
- get_area(method:str,units:str|None=None)
Retrieves the area of the
Geometry
using a measurement type.Note
The
get_area
method requires ArcPy**Parameter
Description
method
Required String.PLANAR measurements reflect the projection ofgeographic data onto the 2D surface (in other words, they will nottake into account the curvature of the earth).GEODESIC,GREAT_ELLIPTIC,LOXODROME, andPRESERVE_SHAPE measurement typesmay be chosen as an alternative, if desired.
units
Optional String. Areal unit of measure keywords:ACRES | ARES | HECTARES| SQUARECENTIMETERS | SQUAREDECIMETERS | SQUAREINCHES | SQUAREFEET| SQUAREKILOMETERS | SQUAREMETERS | SQUAREMILES |SQUAREMILLIMETERS | SQUAREYARDS
- Returns:
A float representing the area of the
Geometry
object
- get_length(method:str,units:str)
Retrieves the length of the
Geometry
using a measurement type.Note
The
get_length
method requires ArcPyParameter
Description
method
Required String.PLANAR measurements reflect the projection ofgeographic data onto the 2D surface (in other words, they will nottake into account the curvature of the earth).GEODESIC,GREAT_ELLIPTIC,LOXODROME, andPRESERVE_SHAPE measurement typesmay be chosen as an alternative, if desired.
units
Required String. Linear unit of measure keywords:CENTIMETERS |DECIMETERS | FEET | INCHES | KILOMETERS | METERS | MILES |MILLIMETERS | NAUTICALMILES | YARDS
- Returns:
A float representing the length of the
Geometry
object
- get_part(index:int|None=None)
Retrieves an array of
Point
objects for a particular part ofaGeometry
object or an array containing a number of arrays, one for each part.Note
The
get_part
method requires ArcPyParameter
Description
index
Required Integer. The index position of the
Geometry
object.- Returns:
A
Geometry
object
- propertyhas_m
The
has_m
method determines if the geometry has aM value.- Returns:
A boolean indicating yes (True), or no (False)
- propertyhas_z
The
has_z
method determines if the geometry has aZ value.- Returns:
A boolean indicating yes (True), or no (False)
- propertyhull_rectangle
The
hull_rectangle
method retrieves the space-delimited string of the coordinate pairs of the convex hullrectangle.Note
The
hull-rectangle
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.hull_rectangle'-97.06153 32.749 -97.0632940971127 32.7490060186843 -97.0629938635673 32.8370055061228 -97.0612297664546 32.8369994874385'
- Returns:
A space-delimited string
- intersect(second_geometry:Geometry,dimension:int=1)
Constructs a
Geometry
object that is the geometricintersection of the two input geometries. Different dimension values can be used to createdifferent shape types. The intersection of two geometries of thesame shape type is a geometry containing only the regions of overlapbetween the original geometries.Note
The
intersect
method requires ArcPy or ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometrydimension
Required Integer. The topological dimension (shape type) of theresulting geometry.
1 -A zero-dimensional geometry (
Point
orMultiPoint
).2 -A one-dimensional geometry (
Polyline
).4 -A two-dimensional geometry (
Polygon
).
- Returns:
A
Geometry
object indicating an intersection, or None for no intersection
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>type(geom.intersect(second_geometry=geom2,dimension=4)) arcgis.geometry._types.Polygon
- propertyis_empty
Determines if the geometry is empty.
- Returns:
A boolean indicating empty (True), or filled (False)
- propertyis_multipart
The
is_multipart
method determines if the number of parts for this geometry is more than one.Note
The
is_multipart
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.is_multipartTrue
- Returns:
A boolean indicating yes (True), or no (False)
- propertylabel_point
Gets the
Point
at which the label is located.Thelabel_point
is always located within or on a feature.Note
The
label_point
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.label_point{'x': -97.06258999999994, 'y': 32.754333333000034, 'spatialReference': {'wkid': 4326, 'latestWkid': 4326}}
- Returns:
A
Point
object
- propertylast_point
The
last_point
method retrieves the last coordinatePoint
of the feature.>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.last_point{'x': -97.06326, 'y': 32.759, 'spatialReference': {'wkid': 4326, 'latestWkid': 4326}}
- Returns:
A
Point
object
- propertylength
Gets length of the linear feature.The length units is the same as the
SpatialReference
field.Note
The
length
method returns zero forPoint
andMultiPoint
feature types.Note
The
length
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.length0.03033576008004027
- Returns:
A float
- propertylength3D
The
length3D
method retrieves the 3D length of the linear feature. Zero for point and multipointThe length units is the same as theSpatialReference
field.Note
The
length3D
method returns zero forPoint
andMultiPoint
feature types.Note
The
length3D
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.length3D0.03033576008004027
- Returns:
A float
- measure_on_line(second_geometry:Geometry,as_percentage:bool=False)
Retrieves a measure from the start
Point
of this line tothein_point
.Note
The
measure_on_line
method requires ArcPyParameter
Description
second_geometry
Required
Geometry
object. A second geometryas_percentage
Optional Boolean. If False, the measure will be returned as adistance; if True, the measure will be returned as a percentage.
- Returns:
A float
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.measure_on_line(second_geometry=geom2, as_percentage = True) 0.33
- overlaps(second_geometry:Geometry)
Indicates if the intersection of the two
Geometry
objects hasthe same shape type as one of the input geometries and isnot equivalent toeither of the input geometries.Note
The
overlaps
method requires ArcPy or ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A boolean indicating an intersection of same shape type (True), or different type (False)
- propertypart_count
The
part_count
method retrieves the number ofGeometry
parts for the feature.>>>geom=Geometry({ "rings" : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832], [-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749], [-97.06326,32.759]]], "spatialReference" : {"wkid" : 4326}})>>>geom.part_count1
- Returns:
An Integer representing the amount of
Geometry
parts
- propertypoint_count
The
point_count
method retrieves total number ofPoint
objects for the feature.>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.point_count9
- Returns:
An Integer representing the amount of
Point
objects
- point_from_angle_and_distance(angle:float,distance:float,method:str='GEODESCIC')
Retrieves a
Point
at a given angle and distance,in degrees and meters, using the specified measurement type.Note
The
point_from_angle_and_distance
method requires ArcPyParameter
Description
angle
Required Float. The angle in degrees to the returned point.
distance
Required Float. The distance in meters to the returned point.
method
Optional String.PLANAR measurements reflect the projection of geographicdata onto the 2D surface (in other words, they will not take intoaccount the curvature of the earth).GEODESIC,GREAT_ELLIPTIC,LOXODROME, andPRESERVE_SHAPE measurement types may be chosen asan alternative, if desired.
- Returns:
A
Point
object
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>point=geom.point_from_angle_and_distance(angle=60, distance = 100000, method = "PLANAR")>>>point.type "POINT"
- position_along_line(value:float,use_percentage:bool=False)
Retrieves a
Point
on a line at a specified distancefrom the beginning of the line.Note
The
position_along_line
method requires ArcPy or ShapelyParameter
Description
value
Required Float. The distance along the line.
use_percentage
Optional Boolean. The distance may be specified as a fixed unitof measure or a ratio of the length of the line. If True, valueis used as a percentage; if False, value is used as a distance.
Note
For percentages, the value should be expressed as a double from0.0 (0%) to 1.0 (100%).
- Returns:
A
Geometry
object
- project_as(spatial_reference:dict[str,Any]|SpatialReference,transformation_name:str=None)
Projects a
Geometry
object and optionally applies ageotransformation
.Note
The
project_as
method requires ArcPy or pyproj>=1.9 and PROJ.4Parameter
Description
spatial_reference
Required SpatialReference. The new spatial reference. This can be a
SpatialReference
object or the coordinate system name.transformation_name
Required String. The
geotransformation
name.- Returns:
A
Geometry
object
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom2=geom.project_as(spatial_reference="GCS", transformation_name = "transformation")>>>geom2.type arcgis.geometry.Geometry
- query_point_and_distance(second_geometry:Geometry,use_percentage:bool=False)
Finds the
Point
on thePolyline
nearest to thein_point and thedistance between those points.query_point_and_distance
retrieves information about theside of the line thein_point is on as well as the distance alongthe line where the nearest point occurs.Note
The
query_point_and_distance
method requires ArcPyNote
The
query_point_and_distance
method only is valid for Polyline geometries.Parameter
Description
second_geometry
Required
Point
object. A second geometryas_percentage
Optional boolean - if False, the measure will be returned asdistance, True, measure will be a percentage
- Returns:
A tuple of the point and the distance
- rotate(theta:float,inplace:bool=False)
Rotates a
Geometry
object counter-clockwise by a given angle.Parameter
Description
theta
Required Float. The rotation angle.
inplace
Optional Boolean. If True, the value is updated in the object, Falsecreates a new object
- Returns:
A
Geometry
object
- scale(x_scale:float=1,y_scale:float=1,inplace:bool=False)
Scales a
Geometry
object in either the x,y or both directions.Parameter
Description
x_scale
Optional Float. The x-scale factor.
y_scale
Optional Float. The y-scale factor.
inplace
Optional Boolean. If True, the value is updated in the object, Falsecreates a new object
- Returns:
A
Geometry
object
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom2=geom.sacle(x_scale=3, y_scale = 0.5, inplace = False)
- segment_along_line(start_measure:float,end_measure:float,use_percentage:bool=False)
Retrieves a
Polyline
betweenstart
andend
measures.segment_along_line
is similar to thepositionAlongLine
methodbut will return a polyline segment between two points on the polyline instead of a singlePoint
.Note
The
segment_along_line
method requires ArcPyParameter
Description
start_measure
Required Float. The starting distance from the beginning of the line.
end_measure
Required Float. The ending distance from the beginning of the line.
use_percentage
Optional Boolean. The start and end measures may be specified asfixed units or as a ratio.If True, start_measure and end_measure are used as a percentage; ifFalse, start_measure and end_measure are used as a distance.
Note
Forpercentages, the measures should be expressed as a double from 0.0(0 percent) to 1.0 (100 percent).
- Returns:
A float
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.segment_along_line(start_measure=0, end_measure= 1000, use_percentage = True) 0.56
- skew(x_angle:float=0,y_angle:float=0,inplace:bool=False)
Creates a skew transform along one or both axes.
Parameter
Description
x_angle
optional Float. Angle to skew in the x coordinate
y_angle
Optional Float. Angle to skew in the y coordinate
inplace
Optional Boolean. If True, the value is updated in the object, Falsecreates a new object
- Returns:
A
Geometry
object
- snap_to_line(second_geometry:Geometry)
The
snap_to_line
method retrieves a newPoint
based onin_point snapped to thisGeometry
object.Note
The
snap_to_line
method requires ArcPyParameter
Description
second_geometry
Required
Geometry
- A second geometry- Returns:
A
Point
object
- propertyspatial_reference
Gets the
SpatialReference
of the geometry.>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.spatial_reference<SpatialReference Class>
- Returns:
A
SpatialReference
object
- symmetric_difference(second_geometry:Geometry)
The
symmetric_difference
method constructs a newGeometry
object that is the unionof two geometries minus the intersection of those geometries.Note
The two input geometries must be the same shape type.
Note
The
symmetric_difference
method requires ArcPy or ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A
Geometry
object
- touches(second_geometry:Geometry)
Indicates if the boundaries of the two
Geometry
objectsintersect.Note
The
touches
method requires ArcPy or ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A boolean indicating whether the
Geometry
objects touch (True), or if they do nottouch (False)
- translate(x_offset:float=0,y_offset:float=0,inplace:bool=False)
Moves a
Geometry
object in the x and y direction by a givendistance.Parameter
Description
x_offset
Optional Float. Translation x offset
y_offset
Optional Float. Translation y offset
inplace
Optional Boolean. If True, updates the existing Geometry,else itcreates a new Geometry object
- Returns:
A
Geometry
object
>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.translate(x_offset=40, y_offset = 50, inplace = True)
- propertytrue_centroid
Gets the
Point
representing the center of gravityfor a feature.Note
The
true_centroid
method requires ArcPy or Shapely>>>geom=Geometry({>>>"rings":[[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],>>>[-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],>>>[-97.06326,32.759]]],>>>"spatialReference":{"wkid":4326}>>>})>>>geom.true_centroid{'x': -97.06272135472369, 'y': 32.746201426025, 'spatialReference': {'wkid': 4326, 'latestWkid': 4326}}
- Returns:
A
Point
object
- union(second_geometry:Geometry)
Constructs the
Geometry
object that is the set-theoretic unionof the input geometries.Note
The
union
method requires ArcPy or ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometry- Returns:
A
Geometry
object
- within(second_geometry:Geometry,relation:str|None=None)
Indicates if the base
Geometry
object is within the comparisonGeometry
object.Note
The
within
method requires ArcPy or ShapelyParameter
Description
second_geometry
Required
Geometry
object. A second geometryrelation
Optional String. The spatial relationship type.
BOUNDARY - Relationship has no restrictions for interiors or boundaries.
CLEMENTINI - Interiors of geometries must intersect. Specifying CLEMENTINI is equivalent to specifying None. This is the default.
PROPER - Boundaries of geometries must not intersect.
- Returns:
A boolean indicating the
Geometry
object is within (True), or not within (False)
areas_and_lengths
- arcgis.geometry.areas_and_lengths(polygons:Polygon,length_unit:str|LengthUnits,area_unit:str|AreaUnits,calculation_type:str,spatial_ref:int=4326,gis:gis.GIS|None=None,future:bool=False)
Theareas_and_lengths function calculates areas and perimeter lengthsfor each
Polygon
specified in the input array.Keys
Description
polygons
The list of
Polygon
objects whose areas and lengthsare to be computed.length_unit
The length unit in which the perimeters of polygons will be calculated.
Ifcalculation_type isplanar, then this argument can be anyesriUnitsconstant string or integer.
IfcalculationType isnot planar, thenlength_unit must be a linear
LengthUnits
constant or string. For example:Formeters, use9001 orLengthUnits.METER
Forsurvey miles, use9035 orLengthUnits.SURVEYMILE
Iflength_unit is not specified, the units are derived fromspatial_ref.Ifspatial_ref is not specified as well, the units are inmeters.
area_unit
The area unit in which areas of polygons will be calculated.
Ifcalculation_type isplanar, then area_unit can be anyesriAreaUnits constant.
Ifcalculation_type is not planar, thenarea_unit must be an
AreaUnits
dictionary.For example,forsquare meters use -{“areaUnit”: “esriSquareMeters”}
forsquare miles use -{“areaUnit”: “esriSquareMiles”}
Ifarea_unit is not specified, the units are derived from thespatial_ref.Ifspatial_ref is not specified, then the units are in square meters.
calculation_type
The type defined for the area and length calculation of the input geometries. The type can be oneof the following values:
planar - Planar measurements use 2D Euclidean distance to calculate area and length. Thisshould only be used if the area or length needs to be calculated in the given
SpatialReference
. Otherwise, usepreserveShape.geodesic - Use this type if you want to calculate an area or length using only the verticesof the
Polygon
and define the lines between the points as geodesicsegments independent of the actual shape of thePolygon
. A geodesicsegment is the shortest path between two points on an ellipsoid.preserveShape - This type calculates the area or length of the geometry on the surface ofthe Earth ellipsoid. The shape of the geometry in its coordinate system is preserved.
spatial_ref
Optional integer. The desired spatial reference of the output. Integer valueis thewkid value of the spatial reference. Default4326.
Note
SeeUsing Spatial Referencesfor links to comprehensive list of values.
gis
Optional
GIS
object. If no argument provided, the activeGIS will be used.future
Optional boolean.
IfTrue, a
GeometryJob
that can be queriedwill be returned and control returns to the user.IfFalse, a dictionary object with results after the function completes.
- Returns:
A dictionary with result output iffuture=False, or a
GeometryJob
objectiffuture = True.
>>>fl_item=gis.content.get("<item_id>")#Feature Layer item with polygon later>>>poly_lyr=fl_item.layers[0]>>>polygon1=poly_lyr.query(where="objectid=14, as_df=True).SHAPE.loc[0]>>>polygon2=poly_lyr.query(where="objectid=38, as_df=True).SHAPE.loc[0]# Usage Example 1>>>output_1=areas_and_lengths(polygons=[polygon1,polygon2],length_unit=9001,area_unit={"areaUnit":"esriSquareMeters"},spatial_ref=3857,calculation_type="preserveShape")>>>output_1{'areas':[7845609.082046935,52794153.65053841],'lengths':[29042.783436295722,98763.80242520552]}# Usage Example 2>>>fromarcgis.geometryimportLengthUnits,AreaUnits>>>output_2=areas_and_lengths(polygons=[polygon1,polygon2,...],length_unit=LengthUnits.FOOT,area_unit=AreaUnits.SQUAREFEET,spatial_ref={"wkid":3857}calculation_type="planar",future=True)>>>trials=0>>>whiletrials<10:>>>ifnotft_output.done():>>>print("...processing...")>>>time.sleep(3)>>>trials+=1>>>else:>>>print(ft_output.result())>>>break...processing......processing...{'areas':[84449433.3236774,568271540.420404],'lengths':[95284.72256002533,324028.2231798081]}
auto_complete
- arcgis.geometry.auto_complete(polygons:list[Polygon]|None=None,polylines:list[Polyline]|None=None,spatial_ref:SpatialReference|None=None,gis:GIS|None=None,future:bool=False)
The
auto_complete
function simplifies the process of constructing newPolygon
objects that are adjacent to otherpolygons. It constructspolygons that fill in the gaps between existingpolygons and a set ofPolyline
objects.Keys
Description
polygons
A List of
Polygon
objectspolylines
A List of
Polyline
objectsspatial_ref
A
SpatialReference
of the input geometries or theinteger WKID of the spatial reference.future
Optional boolean.
IfTrue, a
GeometryJob
that canbe queried will be returned and control returns to the user.IfFalse, a
Polygon
object will be returnedafter the function completes.
- Returns:
Iffuture=False, a
Polygon
object. Iffuture=True, aGeometryJob
object. See code example inareas_and_lengths
for code snippet querying the job.
buffer
- arcgis.geometry.buffer(geometries:list,in_sr:int|dict[str,Any],distances:float|list[float],unit:str|LengthUnits,out_sr:int|dict[str,Any]|None=None,buffer_sr:float|None=None,union_results:bool|None=None,geodesic:bool|None=None,gis:GIS|None=None,future:bool=False)
The
buffer
function createspolygons
around each inputGeometry
in the list at thespecified distance.Note
The options are available to union buffers and to use geodesic distance.
Keys
Description
geometries
The list of
geometries
to buffer.in_sr
The well-known ID, or a
SpatialReference
object forthe input geometries.distances
The distances that each input
Geometry
will bebuffered.unit
The unit of the bufferdistances.* If not specified, the units are derived frombuffer_sr.* Ifbuffer_sr is also not specified, the units are derived fromin_sr.
out_sr
The well-known ID or the
SpatialReference
object forthe returnedgeometries
.buffer_sr
The well-known ID or the
SpatialReference
objectin which thegeometries
are buffered.union_results
Optional boolean.* IfTrue, allgeometries buffered at a given distance are unioned into asingle (possibly multipart)
Polygon
and the unionedGeometry
is placed in the output list. The defaultisFalse.geodesic
Optional boolean.
IfTrue, buffer the inputgeometries using geodesic distance. Geodesic
distance is the shortest path between two points along the ellipsoid of the earth.IfFalse, the 2D Euclidean distance is used
Note
The default value depends on the geometry type,unit andbuffer_srarguments. Seebuffering using GCSandbuffering using PCSfor details.
future
Optional boolean.
IfTrue, a
GeometryJob
will be returned for queryand the process returns control to the user.IfFalse, the process waits until completion before returning the output
polygons
The default is False.
Note
If setting future toTrue there is a limitation of 6500geometriesthat can be processed in one call.
- Returns:
A list of
Polygon
objects iffuture=False, or aGeometryJob
object iffuture=True.Query the job’sresult()
method to get results.
>>>fromarcgis.gisimportGIS>>>fromarcgis.geometryimportPoint,buffer,LengthUnits,AreaUnits>>>gis=GIS(profile="my_entertprise_user")>>>flyr_item=gis.content.get("<item_id>")>>>pts_layer=fl_item.layers[0]>>>geom1=Point(pts_layer.query(where="name='Water Dept'").features[0].geometry)>>>geom2=Point(pts_layer.query(where="name='Water Satellite'").features[0].geometry)>>>buffer_res=buffer(geometries=[geom1,geom2], distances=[1000,2000,...], in_sr = {"wkid": 3857}, unit = LengthUnits.FOOT, out_sr = 102009, buffer_sr = 102009, union_results = False, geodesic = True, future = False)>>>buffer_res[{'rings': [[[-1231272.7177999988, -367594.3729999997], [-1231259.824000001, -367596.90949999914],… [-1231285.7353999987, -367592.5767999999], [-1231272.7177999988, -367594.3729999997]]], 'spatialReference': {'wkid': 102009, 'latestWkid': 102009}}, {'rings': [[[-1414089.7775999978, -547764.3929000013], [-1414076.887000002, -547767.1926000006],… [-1414102.8069999963, -547762.3337000012], [-1414089.7775999978, -547764.3929000013]]], 'spatialReference': {'wkid': 102009, 'latestWkid': 102009}}]
convex_hull
- arcgis.geometry.convex_hull(geometries:list[Polygon]|list[Polyline]|list[MultiPoint]|list[Point],spatial_ref:int|dict[str,Any]|None=None,gis:GIS|None=None,future:bool=False)
Theconvex_hull function is performed on aGeometry Serviceresource.It returns the minimum bounding shape that contains the input geometry. Theinput geometry can be a
Point
,MultiPoint
,Polyline
, orPolygon
object.Note
The convex hull is typically a polygon but can also be a polylineor point in degenerate cases.
Keys
Description
geometries
A list of
Point
,MultiPoint
,Polyline
, orPolygon
objects.The structure of each geometry in the array is defined the same as theJSON geometry objectsreturned by the ArcGIS REST API.Note
Geometry
objects can be obtained by querying aFeatureLayer
, returning it as a Pandasdata frame, and then assigning variables to a geometry based on the row index.>>>flyr_item=gis.content.search("*","Feature Layer")[0]>>>flyr_df=flyr_item.query(where="1=1",as_df=True)>>>geom0=flyr_df.loc[0].SHAPE
spatial_ref
An integer value, or a
SpatialReference
objectdefined using the the Well-Known ID (wkid) of the Spatial Reference.Note
SeeSpatial Referencein theGeometry objects help, orUsing Spatial Referencesfor details on concepts and resources for finding specificwkid values.
>>>geom_result=convex_hull(geometries=[geometry_object] spatial_ref=<wkid>)
or
>>>geom_result=convex_hull(geometries=[geometry_object], spatial_ref={"wkid": <wkid>})
or
>>>fromarcgis.geometryimportSpatialReference>>>sr_obj_wkid=SpatialReference(<wkid>)>>>geom_result=convex_hull(geometries=[geometry_object], spatial_ref=sr_obj_wkid)
future
Optional boolean.
IfTrue, a
GeometryJob
will be returned for queryand the process returns control to the user.IfFalse, the process waits until completion before returning the output
polygons
The default is False.
Note
If setting future toTrue there is a limitation of 6500geometriesthat can be processed in one call.
- Returns:
A list containing the
Geometry
object of the result, or iffuture=True
,aGeometryJob
object. Call the job’sresult()
method to inspect the process and results.
# Usage Example:>>>importtime>>>fromarcgis.gisimportGIS>>>fromarcgis.geometryimportconvex_hull>>>gis=GIS(profile="your_organization_profile")>>>flyr_item=gis.content.get("<item_id for feature layer>")>>>flyr=flyr_item.layers[0]>>>df=flyr.query(where="OBJECTID=1",as_df=True)>>>geom1=df.loc[0].SHAPE>>>hull_job=convex_hull(geometries=[geom1],spatial_ref={"wkid":2056},future=True)>>>trials=0>>>whiletrials<5:>>>ifnothull_job.done():>>>print("...processing...")>>>time.sleep(3)>>>trials+=1>>>else:>>>print(hull_job.result())>>>break...processing...{'rings':[[[2664507.7925999984,1212609.7138999999],...,[2664678.264199998,1212618.6860999987],[2664507.7925999984,1212609.7138999999]]],'spatialReference':{'wkid':{'wkid':2056}}}
cut
- arcgis.geometry.cut(cutter:Polyline,target:list[Polyline]|list[Polygon],spatial_ref:int|dict[str,Any]|None=None,gis:GIS|None=None,future:bool=False)
The geometry service
cut
function splits a targetPolyline
orPolygon
geometry where it is crossed by the cutterPolyline
geometry.Note
At 10.1 and later, this function calls simplify on the inputcutter and target geometries.
Keys
Description
cutter
The
Polyline
that will be used to divide the targetgeometry into pieces where it crosses the target.target
spatial_ref
A
SpatialReference
object or well-known ID specifyingthe spatial reference of the input geometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
A List of
Geometry
objects iffuture=False, or aGeometryJob
iffuture=True.
densify
- arcgis.geometry.densify(geometries:list[Polygon]|list[Polyline]|list[MultiPoint]|list[Point],spatial_ref:int|dict[str,Any]|None,max_segment_length:float|None,length_unit:str|None|LengthUnits,geodesic:bool=False,gis:GIS|None=None,future:bool=False)
The
densify
function adds vertices toGeometry
objectsat regular intervals.Keys
Description
geometries
spatial_ref
The well-known ID or a
SpatialReference
object forthe inputgeometries
.max_segment_len
All segments longer thanmaxSegmentLength arereplaced with sequences of lines no longer thanmax_segment_length.
length_unit
The length unit ofmax_segment_length.
Ifgeodesic = False, then the units are derived from thespatial_refargument and thelength_unit argument is ignored
Ifgeodesic = True, thenlength_unit must be a linear unit
If argument is not provided and thespatial_ref argument is a projectedcoordinate system, this value is derived from thespatial_ref
If argument is not provided and thespatial_ref argument is a geographiccoordinate system, the units aremeters
geodesic
Optional boolean.
IfTrue, thengeodesic distanceis used to calculatemax_segment_length.
IfFalse, then2D Euclidean distance is used to calculatemax_segment_length. The default isFalse.
future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of
Geometry
objects. Iffuture = True,aGeometryJob
object.
difference
- arcgis.geometry.difference(geometries:list[Polygon]|list[Polyline]|list[MultiPoint]|list[Point],spatial_ref:int|dict[str,Any]|None,geometry:Geometry,gis:GIS|None=None,future:bool=False)
Thedifference function constructs the set-theoretic differencebetween each member of a list of
geometries
and anotherGeometry
object. In other words, let B be thedifference geometry. For each geometry, A, in the input geometrylist, it constructs A - B.Note
The operation calls
simplify()
on the inputgeometriesKeys
Description
geometries
An array of
Point
,MultiPoint
,Polyline
, orPolygon
objects.geometry
A single
Geometry
object of any type and of adimension equal to or greater than the elements of thegeometries argument.spatial_ref
A
SpatialReference
object or the well-known IDspecifying the spatial reference of the inputgeometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of
Geometry
objects. Iffuture = True,aGeometryJob
object.
distance
- arcgis.geometry.distance(spatial_ref:int|dict[str,Any]|None,geometry1:Geometry,geometry2:Geometry,distance_unit:str|LengthUnits|None='',geodesic:bool=False,gis:GIS|None=None,future:bool=False)
The
distance
function is performed on a geometry service resource.It reports the2D Euclidean orgeodesic distance between the twoGeometry
objects.Keys
Description
geometry1
The
Geometry
object from which the distance ismeasured. The structure of each geometry in the array is thesame as the structure of the JSON geometry objects returned bythe ArcGIS REST API.geometry2
The
Geometry
object to which the distance ismeasured. The structure of each geometry in the array is thesame as the structure of the JSON geometry objects returned bythe ArcGIS REST API.distance_unit
Optional. One of
LengthUnits
enumerationmembers. See Geometry Servicedistancefor full details.geodesic
If
geodesic
is set to true, then the geodesic distancebetween thegeometry1
andgeometry2
geometries is returned.Geodesic distance is the shortest path between two points alongthe ellipsoid of the earth. Ifgeodesic
is set to false or notspecified, the planar distance is returned. The default value is false.spatial_ref
A
SpatialReference
of the input geometries Well-KnownID or JSON objectfuture
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
- Returns:
Iffuture = False, the distance value between the
Geometry
objects.Iffuture = True, aGeometryJob
object.
find_transformation
- arcgis.geometry.find_transformation(in_sr:int|dict[str,Any]|None,out_sr:int|dict[str,Any]|None,extent_of_interest:dict[str,Any]|None=None,num_of_results:int=1,gis:GIS|None=None,future:bool=False)
The
find_transformations
function is performed on aGeometry
service resource. This function returns a list of applicablegeographic transformations you should use when projectinggeometries from the inputSpatialReference
to the outputSpatialReference
. The transformations are in JSON format and are returnedin order of most applicable to least applicable. Recall that ageographic transformation is not needed when the input and outputspatial references have the same underlying geographic coordinatesystems. In this case, findTransformations returns an empty list.Note
Every returned geographic transformation is a forwardtransformation meaning that it can be used as-is to project fromthe input spatial reference to the output spatial reference. In thecase where a predefined transformation needs to be applied in thereverse direction, it is returned as a forward compositetransformation containing one transformation and a transformForwardelement with a value of false.
Keys
Description
in_sr
The well-known ID of the
SpatialReference
or a spatialreference JSON object for the input geometries.out_sr
The well-known ID of the
SpatialReference
or aspatial reference JSON object for the output geometries.ext_of_interest
The bounding box of the area of interest specified as a JSON envelope.If provided, the extent ofinterest is used to return the most applicable geographictransformations for the area.
Note
If a
SpatialReference
is notincluded in the JSON envelope, thein_sr
is used for theenvelope.num_of_results
The number of geographic transformations toreturn. The default value is 1.
Note
If
num_of_results
has a value of -1, all applicable transformations are returned.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of geographic transformations, or iffuture = True, a
GeometryJob
object.
from_geo_coordinate_string
- arcgis.geometry.from_geo_coordinate_string(spatial_ref:int|dict[str,Any]|None,strings:list[str],conversion_type:str|None,conversion_mode:str|None=None,gis:GIS|None=None,future:bool=False)
The
from_geo_coordinate_string
function is performed on aGeometry
service resource. The function converts an array of well-knownstrings into xy-coordinates based on the conversion type andSpatialReference
supplied by the user. An optional conversion modeparameter is available for some conversion types. Seeto_geo_coordinate_strings
for more information on the opposite conversion.Keys
Description
spatial_ref
A
SpatialReference
of the input geometries Well-Known ID or JSON objectstrings
An array of strings formatted as specified by conversion_type.Syntax: [<string1>,…,<stringN>]
conversion-type
The conversion type of the input strings.
Note
Valid conversion types are:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversion_mode
Conversion options for MGRS, UTM and GARS conversion types.
Note
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial reference.
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The 80 degree longitude falls into Zone 60.
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841. The 180 degree longitude falls into Zone 60.
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180 degree longitude falls into Zone 01
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180 degree longitude falls into Zone 01
Note
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers - Non-standard. Default is recommended
future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
- Returns:
Iffuture = False, a is of (x,y) coordinates and iffuture = True, a
GeometryJob
object.
>>>coords=from_geo_coordinate_string(spatial_ref="wkid", strings = ["01N AA 66021 00000","11S NT 00000 62155", "31U BT 94071 65288"], conversion_type = "MGRS", conversion_mode = "mgrs_default", future = False)>>>coords[[-117.378, 34.233], [14.387, 58.092], [179.0432, 98.653]]
generalize
- arcgis.geometry.generalize(spatial_ref:int|dict[str,Any]|None,geometries:list[Geometry],max_deviation:int,deviation_unit:str|LengthUnits|None=None,gis:GIS|None=None,future:bool=False)
The
generalize
simplifies the input geometries using the _Douglas-Peucker_algorithm with a specified maximum deviation distance.Note
The output geometries will contain a subset ofthe original input vertices.
Keys
Description
geometries
Required. The list of
Polyline
orPolygon
objects to be generalized.max_deviation
Sets the maximum allowable offset, which determines the degree of simplification.This value limits the distance the output geometry can differ from the inputgeometry.
deviation_unit
Specifies a unit for themax_deviation argument.
Note
If not specified, the units are derived fromspatial_ref
spatial_ref
A
SpatialReference
object or the Well-Known IDof the inputgeometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of the generalized
Geometry
objects, oriffuture = True, aGeometryJob
object.
intersect
- arcgis.geometry.intersect(spatial_ref:int|dict[str,Any]|None,geometries:list[Geometry],geometry:Geometry,gis:GIS|None=None,future:bool=False)
The
intersect
function constructs the set-theoretic intersectionbetween a list ofgeometries <arcgis.geometry.Geometry> and anotherGeometry
.Note
The dimension of each resultant geometry is the minimum dimension of the inputgeometries list and the object serving as thegeometry argument.
Keys
Description
geometries
An list of
Point
,MultiPoint
,Polyline
, orPolygon
objects.geometry
A single
Geometry
of any type and of a dimension equalto or greater than the elements ofgeometries.spatial_ref
A
SpatialReference
object or the Well-Known ID of theinputgeometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, the set-theoretic dimension between
Geometry
objects, oriffuture = True, aGeometryJob
object.
label_points
- arcgis.geometry.label_points(spatial_ref:int|dict[str,Any]|None,polygons:list[Polygon],gis:GIS|None=None,future:bool=False)
The
label_points
function calculates an interiorPoint
for eachPolygon
specified in the input list. These interiorpoints can be used by clients for labeling the polygons.Keys
Description
polygons
Required list of
Polygon
objects whose labelPoint
objects are to be computed.spatial_ref
A
SpatialReference
object or the well-known ID ofthe spatial reference of the inputpolygons.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of
Point
objects, or iffuture = True,aGeometryJob
object.
lengths
- arcgis.geometry.lengths(spatial_ref:int|dict[str,Any]|None,polylines:Polyline,length_unit:str|LengthUnits,calculation_type:str,gis:GIS|None=None,future:bool=False)
The
lengths
function calculates the` 2D Euclidean` orgeodesic lengths ofeachPolyline
specified in the input array.Keys
Description
spatial_ref
A
SpatialReference
object or the well-known ID ofthe spatial reference of the inputpolygons.polylines
The list of
Polyline
objects to compute.length_unit
The length unit in which the lengths are calculated.
Ifcalculation_type isplanar - value can be anyesriUnits constant
Ifcalculation_type isplanar and argument not provided, the unitsare derived from
spatial_ref
.
IfcalculationType isnot planar, then must be a
LengthUnits
value, such asLengthUnits.METER orLengthUnits.SURVEYMILEIfcalculationType isnot planar and argument not provided, the value ismeters
calculation_type
The length calculation type used for the operation. Can be one of the following:
- planar - uses 2D Euclidean distance to calculate length. Only use this
if the length needs to be calculated in the givenspatial_ref,otherwise usepreserveShape
- geodesic - uses only the vertices of thepolygon and defines the
lines between the vertices as geodesic independent of the actual shape ofthe
Polyline
. This segment is the shortest pathbetween two points on an ellipsoid.
- preserveShape - uses the surface of the earth ellipsoid to calculate
the length. The shape of the geometry in its coordinate system is preserved.
future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of 2D-Euclidean or geodesic lengths infloat format, or iffuture = True, a
GeometryJob
object.
offset
- arcgis.geometry.offset(geometries:list[Polygon]|list[Polyline]|list[MultiPoint]|list[Point],offset_distance:float,offset_unit:str|LengthUnits,offset_how:str='esriGeometryOffsetRounded',bevel_ratio:int=10,simplify_result:bool=False,spatial_ref:int|dict[str,Any]|None=None,gis:GIS|None=None,future:bool=False)
The
offset
function constructsgeometries
that are offset from the inputgeometries. If the offset parameter is positive, theconstructed offset will be on the right side of the geometry; if negative on the left.Note
Tracing the geometry from its first vertex to the last will give you adirection along the geometry. It is to the right and leftperspective of this direction that the positive and negativeparameters will dictate where the offset is constructed. In theseterms, you may infer where the offset of even horizontal geometries willbe constructed.
Keys
Description
geometries
Required list of
Point
,MultiPoint
,Polyline
, orPolygon
objects.offset_distance
Specifies the distance for constructing an offset geometry.
Note
If the
offset_distance
parameter is positive, the constructed offsetwill be on the right side of the input; if negative on the left.offset_unit
A unit for offset distance. Use
arcgis.geometry.functions.LengthUnits
options.offset_how
Determines how outer corners between segments are handled.The three options are as follows:
esriGeometryOffsetRounded - Rounds the corner between extended offsets
esriGeometryOffsetBevelled - Squares off the corner after a given ratio distance
esriGeometryOffsetMitered - Attempts to allow extended offsets to naturallyintersect, but if that intersection occurs too far from the corner, the corneris eventually bevelled off at a fixed distance.
bevel_ratio
Value is multiplied by theoffset_distance, and determines how far a miteredoffset intersection can be located before it is bevelled.
whenoffset_how = esriGeometryOffsetMitered, argument is ignored and 10 isused internally.
whenoffset_how = esriGeometryOffsetBevelled, 1.1 will be used if argumentnot specified
whenoffset_how = esriGeometryOffsetRounded, argument is ignored
simplify_result
Option boolean. IfTrue, true, then self intersecting loops will be removed.The default is False.
spatial_ref
A
SpatialReference
object of the well-known ID of thespatial reference of the of the input geometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of
Geometry
objects, or iffuture = True, aGeometryJob
object.
# Usage Example:>>>fromarcgis.geometryimportPolyline,LengthUnits>>>pline=Polyline(iterable={"paths":[[[0,0],[2000,2000],[3000,0]]],:spatialReference:{"wkid":2229}})>>>new_geoms=offset(geometries=[pline],offset_distance=1000,offset_unit=LengthUnits.METER,offset_how="esriGeometryOffsetMitered",spatial_ref={"wkid":2229})
project
- arcgis.geometry.project(geometries:list[Polygon]|list[Polyline]|list[MultiPoint]|list[Point],in_sr:int|dict[str,Any]|None,out_sr:int|dict[str,Any]|None,transformation:str='',transform_forward:bool=False,gis:GIS|None=None,future:bool=False)
The
project
function projects a list of input geometries from the inputSpatialReference
to the outputSpatialReference
Keys
Description
geometries
An list of
Point
,MultiPoint
,Polyline
, orPolygon
objects.in_sr
The well-known ID of the spatial reference or a
SpatialReference
object specifying the spatialreference of the inputgeometries.out_sr
The well-known ID of the spatial reference or a
SpatialReference
object specifying the spatialreference of the outputgeometries.transformation
The well-known ID or a dictionary specifying thegeographic transformation(also known asdatum transformation) to be applied to the projectedgeometries.
Note
A transformation is needed only if the output
SpatialReference
contains a different coordinatesystem from the input spatial reference. For comprehensive list oftransformations, seeTransformation PDFs.transform_forward
Optional boolean. Indicates whether or not to transform forward.
Note
The forward or reverse direction is implied in the name of the transformation.If transformation is specified, a value for this argument must be provided.The default value isFalse.
future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, a list of
Geometry
objects in theout_srcoordinate system,, or iffuture = True, aGeometryJob
object.
#Usage Example>>>result=project(geometries=[{"x":-17568824.55,"y":2428377.35},{"x":-17568456.88,"y":2428431.352}],in_sr=3857,out_sr=4326)[{"x":-157.82343617279275,"y":21.305781607280093},{"x":-157.8201333369876,"y":21.306233559873714}]
relation
- arcgis.geometry.relation(geometries1:list[Geometry],geometries2:list[Geometry],spatial_ref:int|dict[str,Any]|None,spatial_relation:str='esriGeometryRelationIntersection',relation_param:str='',gis:GIS|None=None,future:bool=False)
The
relation
function determines the pairs of geometries from the inputlist that participate in the specified spatialrelation.Note
Both lists are assumed to be in the spatial reference specified bythespatial_ref, which is a required argument. Geometry types cannot be mixedwithin a list.
Note
The relations are evaluated in 2D.z coordinates are not used.
Keys
Description
geometries1
The first list of
Geometry
objects used to computethe relations.geometries2
The second list of
Geometry
objects used.spatial_ref
A
SpatialReference
object or the well-known ID of thespatial reference of thegeometries.relation_param
Only relevant whenspatial_relation = esriGeometryRelationRelation. The ShapeComparison Language string to be evaluated. Seeherefor more details.
spatial_relation
The spatial relationship to be tested between the two input geometry lists.Options:
esriGeometryRelationCross
esriGeometryRelationDisjoint
esriGeometryRelationIn
`esriGeometryRelationInteriorIntersection `
esriGeometryRelationIntersection
esriGeometryRelationLineCoincidence
esriGeometryRelationLineTouch
esriGeometryRelationOverlap
esriGeometryRelationPointTouch
esriGeometryRelationTouch
esriGeometryRelationWithin
esriGeometryRelationRelation
future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
- Returns:
Iffuture = False, a dictionary of geometry index positions of geometries that participatein the specifiedrelation, or iffuture = True, a
GeometryJob
object.
>>>new_res=relation(geometry1=[{"x":-104.53,"y":34.74},{"x":-63.53,"y":10.23}], geometry2 = [{"rings":[[[-105,34],[-104,34],[-104,35],[-105,35],[-105,34]]]}], spatial_relation = "esriGeometryRelationWithin", spatial_ref = 4326, future = False)>>>new_res{'relations': [{"geometry1Index": 0, "geometry2Index": 3}, {"geometry1Index": 1, "geometry2Index": 0}]}
reshape
- arcgis.geometry.reshape(spatial_ref:int|dict[str,Any]|None,target:Polyline|Polygon,reshaper:Polyline,gis:GIS|None=None,future:bool=False)
The
reshape
function modifies aPolyline
orPolygon
feature by constructing apolyline over the feature.The feature takes the shape of thisreshaper polyline from the first place itintersects the feature to the last.Keys
Description
target
reshaper
The single-part
Polyline
object that reshapestarget.spatial_ref
A
SpatialReference
object or the well-known ID of thespatial reference of the geometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
- Returns:
f *future = False, A reshaped
Polyline
orPolygon
object iffuture = True, aGeometryJob
object.
to_geo_coordinate_string
- arcgis.geometry.to_geo_coordinate_string(spatial_ref:int|dict[str,~typing.Any]|None,coordinates:<module'json'from'/opt/conda/envs/arcgis/lib/python3.11/json/__init__.py'>,conversion_type:str,conversion_mode:str='mgrsDefault',num_of_digits:int|None=None,rounding:bool=True,add_spaces:bool=True,gis:~arcgis.gis.GIS|None=None,future:bool=False)
The
to_geo_coordinate_string
function is performed on aGeometry
service resource. The function converts an array ofxy-coordinates into well-known strings based on the conversion typeandSpatialReference
supplied by theUser
. Optional parameters areavailable for some conversion types. Seefrom_geo_coordinate_strings
for moreinformation on the opposite conversion.Note
If an optional parameter is not applicable for a particular conversion type, but avalue is supplied for that parameter, the value will be ignored.
Keys
Description
spatial_ref
A
SpatialReference
object or the well-known ID of thespatial reference of the inputcoordinates.coordinates
An list of xy-coordinates in JSON format to be converted.Syntax:
[[10,10],[10,20]…[30,40]]
conversion-type
The conversion type of the input strings.
Note
Valid conversion types are:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversion_mode
Conversion options for MGRS and UTM conversion types.
Note
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial reference
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The 80 degree longitude falls into Zone 60
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841. The 180 degree longitude falls into Zone 60
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180 degree longitude falls into Zone 01
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180 degree longitude falls into Zone 01
Note
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers - Non-standard. Default is recommended
num_of_digits
The number of digits to output for each of the numerical portions in the string. The defaultvalue for
num_of_digits
varies depending onconversion_type
:MGRS: 5
USNG: 8
UTM: NA
GeoRef: 5
GARS: NA
DMS: 2
DDM: 4
DD: 6
rounding
IfTrue, then numeric portions of the string are rounded to the nearest whole magnitude asspecified bynum_of_digits
Otherwise, numeric portions of the string are truncated.
Note
The rounding parameter applies only to conversion typesMGRS,USNGandGeoRef.
The default value isTrue.
add_spaces
Option boolean.
IfTrue, then spaces are added between components of the string.
Note
Only applies toconversion_typesMGRS,USNG andUTM. The defaultvalue forMGRS isFalse, while the default value for bothUSNGandUTM isTrue.
future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
- Returns:
A list of strings iffuture = False, a
GeometryJob
object iffuture = True.
>>>strings=to_geo_coordinate_string(spatial_ref=4326, coordinates = [[180,0],[-117,34],[0,52]], conversion_type = "MGRS", conversion_mode = "mgrsNewWith180InZone01", num_of_digits=8, add_spaces=True, future = False)>>>strings ["01N AA 66021 00000","11S NT 00000 62155", "31U BT 94071 65288"]
trim_extend
- arcgis.geometry.trim_extend(spatial_ref:int|dict[str,Any]|None,polylines:list[Polyline],trim_extend_to:Polyline,extend_how:int=0,gis:GIS|None=None,future:bool=False)
The
trim_extend
function trims or extends eachPolyline
specifiedin the input list using the user-specified guide polylines.Note
When trimming features, the part to the left of the oriented cuttingline is preserved in the output, and the other part is discarded.An empty
Polyline
is added to the output listif the corresponding input polyline is neither cut nor extended.Keys
Description
polylines
A list of
Polyline
objects to trim or extendtrim_extend_to
A
Polyline
serving as the guide for trimming orextending inputpolylines.extend_how
A flag that is used along with the trimExtend function.
0
- By default, an extension considers both ends of a path. Theold ends remain, and new points are added to the extended ends.The new points have attributes that are extrapolated from adjacent existing segments.1
- If an extension is performed at an end, relocate the endpoint to the new position instead of leaving the old point andadding a new point at the new position.2
- If an extension is performed at an end, do not extrapolatethe end-segment’s attributes for the new point. Instead, make
its attributes the same as the current end. Incompatible withesriNoAttributes.*
4
- If an extension is performed at an end, do not extrapolatethe end-segment’s attributes for the new point. Instead, makeits attributes empty. Incompatible with esriKeepAttributes.
8
- Do not extend the ‘from’ end of any path.16
- Do not extend the ‘to’ end of any path.
spatial_ref
A
SpatialReference
object or the well-known ID of thespatial reference of the inputgeometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
- Returns:
A list of
Polyline
objects iffuture = False, or aGeometryJob
object iffuture = True.
union
- arcgis.geometry.union(geometries:list[~arcgis.geometry._types.Polygon]|list[~arcgis.geometry._types.Polyline]|list[~arcgis.geometry._types.MultiPoint]|list[~arcgis.geometry._types.Point],spatial_ref:str|dict[slice(<class'str'>,<class'str'>,None)]|None=None,gis:~arcgis.gis.GIS|None=None,future:bool=False)
The
union
function constructs the set-theoretic union of eachGeometry
in thegeometries list.Note
All inputs must be of the same type.
Keys
Description
geometries
Required list of
Point
,MultiPoint
,Polyline
,orPolygon
objects.spatial_ref
A
SpatialReference
object or the well-known ID of thespatial reference of the inputgeometries.future
Optional boolean.
IfTrue, a
GeometryJob
objectwill be returned and the process returns control to the user.IfFalse, the process waits for the operation to complete before returningresults and passing control back to the user.
Note
Iffuture=True, there is a limitation of 6500 geometries that can beprocessed in one call.
- Returns:
Iffuture = False, the set-theoretic union of the
Geometry
objectsin thegeometries argument, or iffuture = True, aGeometryJob
object.