The functions module is used to take Geometry objects
as parameter arguments and return Geometry objects as results.
These functions use spatial references as inputs and outputs. They can be entered as
SpatialReference objects or as integer values representing the
well-known ID of each reference.
>>> from arcgis.geometry input SpatialReference
>>> sr = SpatialReference(iterable={"wkid": 3857})
>>> function_res = function_name(...
spatial_ref = sr,
...)
or
>>> sr = 3857
>>> function_res = function(...
in_sr = sr,
...)
For further details and explanation of concepts, see Using Spatial References. Also see the Working with Geometries Introduction guide in the Editing section of the API for Python documentation.
For a complete list of well-known ID values, see Coordinate System PDF
GeometryJob
- class arcgis.geometry.GeometryJob(future: Future, task_name: str, jobid: str = None, task_url: str = None, notify: bool = False, gis=None, out_wkid: int = None)
-
- property elapse_time
Returns the amount of time that has passed while the
AsyncJobran.
Enumerations
AreaUnits
LengthUnits
Functions
areas_and_lengths
- arcgis.geometry.functions.areas_and_lengths(polygons: Polygon, length_unit: str | LengthUnits, area_unit: str | AreaUnits, calculation_type: str, spatial_ref: int = 4326, gis: GIS | None = None, future: bool = False)
The areas_and_lengths function calculates areas and perimeter lengths for each
Polygonspecified in the input array.Keys
Description
polygons
The list of
Polygonobjects 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
LengthUnitsconstant 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
AreaUnitsdictionary. 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
Polygonand 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.
Note
See Using Spatial References for links to comprehensive list of values.
gis
Optional
GISobject. If no argument provided, the active GIS will be used.future
Optional boolean.
If True, a
GeometryJobthat can be queried will be returned and control returns to the user.If False, a dictionary object with results after the function completes.
- Returns:
A dictionary with result output if future=False, or a
GeometryJobobject 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]}
auto_complete
- arcgis.geometry.functions.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_completefunction simplifies the process of constructing newPolygonobjects that are adjacent to other polygons. It constructs polygons that fill in the gaps between existing polygons and a set ofPolylineobjects.Keys
Description
polygons
A List of
Polygonobjectspolylines
A List of
Polylineobjectsspatial_ref
A
SpatialReferenceof the input geometries or the integer WKID of the spatial reference.future
Optional boolean.
If True, a
GeometryJobthat can be queried will be returned and control returns to the user.If False, a
Polygonobject will be returned after the function completes.
- Returns:
If future=False, a
Polygonobject. If future=True, aGeometryJobobject. See code example inareas_and_lengthsfor code snippet querying the job.
buffer
- arcgis.geometry.functions.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
bufferfunction createspolygonsaround each inputGeometryin 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
geometriesto buffer.in_sr
The well-known ID, or a
SpatialReferenceobject for the input geometries.distances
The distances that each input
Geometrywill 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
SpatialReferenceobject for the returnedgeometries.buffer_sr
The well-known ID or the
SpatialReferenceobject in which thegeometriesare buffered.union_results
Optional boolean. * If True, all geometries buffered at a given distance are unioned into a single (possibly multipart)
Polygonand the unionedGeometryis 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
Note
The default value depends on the geometry type, unit and buffer_sr arguments. See buffering using GCS and buffering using PCS for details.
future
Optional boolean.
If True, a
GeometryJobwill 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.
- Returns:
A list of
Polygonobjects if future=False, or aGeometryJobobject if future=True. Query the job’sresult()method to get results.
>>> from arcgis.gis import GIS >>> from arcgis.geometry import Point, buffer, LengthUnits, AreaUnits >>> gis = GIS(profile="my_enterprise_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.functions.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)
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, orPolygonobject.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, orPolygonobjects. The structure of each geometry in the array is defined the same as the JSON geometry objects returned by the ArcGIS REST API.Note
Geometryobjects can be obtained by querying aFeatureLayer, 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
SpatialReferenceobject defined using the the Well-Known ID (wkid) of the Spatial Reference.Note
See Spatial Reference in the Geometry objects help, or Using Spatial References for details on concepts and resources for finding specific wkid values.
>>> 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
GeometryJobwill 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.
- Returns:
A list containing the
Geometryobject of the result, or iffuture=True, aGeometryJobobject. Call the job’sresult()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}}}
cut
- arcgis.geometry.functions.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
cutfunction splits a targetPolylineorPolygongeometry where it is crossed by the cutterPolylinegeometry.Note
At 10.1 and later, this function calls simplify on the input cutter and target geometries.
Keys
Description
cutter
The
Polylinethat will be used to divide the target geometry into pieces where it crosses the target.target
spatial_ref
A
SpatialReferenceobject or well-known ID specifying the spatial reference of the input geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
A List of
Geometryobjects if future=False, or aGeometryJobif future=True.
densify
- arcgis.geometry.functions.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 | LengthUnits | None, geodesic: bool = False, gis: GIS | None = None, future: bool = False)
The
densifyfunction adds vertices toGeometryobjects at regular intervals.Keys
Description
geometries
spatial_ref
The well-known ID or a
SpatialReferenceobject for the inputgeometries.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
GeometryJobobject 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.
- Returns:
If future = False, a list of
Geometryobjects. If future = True, aGeometryJobobject.
difference
- arcgis.geometry.functions.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)
The difference function constructs the set-theoretic difference between each member of a list of
geometriesand anotherGeometryobject. 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 geometriesKeys
Description
geometries
An array of
Point,MultiPoint,Polyline, orPolygonobjects.geometry
A single
Geometryobject of any type and of a dimension equal to or greater than the elements of the geometries argument.spatial_ref
A
SpatialReferenceobject or the well-known ID specifying the spatial reference of the input geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, a list of
Geometryobjects. If future = True, aGeometryJobobject.
distance
- arcgis.geometry.functions.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
distancefunction is performed on a geometry service resource. It reports the 2D Euclidean or geodesic distance between the twoGeometryobjects.Keys
Description
geometry1
The
Geometryobject 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
Geometryobject 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
LengthUnitsenumeration members. See Geometry Service distance for full details.geodesic
If
geodesicis set to true, then the geodesic distance between thegeometry1andgeometry2geometries is returned. Geodesic distance is the shortest path between two points along the ellipsoid of the earth. Ifgeodesicis set to false or not specified, the planar distance is returned. The default value is false.spatial_ref
A
SpatialReferenceof the input geometries Well-Known ID or JSON objectfuture
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, the distance value between the
Geometryobjects. If future = True, aGeometryJobobject.
find_transformation
- arcgis.geometry.functions.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_transformationsfunction is performed on aGeometryservice resource. This function returns a list of applicable geographic transformations you should use when projecting geometries from the inputSpatialReferenceto the outputSpatialReference. 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
SpatialReferenceor a spatial reference JSON object for the input geometries.out_sr
The well-known ID of the
SpatialReferenceor 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
SpatialReferenceis not included in the JSON envelope, thein_sris used for the envelope.num_of_results
The number of geographic transformations to return. The default value is 1.
Note
If
num_of_resultshas a value of -1, all applicable transformations are returned.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, a list of geographic transformations, or if future = True, a
GeometryJobobject.
from_geo_coordinate_string
- arcgis.geometry.functions.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_stringfunction is performed on aGeometryservice resource. The function converts an array of well-known strings into xy-coordinates based on the conversion type andSpatialReferencesupplied by the user. An optional conversion mode parameter is available for some conversion types. Seeto_geo_coordinate_stringsfor more information on the opposite conversion.Keys
Description
spatial_ref
A
SpatialReferenceof 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.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, a is of (x,y) coordinates and if future = True, a
GeometryJobobject.
>>> 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.functions.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
generalizesimplifies 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
PolylineorPolygonobjects 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
SpatialReferenceobject or the Well-Known ID of the input geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, a list of the generalized
Geometryobjects, or if future = True, aGeometryJobobject.
intersect
- arcgis.geometry.functions.intersect(spatial_ref: int | dict[str, Any] | None, geometries: list[Geometry], geometry: Geometry, gis: GIS | None = None, future: bool = False)
The
intersectfunction constructs the set-theoretic intersection between a list of geometries <arcgis.geometry.Geometry> and anotherGeometry.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, orPolygonobjects.geometry
A single
Geometryof any type and of a dimension equal to or greater than the elements of geometries.spatial_ref
A
SpatialReferenceobject or the Well-Known ID of the input geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, the set-theoretic dimension between
Geometryobjects, or if future = True, aGeometryJobobject.
label_points
- arcgis.geometry.functions.label_points(spatial_ref: int | dict[str, Any] | None, polygons: list[Polygon], gis: GIS | None = None, future: bool = False)
The
label_pointsfunction calculates an interiorPointfor eachPolygonspecified in the input list. These interior points can be used by clients for labeling the polygons.Keys
Description
polygons
Required list of
Polygonobjects whose labelPointobjects are to be computed.spatial_ref
A
SpatialReferenceobject or the well-known ID of the spatial reference of the input polygons.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, a list of
Pointobjects, or if future = True, aGeometryJobobject.
lengths
- arcgis.geometry.functions.lengths(spatial_ref: int | SpatialReference | dict[str, Any], polylines: list[Polyline], length_unit: str | int | LengthUnits, calculation_type: str, gis: GIS | None = None, future: bool = False)
Calculates the 2D Euclidean or geodesic lengths of each
Polylinespecified in the input array.Keys
Description
spatial_ref
A
SpatialReferenceobject or the well-known ID of the spatial reference of the input polygons.polylines
The list of
Polylineobjects to compute.# Usage Example for parameter: >>> from arcgis.geometry import Polyline >>> from arcgis.geometry.functions import lengths >>> polyline1 = Polyline( >>> { >>> "paths": [ >>> [ >>> [-95.5, 30.2], [-95.6, 30.3] >>> ] >>> ], >>> "spatialReference": {"wkid": 4326} >>> } >>> ) >>> length_val = lengths( >>> ... >>> polylines=[polyline1] >>> ... >>> )
length_unit
A
LengthUnitsobject for which unit of measure to return result.If calculation_type is planar - value can be any esriUnits constant
Note
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
LengthUnitsvalue, such as LengthUnits.METER or LengthUnits.SURVEYMILE
Note
If calculationType is not planar and argument not provided, the value is meters
See valid list of esriUnits constants: esriSRUnitTypeConstants
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 polyline 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
GeometryJobobject 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.
- Returns:
If future = False, a list of 2D-Euclidean or geodesic lengths in float format
If future = True, a
GeometryJobobject.
# Example Usage: Running lengths on a feature's geometry >>> from arcgis.gis import GIS >>> from arcgis.geometry import Polyline >>> from arcgis.geometry import lengths, LengthUnits >>> gis = GIS(profile="your_organization_profile") >>> roads_item = gis.content.search("Major Roads")[0] >>> roads_flayer = roads_item.layers[0] >>> major_road_feature = roads_flyr.query("Carpenter Road").features[0] >>> major_road_line = Polyline(major_read_feature.geometry) >>> usFeet_simple = lengths( >>> spatial_ref=4326, >>> polylines=[major_road_line], >>> length_unit=LengthUnits.FOOT, >>> calculation_type='geodesic', >>> gis=gis >>> ) >>> print(usFeet_simple) [7619.876053]
offset
- arcgis.geometry.functions.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
offsetfunction constructsgeometriesthat 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, orPolygonobjects.offset_distance
Specifies the distance for constructing an offset geometry.
Note
If the
offset_distanceparameter 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.LengthUnitsoptions.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
SpatialReferenceobject of the well-known ID of the spatial reference of the of the input geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, a list of
Geometryobjects, or if future = True, aGeometryJobobject.
# 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})
project
- arcgis.geometry.functions.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
projectfunction projects a list of input geometries from the inputSpatialReferenceto the outputSpatialReferenceKeys
Description
geometries
An list of
Point,MultiPoint,Polyline, orPolygonobjects.in_sr
The well-known ID of the spatial reference or a
SpatialReferenceobject specifying the spatial reference of the input geometries.out_sr
The well-known ID of the spatial reference or a
SpatialReferenceobject 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
SpatialReferencecontains 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
GeometryJobobject 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.
- Returns:
If future = False, a list of
Geometryobjects in the out_sr coordinate system,, or if future = True, aGeometryJobobject.
#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.functions.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
relationfunction 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
Geometryobjects used to compute the relations.geometries2
The second list of
Geometryobjects used.spatial_ref
A
SpatialReferenceobject 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
GeometryJobobject 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.
- Returns:
If future = False, a dictionary of geometry index positions of geometries that participate in the specified relation, or if future = True, a
GeometryJobobject.
>>> 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.functions.reshape(spatial_ref: int | dict[str, Any] | None, target: Polyline | Polygon, reshaper: Polyline, gis: GIS | None = None, future: bool = False)
The
reshapefunction modifies aPolylineorPolygonfeature 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
reshaper
The single-part
Polylineobject that reshapes target.spatial_ref
A
SpatialReferenceobject or the well-known ID of the spatial reference of the geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
f *future = False, A reshaped
PolylineorPolygonobject if future = True, aGeometryJobobject.
simplify
- arcgis.geometry.functions.simplify(spatial_ref: int | dict[str, Any] | None, geometries: list[Polygon] | list[Polyline] | list[MultiPoint] | list[Point], gis: GIS | None = None, future: bool = False)
The
simplifyfunction permanently alters each of the inputgeometriesso they become topologically consistent.Keys
Description
geometries
Required list of
Point,MultiPoint,Polyline, orPolygonobjects to simplify.spatial_ref
A
SpatialReferenceobject or the well-known ID of the spatial reference of the input and output geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
An array of
Geometryobjects if future = False, or aGeometryJobobject if future = True.
to_geo_coordinate_string
- arcgis.geometry.functions.to_geo_coordinate_string(spatial_ref: int | dict[str, Any] | None, coordinates: list[list[float]], conversion_type: str, conversion_mode: str = 'mgrsDefault', num_of_digits: int | None = None, rounding: bool = True, add_spaces: bool = True, gis: GIS | None = None, future: bool = False)
The
to_geo_coordinate_stringfunction is performed on aGeometryservice resource. The function converts an array of xy-coordinates into well-known strings based on the conversion type andSpatialReferencesupplied by theUser. Optional parameters are available for some conversion types. Seefrom_geo_coordinate_stringsfor 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
SpatialReferenceobject 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_digitsvaries depending onconversion_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
GeometryJobobject 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.
- Returns:
A list of strings if future = False, a
GeometryJobobject 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"]
trim_extend
- arcgis.geometry.functions.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_extendfunction trims or extends eachPolylinespecified 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
Polylineis added to the output list if the corresponding input polyline is neither cut nor extended.Keys
Description
polylines
A list of
Polylineobjects to trim or extendtrim_extend_to
A
Polylineserving 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 extrapolatethe 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
SpatialReferenceobject or the well-known ID of the spatial reference of the input geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
A list of
Polylineobjects if future = False, or aGeometryJobobject if future = True.
union
- arcgis.geometry.functions.union(geometries: list[Polygon] | list[Polyline] | list[MultiPoint] | list[Point], spatial_ref: str | dict[str, str] | None = None, gis: GIS | None = None, future: bool = False)
The
unionfunction constructs the set-theoretic union of eachGeometryin the geometries list.Note
All inputs must be of the same type.
Keys
Description
geometries
Required list of
Point,MultiPoint,Polyline, orPolygonobjects.spatial_ref
A
SpatialReferenceobject or the well-known ID of the spatial reference of the input geometries.future
Optional boolean.
If True, a
GeometryJobobject 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.
- Returns:
If future = False, the set-theoretic union of the
Geometryobjects in the geometries argument, or if future = True, aGeometryJobobject.