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 converting geometries between different representations.
Several functions accept geometries represented as dictionaries and the geometry objects in this module behave like them as 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 the geometry 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) TruePoint
The Point
class contains x and y fields along with a SpatialReference
field. A Point
can also contain m and z fields. A Point
is empty when its x field is present and has the value null or the string NaN. An empty point
has no location in space.
Retrieves the coordinates of the Point
as an np.array
#Usage Example >>> coords = point.coordinates() >>> coords [x1,y1,m1,z1]
An np.array containing coordinate values
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 is valid, and â#ff3333â if invalid.
An SVG circle element
Gets the type of the current Point
object.
A multipoint
contains an array of Point
, along with a SpatialReference
field. A multipoint
can also have boolean-valued hasZ and hasM fields. These fields control the interpretation of elements of the points array.
Note
Omitting an hasZ or hasM field is equivalent to setting it to false.
Each element of the points array is itself an array of two, three, or four numbers. It will have two elements for 2D points, two or three elements for 2D points with Ms, three elements for 3D points, and three or four elements for 3D points with Ms. In all cases, the x coordinate is 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. For 3D points, the Z coordinate is required and is at index 2. For 3D points 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 points are ignored.
Retrieves the coordinates of the MultiPoint
as an np.array
#Usage Example >>> coords = multiPoint.coordinates() >>> coords [ [x1,y1,m1,z1], [x2,y2,m2,z2],...]
An np.array containing coordinate values for each point
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 is valid, and â#ff3333â if invalid.
A group of SVG circle elements
Gets the type of the current MultiPoint
object.
The Polyline
contains an array of paths or curvePaths and a SpatialReference
. For Polylines
with curvePaths, see the sections on JSON curve object and Polyline
with curve. Each path is represented as an array of Point
, and each point in the path is represented as an array of numbers. A Polyline
can also have boolean-valued hasM and hasZ fields.
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 paths field. Nulls and/or NaNs embedded in an otherwise defined coordinate stream for Polylines
and Polygon
objects is a syntax error.
Retrieves the coordinates of the Polyline
as a np.array
#Usage Example >>> coords = polyLine.coordinates() >>> coords [ [x1,y1,m1,z1], [x2,y2,m2,z2],...]
An np.array containing coordinate values
The has_z
method determines if the geometry has a Z value.
A boolean indicating yes (True), or no (False)
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 is valid, and â#ff3333â if invalid.
The SVG polyline element for the LineString Geometry
Gets the type of the current Polyline
object.
The Polygon
contains an array of rings or curveRings and a SpatialReference
. For Polygons
with curveRings, see the sections on JSON curve object and Polygon
with curve. Each ring is represented as an array of Point
. The first point of each ring is always the same as the last point. Each point in the ring is represented as an array of numbers. A Polygon
can also have boolean-valued hasM and hasZ fields.
An empty Polygon
is represented with an empty array for the rings field. Null and/or NaNs embedded in an otherwise defined coordinate stream for Polyline
and Polygons
is a syntax error. Polygons should be topologically simple. Exterior rings are oriented clockwise, while holes are oriented counter-clockwise. Rings can touch at a vertex or self-touch at a vertex, but there should be no other intersections. Polygons returned by services are topologically simple. When drawing a polygon, use the even-odd fill rule. The even-odd fill rule will guarantee that the polygon will draw correctly even if the ring orientation is not as described above.
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] ]
An np.array containing coordinate values
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 is valid, and â#ff3333â if invalid.
The SVG polygon element
Gets the type of the current Polyline
object.
The Envelope
class represents a rectangle defined by a range of values for each coordinate and attribute. It also has a SpatialReference
field. The fields for the z and m ranges are optional.
Note
An empty Envelope
has no points in space and is defined by the presence of an xmin field a null value or a NaN string.
The coordinates
method retrieves the coordinates of the Envelope
as a np.array
#Usage Example >>> coords = envelope.coordinates() >>> coords [ [x1,y1,m1,z1], [x2,y2,m2,z2],...]
An np.array containing coordinate values
The geohash
method retrieves a geohash string of the extent of the ``Envelope.
A geohash String
The geohash_covers
method retrieves a list of up to the four longest geohash strings that fit within the extent of the Envelope
.
A list of geohash Strings
Gets a list of the geohash neighbor strings for the extent of the Envelope
.
A list of geohash neighbor Strings
Gets the extent height value.
The extent height value
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 is valid, and â#ff3333â if invalid.
A SVG envelope element
Gets the type of the current Polyline
object.
Gets the extent width value.
The extent width value
A SpatialReference
object can be defined using a well-known ID (wkid) or well-known text (wkt). The default tolerance and resolution values for the associated coordinate system are used.
Note
The x, y and z tolerance values 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 systems using degrees, the equivalent of a mm at the equator is used.
The well-known ID (WKID) for a given spatial reference can occasionally change. For example, the WGS 1984 Web Mercator (Auxiliary Sphere) projection was originally assigned WKID 102100, but was later changed to 3857. To ensure backward compatibility with older spatial data servers, the JSON wkid property will always be the value that was originally assigned to an SR when it was created. An additional property, latestWkid, identifies the current WKID value (as of a given software release) associated with the same spatial reference.
A SpatialReference
object can optionally include a definition for a vertical coordinate system (VCS), which is used to interpret the z-values of a geometry. A VCS defines units of measure, the location of z = 0, and whether the positive vertical direction is up or down. When a vertical coordinate system is specified with a WKID, the same caveat as mentioned above applies.
Note
There are two VCS WKID properties: vcsWkid and latestVcsWkid. A VCS WKT can also be embedded in the string value of the wkt property. In other words, the WKT syntax can be used to define an SR with both horizontal and vertical components in one string. If either part of an SR is custom, the entire SR will be serialized with only the wkt property.
The JSON
method retrieves an Esri JSON representation of the Geometry
object as a string.
A string representing a Geometry
object
Gets the arcpy SpatialReference object.
Retrieves SVG (Scalable Vector Graphic) polygon element for a SpatialReference
field. ================ =============================================================================== 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 is
valid, and â#ff3333â if invalid.
Gets the type of the current SpatialReference
object.
The base class for all geometries.
You can create a Geometry even when you donât know the exact type. The Geometry constructor is able to 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
Gets the extended well-known text
(EWKT) representation for OGC geometry. It provides a portable representation of a geometry value as a text string.
Note
Any true curves in the geometry will be densified into approximate curves in the WKT string.
A String
The JSON
method retrieves an Esri JSON representation of the Geometry
object as a string.
A string representing a Geometry
object
Gets the well-known binary
(WKB) representation for OGC geometry. It provides a portable representation of a geometry value as a contiguous stream of bytes.
bytes
Gets the well-known text
(WKT
) representation for OGC geometry. It provides a portable representation of a geometry value as a text string.
Note
Any true curves in the geometry will be densified into approximate curves in the WKT string.
A string
The angle_distance_to
method retrieves a tuple of angle and distance to another Point
using a measurement type.
Note
The angle_distance_to
method requires ArcPy. If ArcPy is not installed, none is returned.
Parameter
Description
second_geometry
Required Geometry. An Geometry
object.
method
Optional String. PLANAR measurements reflect the projection of geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, and LOXODROME measurement types may be chosen as an alternative, if desired.
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}
The area
method retrieves the area of a Polygon
feature. The units of the returned area are based off the SpatialReference
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
A float
The as_arcpy
method retrieves the Geometry as an ArcPy Geometry.
If ArcPy is not installed, none is returned.
Note
The as_arcpy
method requires ArcPy
An Geometry
object
The as_shapely
method retrieves a shapely Geometry
object
A shapely Geometry
object. If shapely is not installed, None is returned
The boundary
method constructs the boundary of the Geometry
object.
A Geometry
object
The buffer method constructs a Polygon
at a specified distance from the Geometry
object.
Note
The buffer
method requires ArcPy
Parameter
Description
distance
Required float. The buffer distance. The buffer distance is in the same units as the geometry that is being buffered. A negative distance can only be specified against a polygon geometry.
A Polygon
object
The centroid
method retrieves the center of the Geometry
object
Note
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)
A tuple(x,y) indicating the center
The clip
method constructs the intersection of the Geometry
object and the specified extent.
Note
The clip
method requires ArcPy. If ArcPy is not installed, none is returned.
Parameter
Description
envelope
Required tuple. The tuple must have (XMin, YMin, XMax, YMax) each value represents the lower left bound and upper right bound of the extent.
The Geometry
object clipped to the extent
Indicates if the base Geometry
object contains the comparison Geometry
object.
Note
The contain
method requires ArcPy/Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
relation
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.
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
Constructs the Geometry
object that is the minimal bounding Polygon
such that all outer angles are convex.
A Geometry
object
Indicates if the two Geometry
objects intersect in a geometry of a lesser shape type.
Note
The crosses
method requires ArcPy/Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A boolean indicating yes (True), or no (False)
Splits this Geometry
object into a part left of the cutting Polyline
and a part right of it.
Note
The cut
method requires ArcPy
Parameter
Description
cutter
Required Polyline
. The cutting polyline geometry
a list of two Geometry
objects
Creates a new Geometry
object with added vertices
Note
The densify
method requires ArcPy
Parameter
Description
method
Required String. The type of densification: DISTANCE
, ANGLE
, or GEODESIC
distance
Required float. The maximum distance between vertices. The actual distance between vertices will usually be less than the maximum distance as new vertices will be evenly distributed along the original segment. If using a type of DISTANCE or ANGLE, the distance is measured in the units of the geometryâs spatial reference. If using a type of GEODESIC, the distance is measured in 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 and the original curve. The smaller its value, the more segments will be required to approximate the curve.
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)
Constructs the Geometry
object that is composed only of the region unique to the base geometry but not part of the other geometry.
Note
The difference
method requires ArcPy/Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A Geometry
object
Indicates if the base and comparison Geometry
objects share no Point
objects in common.
Note
The disjoint
method requires ArcPy/Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A boolean indicating no Point
objects in common (True), or some in common (False)
Retrieves the minimum distance between two Geometry
objects. If the geometries intersect, the minimum distance is 0.
Note
Both geometries must have the same projection.
Note
The distance_to
method requires ArcPy/Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A float
The envelope
method retrieves the geoextent as an Envelope
object
Indicates if the base and comparison Geometry
objects 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.
Note
The equals
method requires ArcPy or Shapely
Parameter
Description
second_geometry
Required Geometry
. A second geometry
Boolean indicating True if geometries are equal else False
Get the extent of the Geometry
object as a tuple containing xmin, ymin, xmax, ymax
Note
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)
A tuple
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}}
A Geometry
object
Creates a Python API Geometry object from a Shapely geometry object.
Note
Must have shapely installed
Parameter
Description
shapely_geometry
Required Shapely Geometry Single instance of Shapely Geometry to be converted to ArcGIS Python API geometry instance.
spatial_reference
Optional SpatialReference Defines the spatial reference for the output geometry.
A Geometry
object
# Usage Example: importing shapely geometry object and setting spatial reference to WGS84 Geometry.from_shapely( shapely_geometry=shapely_geometry_object, spatial_reference={'wkid': 4326} )
Creates a new simplified Geometry
object using a specified maximum offset tolerance.
Note
The generalize
method requires ArcPy or Shapely**
Parameter
Description
max_offset
Required float. The maximum offset tolerance.
A Geometry
object
The geoextent
property retrieves the current featureâs extent
#Usage Example >>> g = Geometry({...}) >>> g.geoextent (1,2,3,4)
tuple
>>> 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'
A string indicating the geometry type
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 of geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, LOXODROME, and PRESERVE_SHAPE measurement types may 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
A float representing the area of the Geometry
object
Retrieves the length of the Geometry
using a measurement type.
Note
The get_length
method requires ArcPy
Parameter
Description
method
Required String. PLANAR measurements reflect the projection of geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, LOXODROME, and PRESERVE_SHAPE measurement types may 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
A float representing the length of the Geometry
object
Retrieves an array of Point
objects for a particular part of a Geometry
object or an array containing a number of arrays, one for each part.
Note
The get_part
method requires ArcPy
Parameter
Description
index
Required Integer. The index position of the Geometry
object.
A Geometry
object
The has_m
method determines if the geometry has a M value.
A boolean indicating yes (True), or no (False)
The has_z
method determines if the geometry has a Z value.
A boolean indicating yes (True), or no (False)
The hull_rectangle
method retrieves the space-delimited string of the coordinate pairs of the convex hull rectangle.
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'
A space-delimited string
Constructs a Geometry
object 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.
Note
The intersect
method requires ArcPy or Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
dimension
Required Integer. The topological dimension (shape type) of the resulting geometry.
1 -A zero-dimensional geometry (Point
or MultiPoint
).
2 -A one-dimensional geometry (Polyline
).
4 -A two-dimensional geometry (Polygon
).
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
Determines if the geometry is empty.
A boolean indicating empty (True), or filled (False)
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_multipart True
A boolean indicating yes (True), or no (False)
Gets the Point
at which the label is located. The label_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}}
A Point
object
The last_point
method retrieves the last coordinate Point
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}}
A Point
object
Gets length of the linear feature. The length units is the same as the SpatialReference
field.
Note
The length
method returns zero for Point
and MultiPoint
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.length 0.03033576008004027
A float
The length3D
method retrieves the 3D length of the linear feature. Zero for point and multipoint The length units is the same as the SpatialReference
field.
Note
The length3D
method returns zero for Point
and MultiPoint
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.length3D 0.03033576008004027
A float
Retrieves a measure from the start Point
of this line to the in_point
.
Note
The measure_on_line
method requires ArcPy
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
as_percentage
Optional Boolean. If False, the measure will be returned as a distance; if True, the measure will be returned as a percentage.
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
Indicates if the intersection of the two Geometry
objects has the same shape type as one of the input geometries and is not equivalent to either of the input geometries.
Note
The overlaps
method requires ArcPy or Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A boolean indicating an intersection of same shape type (True), or different type (False)
The part_count
method retrieves the number of Geometry
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_count 1
An Integer representing the amount of Geometry
parts
The point_count
method retrieves total number of Point
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_count 9
An Integer representing the amount of Point
objects
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 ArcPy
Parameter
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 geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, LOXODROME, and PRESERVE_SHAPE measurement types may be chosen as an alternative, if desired.
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"
Retrieves a Point
on a line at a specified distance from the beginning of the line.
Note
The position_along_line
method requires ArcPy or Shapely
Parameter
Description
value
Required Float. The distance along the line.
use_percentage
Optional Boolean. The distance may be specified as a fixed unit of measure or a ratio of the length of the line. If True, value is used as a percentage; if False, value is used as a distance.
Note
For percentages, the value should be expressed as a double from 0.0 (0%) to 1.0 (100%).
A Geometry
object
Projects a Geometry
object and optionally applies a geotransformation
.
Note
The project_as
method requires ArcPy or pyproj>=1.9 and PROJ.4
Parameter
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.
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
Finds the Point
on the Polyline
nearest to the in_point and the distance between those points. query_point_and_distance
retrieves information about the side of the line the in_point is on as well as the distance along the line where the nearest point occurs.
Note
The query_point_and_distance
method requires ArcPy
Note
The query_point_and_distance
method only is valid for Polyline geometries.
Parameter
Description
second_geometry
Required Point
object. A second geometry
as_percentage
Optional boolean - if False, the measure will be returned as distance, True, measure will be a percentage
A tuple of the point and the distance
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, False creates a new object
A Geometry
object
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, False creates a new object
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)
Retrieves a Polyline
between start
and end
measures. segment_along_line
is similar to the positionAlongLine
method but will return a polyline segment between two points on the polyline instead of a single Point
.
Note
The segment_along_line
method requires ArcPy
Parameter
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 as fixed units or as a ratio. If True, start_measure and end_measure are used as a percentage; if False, start_measure and end_measure are used as a distance.
Note
For percentages, the measures should be expressed as a double from 0.0 (0 percent) to 1.0 (100 percent).
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
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, False creates a new object
A Geometry
object
The snap_to_line
method retrieves a new Point
based on in_point snapped to this Geometry
object.
Note
The snap_to_line
method requires ArcPy
Parameter
Description
second_geometry
Required Geometry
- A second geometry
A Point
object
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>
A SpatialReference
object
The symmetric_difference
method constructs a new Geometry
object that is the union of 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 Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A Geometry
object
Indicates if the boundaries of the two Geometry
objects intersect.
Note
The touches
method requires ArcPy or Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A boolean indicating whether the Geometry
objects touch (True), or if they do not touch (False)
Moves a Geometry
object in the x and y direction by a given distance.
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 it creates a new Geometry object
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)
Gets the Point
representing the center of gravity for 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}}
A Point
object
Constructs the Geometry
object that is the set-theoretic union of the input geometries.
Note
The union
method requires ArcPy or Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
A Geometry
object
Indicates if the base Geometry
object is within the comparison Geometry
object.
Note
The within
method requires ArcPy or Shapely
Parameter
Description
second_geometry
Required Geometry
object. A second geometry
relation
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.
A boolean indicating the Geometry
object is within (True), or not within (False)
The areas_and_lengths function calculates areas and perimeter lengths for each Polygon
specified in the input array.
Keys
Description
polygons
The list of Polygon
objects whose areas and lengths are to be computed.
length_unit
The length unit in which the perimeters of polygons will be calculated.
If calculation_type is planar, then this argument can be any esriUnits constant string or integer.
If calculationType is not planar, then length_unit must be a linear LengthUnits
constant or string. For example:
For meters, use 9001 or LengthUnits.METER
For survey miles, use 9035 or LengthUnits.SURVEYMILE
If length_unit is not specified, the units are derived from spatial_ref. If spatial_ref is not specified as well, the units are in meters.
area_unit
The area unit in which areas of polygons will be calculated.
If calculation_type is planar, then area_unit can be any esriAreaUnits constant.
If calculation_type is not planar, then area_unit must be an AreaUnits
dictionary. For example,
for square meters use - {âareaUnitâ: âesriSquareMetersâ}
for square miles use - {âareaUnitâ: âesriSquareMilesâ}
If area_unit is not specified, the units are derived from the spatial_ref. If spatial_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 one of the following values:
planar - Planar measurements use 2D Euclidean distance to calculate area and length. This should only be used if the area or length needs to be calculated in the given
SpatialReference
. Otherwise, use preserveShape.geodesic - Use this type if you want to calculate an area or length using only the vertices of the
Polygon
and define the lines between the points as geodesic segments independent of the actual shape of thePolygon
. A geodesic segment is the shortest path between two points on an ellipsoid.preserveShape - This type calculates the area or length of the geometry on the surface of the 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 value is the wkid value of the spatial reference. Default 4326.
gis
Optional GIS
object. If no argument provided, the active GIS will be used.
future
Optional boolean.
If True, a GeometryJob
that can be queried will be returned and control returns to the user.
If False, a dictionary object with results after the function completes.
A dictionary with result output if future=False, or a GeometryJob
object if future = 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 >>> from arcgis.geometry import LengthUnits, 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 >>> while trials < 10: >>> if not ft_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]}
The auto_complete
function simplifies the process of constructing new Polygon
objects that are adjacent to other polygons. It constructs polygons that fill in the gaps between existing polygons and a set of Polyline
objects.
Keys
Description
polygons
A List of Polygon
objects
polylines
A List of Polyline
objects
spatial_ref
A SpatialReference
of the input geometries or the integer WKID of the spatial reference.
future
Optional boolean.
If True, a GeometryJob
that can be queried will be returned and control returns to the user.
If False, a Polygon
object will be returned after the function completes.
If future=False, a Polygon
object. If future=True, a GeometryJob
object. See code example in areas_and_lengths
for code snippet querying the job.
The buffer
function creates polygons
around each input Geometry
in the list at the specified 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 for the input geometries.
distances
The distances that each input Geometry
will be buffered.
unit
The unit of the buffer distances. * If not specified, the units are derived from buffer_sr. * If buffer_sr is also not specified, the units are derived from in_sr.
out_sr
The well-known ID or the SpatialReference
object for the returned geometries
.
buffer_sr
The well-known ID or the SpatialReference
object in which the geometries
are buffered.
union_results
Optional boolean. * If True, all geometries buffered at a given distance are unioned into a single (possibly multipart) Polygon
and the unioned Geometry
is placed in the output list. The default is False.
geodesic
Optional boolean.
If True, buffer the input geometries using geodesic distance. Geodesic
distance is the shortest path between two points along the ellipsoid of the earth. If False, the 2D Euclidean distance is used
future
Optional boolean.
If True, a GeometryJob
will be returned for query and the process returns control to the user.
If False, the process waits until completion before returning the output polygons
The default is False.
Note
If setting future to True there is a limitation of 6500 geometries that can be processed in one call.
A list of Polygon
objects if future=False, or a GeometryJob
object if future=True. Query the jobâs result()
method to get results.
>>> from arcgis.gis import GIS >>> from arcgis.geometry import Point, 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}}]
The convex_hull function is performed on a Geometry Service resource. It returns the minimum bounding shape that contains the input geometry. The input geometry can be a Point
, MultiPoint
, Polyline
, or Polygon
object.
Note
The convex hull is typically a polygon but can also be a polyline or point in degenerate cases.
Keys
Description
geometries
A list of Point
, MultiPoint
, Polyline
, or Polygon
objects. The structure of each geometry in the array is defined the same as the JSON geometry objects returned by the ArcGIS REST API.
Note
Geometry
objects can be obtained by querying a FeatureLayer
, returning it as a Pandas data 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
object defined using the the Well-Known ID (wkid) of the Spatial Reference.
>>> geom_result = convex_hull(geometries=[geometry_object] spatial_ref=<wkid>)
or
>>> geom_result = convex_hull(geometries=[geometry_object], spatial_ref={"wkid": <wkid>})
or
>>> from arcgis.geometry import SpatialReference >>> sr_obj_wkid = SpatialReference(<wkid>) >>> geom_result = convex_hull(geometries=[geometry_object], spatial_ref=sr_obj_wkid)
future
Optional boolean.
If True, a GeometryJob
will be returned for query and the process returns control to the user.
If False, the process waits until completion before returning the output polygons
The default is False.
Note
If setting future to True there is a limitation of 6500 geometries that can be processed in one call.
A list containing the Geometry
object of the result, or if future=True
, a GeometryJob
object. Call the jobâs result()
method to inspect the process and results.
# Usage Example: >>> import time >>> from arcgis.gis import GIS >>> from arcgis.geometry import convex_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 >>> while trials < 5: >>> if not hull_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}}}
The geometry service cut
function splits a target Polyline
or Polygon
geometry where it is crossed by the cutter Polyline
geometry.
Note
At 10.1 and later, this function calls simplify on the input cutter and target geometries.
Keys
Description
cutter
The Polyline
that will be used to divide the target geometry into pieces where it crosses the target.
target
The list of Polyline
or Polygon
objects to be cut.
spatial_ref
A SpatialReference
object or well-known ID specifying the spatial reference of the input geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
A List of Geometry
objects if future=False, or a GeometryJob
if future=True.
The densify
function adds vertices to Geometry
objects at regular intervals.
Keys
Description
geometries
A list of Polyline
or Polygon
geometry objects to densify.
spatial_ref
The well-known ID or a SpatialReference
object for the input geometries
.
max_segment_len
All segments longer than maxSegmentLength are replaced with sequences of lines no longer than max_segment_length.
length_unit
The length unit of max_segment_length.
If geodesic = False, then the units are derived from the spatial_ref argument and the length_unit argument is ignored
If geodesic = True, then length_unit must be a linear unit
If argument is not provided and the spatial_ref argument is a projected coordinate system, this value is derived from the spatial_ref
If argument is not provided and the spatial_ref argument is a geographic coordinate system, the units are meters
geodesic
Optional boolean.
If True, then geodesic distance is used to calculate max_segment_length.
If False, then 2D Euclidean distance is used to calculate max_segment_length. The default is False.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of Geometry
objects. If future = True, a GeometryJob
object.
The difference function constructs the set-theoretic difference between each member of a list of geometries
and another Geometry
object. In other words, let B be the difference geometry. For each geometry, A, in the input geometry list, it constructs A - B.
Note
The operation calls simplify()
on the input geometries
Keys
Description
geometries
An array of Point
, MultiPoint
, Polyline
, or Polygon
objects.
geometry
A single Geometry
object of any type and of a dimension equal to or greater than the elements of the geometries argument.
spatial_ref
A SpatialReference
object or the well-known ID specifying the spatial reference of the input geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of Geometry
objects. If future = True, a GeometryJob
object.
The distance
function is performed on a geometry service resource. It reports the 2D Euclidean or geodesic distance between the two Geometry
objects.
Keys
Description
geometry1
The Geometry
object from which the distance is measured. The structure of each geometry in the array is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.
geometry2
The Geometry
object to which the distance is measured. The structure of each geometry in the array is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.
distance_unit
Optional. One of LengthUnits
enumeration members. See Geometry Service distance for full details.
geodesic
If geodesic
is set to true, then the geodesic distance between the geometry1
and geometry2
geometries is returned. Geodesic distance is the shortest path between two points along the ellipsoid of the earth. If geodesic
is set to false or not specified, the planar distance is returned. The default value is false.
spatial_ref
A SpatialReference
of the input geometries Well-Known ID or JSON object
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
If future = False, the distance value between the Geometry
objects. If future = True, a GeometryJob
object.
The find_transformations
function is performed on a Geometry
service resource. This function returns a list of applicable geographic transformations you should use when projecting geometries from the input SpatialReference
to the output SpatialReference
. The transformations are in JSON format and are returned in order of most applicable to least applicable. Recall that a geographic transformation is not needed when the input and output spatial references have the same underlying geographic coordinate systems. In this case, findTransformations returns an empty list.
Note
Every returned geographic transformation is a forward transformation meaning that it can be used as-is to project from the input spatial reference to the output spatial reference. In the case where a predefined transformation needs to be applied in the reverse direction, it is returned as a forward composite transformation containing one transformation and a transformForward element with a value of false.
Keys
Description
in_sr
The well-known ID of the SpatialReference
or a spatial reference JSON object for the input geometries.
out_sr
The well-known ID of the SpatialReference
or a spatial 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 of interest is used to return the most applicable geographic transformations for the area.
Note
If a SpatialReference
is not included in the JSON envelope, the in_sr
is used for the envelope.
num_of_results
The number of geographic transformations to return. The default value is 1.
Note
If num_of_results
has a value of -1, all applicable transformations are returned.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of geographic transformations, or if future = True, a GeometryJob
object.
The from_geo_coordinate_string
function is performed on a Geometry
service resource. The function converts an array of well-known strings into xy-coordinates based on the conversion type and SpatialReference
supplied by the user. An optional conversion mode parameter is available for some conversion types. See to_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 object
strings
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.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
If future = False, a is of (x,y) coordinates and if future = 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]]
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 of the original input vertices.
Keys
Description
geometries
Required. The list of Polyline
or Polygon
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 input geometry.
deviation_unit
Specifies a unit for the max_deviation argument.
Note
If not specified, the units are derived from spatial_ref
spatial_ref
A SpatialReference
object or the Well-Known ID of the input geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of the generalized Geometry
objects, or if future = True, a GeometryJob
object.
The intersect
function constructs the set-theoretic intersection between a list of geometries <arcgis.geometry.Geometry> and another Geometry
.
Note
The dimension of each resultant geometry is the minimum dimension of the input geometries list and the object serving as the geometry argument.
Keys
Description
geometries
An list of Point
, MultiPoint
, Polyline
, or Polygon
objects.
geometry
A single Geometry
of any type and of a dimension equal to or greater than the elements of geometries.
spatial_ref
A SpatialReference
object or the Well-Known ID of the input geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, the set-theoretic dimension between Geometry
objects, or if future = True, a GeometryJob
object.
The label_points
function calculates an interior Point
for each Polygon
specified in the input list. These interior points can be used by clients for labeling the polygons.
Keys
Description
polygons
Required list of Polygon
objects whose label Point
objects are to be computed.
spatial_ref
A SpatialReference
object or the well-known ID of the spatial reference of the input polygons.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of Point
objects, or if future = True, a GeometryJob
object.
The lengths
function calculates the` 2D Euclidean` or geodesic lengths of each Polyline
specified in the input array.
Keys
Description
spatial_ref
A SpatialReference
object or the well-known ID of the spatial reference of the input polygons.
polylines
The list of Polyline
objects to compute.
length_unit
The length unit in which the lengths are calculated.
If calculation_type is planar - value can be any esriUnits constant
If calculation_type is planar and argument not provided, the units are derived from spatial_ref
.
If calculationType is not planar, then must be a LengthUnits
value, such as LengthUnits.METER or LengthUnits.SURVEYMILE
If calculationType is not planar and argument not provided, the value is meters
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 given spatial_ref, otherwise use preserveShape
- geodesic - uses only the vertices of the polygon and defines the
lines between the vertices as geodesic independent of the actual shape of the
Polyline
. This segment is the shortest path between 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.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of 2D-Euclidean or geodesic lengths in float format, or if future = True, a GeometryJob
object.
The offset
function constructs geometries
that are offset from the input geometries. If the offset parameter is positive, the constructed 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 a direction along the geometry. It is to the right and left perspective of this direction that the positive and negative parameters will dictate where the offset is constructed. In these terms, you may infer where the offset of even horizontal geometries will be constructed.
Keys
Description
geometries
Required list of Point
, MultiPoint
, Polyline
, or Polygon
objects.
offset_distance
Specifies the distance for constructing an offset geometry.
Note
If the offset_distance
parameter is positive, the constructed offset will 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 naturally intersect, but if that intersection occurs too far from the corner, the corner is eventually bevelled off at a fixed distance.
bevel_ratio
Value is multiplied by the offset_distance, and determines how far a mitered offset intersection can be located before it is bevelled.
when offset_how = esriGeometryOffsetMitered, argument is ignored and 10 is used internally.
when offset_how = esriGeometryOffsetBevelled, 1.1 will be used if argument not specified
when offset_how = esriGeometryOffsetRounded, argument is ignored
simplify_result
Option boolean. If True, true, then self intersecting loops will be removed. The default is False.
spatial_ref
A SpatialReference
object of the well-known ID of the spatial reference of the of the input geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of Geometry
objects, or if future = True, a GeometryJob
object.
# Usage Example: >>> from arcgis.geometry import Polyline, 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})
The project
function projects a list of input geometries from the input SpatialReference
to the output SpatialReference
Keys
Description
geometries
An list of Point
, MultiPoint
, Polyline
, or Polygon
objects.
in_sr
The well-known ID of the spatial reference or a SpatialReference
object specifying the spatial reference of the input geometries.
out_sr
The well-known ID of the spatial reference or a SpatialReference
object specifying the spatial reference of the output geometries.
transformation
The well-known ID or a dictionary specifying the geographic transformation (also known as datum transformation) to be applied to the projected geometries.
Note
A transformation is needed only if the output SpatialReference
contains a different coordinate system from the input spatial reference. For comprehensive list of transformations, see Transformation 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 is False.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, a list of Geometry
objects in the out_sr coordinate system,, or if future = True, a GeometryJob
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}]
The relation
function determines the pairs of geometries from the input list that participate in the specified spatial relation.
Note
Both lists are assumed to be in the spatial reference specified by the spatial_ref, which is a required argument. Geometry types cannot be mixed within 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 compute the relations.
geometries2
The second list of Geometry
objects used.
spatial_ref
A SpatialReference
object or the well-known ID of the spatial reference of the geometries.
relation_param
Only relevant when spatial_relation = esriGeometryRelationRelation. The Shape Comparison Language string to be evaluated. See here for 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.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
If future = False, a dictionary of geometry index positions of geometries that participate in the specified relation, or if future = 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}]}
The reshape
function modifies a Polyline
or Polygon
feature by constructing a polyline over the feature. The feature takes the shape of this reshaper polyline from the first place it intersects the feature to the last.
Keys
Description
target
The Polyline
or Polygon
to reshape.
reshaper
The single-part Polyline
object that reshapes target.
spatial_ref
A SpatialReference
object or the well-known ID of the spatial reference of the geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
f *future = False, A reshaped Polyline
or Polygon
object if future = True, a GeometryJob
object.
The to_geo_coordinate_string
function is performed on a Geometry
service resource. The function converts an array of xy-coordinates into well-known strings based on the conversion type and SpatialReference
supplied by the User
. Optional parameters are available for some conversion types. See from_geo_coordinate_strings
for more information on the opposite conversion.
Note
If an optional parameter is not applicable for a particular conversion type, but a value is supplied for that parameter, the value will be ignored.
Keys
Description
spatial_ref
A SpatialReference
object or the well-known ID of the spatial reference of the input coordinates.
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 default value for num_of_digits
varies depending on conversion_type
:
MGRS: 5
USNG: 8
UTM: NA
GeoRef: 5
GARS: NA
DMS: 2
DDM: 4
DD: 6
rounding
If True, then numeric portions of the string are rounded to the nearest whole magnitude as specified by num_of_digits
Otherwise, numeric portions of the string are truncated.
Note
The rounding parameter applies only to conversion types MGRS, USNG and GeoRef.
The default value is True.
add_spaces
Option boolean.
If True, then spaces are added between components of the string.
Note
Only applies to conversion_types MGRS, USNG and UTM. The default value for MGRS is False, while the default value for both USNG and UTM is True.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
A list of strings if future = False, a GeometryJob
object if future = 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"]
The trim_extend
function trims or extends each Polyline
specified in the input list using the user-specified guide polylines.
Note
When trimming features, the part to the left of the oriented cutting line is preserved in the output, and the other part is discarded. An empty Polyline
is added to the output list if the corresponding input polyline is neither cut nor extended.
Keys
Description
polylines
A list of Polyline
objects to trim or extend
trim_extend_to
A Polyline
serving as the guide for trimming or extending input polylines.
extend_how
A flag that is used along with the trimExtend function.
0
- By default, an extension considers both ends of a path. The old 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 end point to the new position instead of leaving the old point and adding a new point at the new position.
2
- If an extension is performed at an end, do not extrapolate the end-segmentâs attributes for the new point. Instead, make
its attributes the same as the current end. Incompatible with esriNoAttributes. * 4
- If an extension is performed at an end, do not extrapolate
the end-segmentâs attributes for the new point. Instead, make its 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 the spatial reference of the input geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
A list of Polyline
objects if future = False, or a GeometryJob
object if future = True.
The union
function constructs the set-theoretic union of each Geometry
in the geometries list.
Note
All inputs must be of the same type.
Keys
Description
geometries
Required list of Point
, MultiPoint
, Polyline
, or Polygon
objects.
spatial_ref
A SpatialReference
object or the well-known ID of the spatial reference of the input geometries.
future
Optional boolean.
If True, a GeometryJob
object will be returned and the process returns control to the user.
If False, the process waits for the operation to complete before returning results and passing control back to the user.
Note
If future=True, there is a limitation of 6500 geometries that can be processed in one call.
If future = False, the set-theoretic union of the Geometry
objects in the geometries argument, or if future = True, a GeometryJob
object.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4