arcgis.geometry module

The arcgis.geometry module defines useful geometry types for working with geographic information and GIS functionality. It provides functions which use geometric types as input and output as well as functions for easily 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.

Example:

pt = Point({"x" : -118.15, "y" : 33.80, "spatialReference" : {"wkid" : 4326}})
print (pt.is_valid)
print (pt.type) # POINT
print (pt)
print (pt.x, pt.y)

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)
print(polyline.is_valid)

Example of 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)
print(polyline.is_valid) # False

The same pattern can be used repeated for Polygon, MultiPoint and SpatialReference.

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:

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

Point

class arcgis.geometry.Point(iterable=None, **kwargs)

A point 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.

type

MultiPoint

class arcgis.geometry.MultiPoint(iterable=None, **kwargs)

A multipoint contains an array of points, 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. 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. An empty multipoint has a points field with no elements. Empty points are ignored.

type

Polyline

class arcgis.geometry.Polyline(iterable=None, **kwargs)

A 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 points, and each point in the path is represented as an array of numbers. A polyline can also have boolean-valued hasM and hasZ fields. See the description of multipoints 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/polygons is a syntax error.

type

Polygon

class arcgis.geometry.Polygon(iterable=None, **kwargs)

A 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 points. 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. Nulls and/or NaNs embedded in an otherwise defined coordinate stream for polylines/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.

type

Envelope

class arcgis.geometry.Envelope(iterable=None, **kwargs)

An envelope is 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. An empty envelope has no in space and is defined by the presence of an xmin field a null value or a “NaN” string.

type

SpatialReference

class arcgis.geometry.SpatialReference(iterable=None, **kwargs)

A spatial reference 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. The xy 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 spatial reference 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. 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. Starting at 10.3, Image Service supports image coordinate systems.

type

Geometry

class arcgis.geometry.Geometry(iterable=None, **kwargs)

The base class for all geometries.

You can create a Geometry even when you don’t know the exact type. The Geometry constructor is able to figure out the geometry type and returns the correct type as the example below demonstrates:

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

areas_and_lengths

geometry.areas_and_lengths(polygons, length_unit, area_unit, calculation_type, spatial_ref=4326, gis=None)

The areas_and_lengths function calculates areas and perimeter lengths for each polygon specified in the input array.

Inputs:
polygons - The array of polygons 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 length_unit can be any esriUnits constant. If lengthUnit is not specified, the units are derived from spatial_ref. If calculationType is not planar, then lengthUnit must be a linear esriUnits constant, such as esriSRUnit_Meter or esriSRUnit_SurveyMile. If length_unit is not specified, the units are meters. For a list of valid units, see esriSRUnitType Constants and esriSRUnit2Type Constant.
area_unit - The area unit in which areas of polygons will be
calculated. If calculation_type is planar, then area_unit can be any esriUnits constant. If area_unit is not specified, the units are derived from spatial_ref. If calculation_type is not planar, then area_unit must be a linear esriUnits constant such as esriSRUnit_Meter or esriSRUnit_SurveyMile. If area_unit is not specified, then the units are meters. For a list of valid units, see esriSRUnitType Constants and esriSRUnit2Type constant. The list of valid esriAreaUnits constants include, esriSquareInches | esriSquareFeet | esriSquareYards | esriAcres | esriSquareMiles | esriSquareMillimeters | esriSquareCentimeters | esriSquareDecimeters | esriSquareMeters | esriAres | esriHectares | esriSquareKilometers.
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. Th- should only be used if the area or length needs to be calculated in the given spatial reference. 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 the polygon. 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.
Output:
JSON as dictionary

auto_complete

geometry.auto_complete(polygons=None, polylines=None, spatial_ref=None, gis=None)

The auto_complete function simplifies the process of constructing new polygons that are adjacent to other polygons. It constructs polygons that fill in the gaps between existing polygons and a set of polylines.

Inputs:
polygons - array of Polygon objects polylines - list of Polyline objects spatial_ref - spatial reference of the input geometries WKID

buffer

geometry.buffer(geometries, in_sr, distances, unit, out_sr=None, buffer_sr=None, union_results=True, geodesic=True, gis=None)

The buffer function is performed on a geometry service resource The result of this function is buffered polygons at the specified distances for the input geometry array. Options are available to union buffers and to use geodesic distance.

Inputs:

geometries - The array of geometries to be buffered. is_sr - The well-known ID of the spatial reference or a spatial

reference JSON object for the input geometries.
distances - The distances that each of the input geometries is
buffered.
unit - The units for calculating each buffer distance. If unit
is not specified, the units are derived from bufferSR. If bufferSR is not specified, the units are derived from in_sr.
out_sr - The well-known ID of the spatial reference or a
spatial reference JSON object for the input geometries.
buffer_sr - The well-known ID of the spatial reference or a
spatial reference JSON object for the input geometries.
union_results - If true, all geometries buffered at a given
distance are unioned into a single (gis,possibly multipart) polygon, and the unioned geometry is placed in the output array. The default is false
geodesic - Set geodesic to true to buffer the input geometries
using geodesic distance. Geodesic distance is the shortest path between two points along the ellipsoid of the earth. If geodesic is set to false, the 2D Euclidean distance is used to buffer the input geometries. The default value depends on the geometry type, unit and bufferSR.

convex_hull

geometry.convex_hull(geometries, spatial_ref=None, gis=None)

The convex_hull function is performed on a geometry service resource. It returns the convex hull of the input geometry. The input geometry can be a point, multipoint, polyline, or polygon. The convex hull is typically a polygon but can also be a polyline or point in degenerate cases.

Inputs:

geometries - The geometries whose convex hull is to be created. spatial_ref - The well-known ID or a spatial reference JSON object for

the output geometry.

cut

geometry.cut(cutter, target, spatial_ref=None, gis=None)

The cut function is performed on a geometry service resource. This function splits the target polyline or polygon where it’s crossed by the cutter polyline. At 10.1 and later, this function calls simplify on the input cutter and target geometries.

Inputs:
cutter - The polyline that will be used to divide the target
into pieces where it crosses the target.The spatial reference of the polylines is specified by spatial_ref. The structure of the polyline is the same as the structure of the JSON polyline objects returned by the ArcGIS REST API.
target - The array of polylines/polygons to be cut. The
structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API. The spatial reference of the target geometry array is specified by spatial_ref.
spatial_ref - The well-known ID or a spatial reference JSON object for
the output geometry.

density

difference

geometry.difference(geometries, spatial_ref, geometry, gis=None)

The difference function is performed on a geometry service resource. This function constructs the set-theoretic difference between each element of an array of geometries and another geometry the so-called difference geometry. In other words, let B be the difference geometry. For each geometry, A, in the input geometry array, it constructs A-B.

Inputs:
geometries - An array of points, multipoints, polylines or
polygons. 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.
geometry - A single geometry of any type and of a dimension equal
to or greater than the elements of geometries. The structure of geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API. The use of simple syntax is not supported.
spatial_ref - The well-known ID of the spatial reference or a spatial
reference JSON object for the input geometries.

distance

geometry.distance(spatial_ref, geometry1, geometry2, distance_unit='', geodesic=False, gis=None)

The distance function is performed on a geometry service resource. It reports the 2D Euclidean or geodesic distance between the two geometries.

Inputs:
spatial_ref - The well-known ID or a spatial reference JSON object for
input geometries.
geometry1 - The geometry from which the distance is to be
measured. The structure of the geometry is same as the structure of the JSON geometry objects returned by the ArcGIS REST API.
geometry2 - The geometry from which the distance is to be
measured. The structure of the geometry is same as the structure of the JSON geometry objects returned by the ArcGIS REST API.
distanceUnit - specifies the units for measuring distance between
the geometry1 and geometry2 geometries.
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.

find_transformation

geometry.find_transformation(in_sr, out_sr, extent_of_interest=None, num_of_results=1, gis=None)

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 spatial reference to the output spatial reference. 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. 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.

Inputs:
in_sr - The well-known ID (gis,WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
out_sr - The well-known ID (gis,WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
extent_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. If a spatial reference 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. If num_of_results has a value of -1, all applicable transformations are returned.

from_geo_coordinate_string

geometry.from_geo_coordinate_string(spatial_ref, strings, conversion_type, conversion_mode=None, gis=None)

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 spatial reference supplied by the user. An optional conversion mode parameter is available for some conversion types.

Inputs:
spatial_ref - The well-known ID of the spatial reference or a spatial
reference json object.
strings - An array of strings formatted as specified by

conversion_type. Syntax: [<string1>,...,<stringN>] Example: [“01N AA 66021 00000”,”11S NT 00000 62155”,

“31U BT 94071 65288”]
conversion_type - The conversion type of the input strings.
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. Conversion options for MGRS and UTM conversion types. 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
180 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.
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

generalize

geometry.generalize(spatial_ref, geometries, max_deviation, deviation_unit, gis=None)

The generalize function is performed on a geometry service resource. The generalize function simplifies the input geometries using the Douglas-Peucker algorithm with a specified maximum deviation distance. The output geometries will contain a subset of the original input vertices.

Inputs:
spatial_ref - The well-known ID or a spatial reference JSON object for the
input geometries.

geometries - The array of geometries to be generalized. max_deviation - max_deviation sets the maximum allowable offset,

which will determine the degree of simplification. This value limits the distance the output geometry can differ from the input geometry.
deviation_unit - A unit for maximum deviation. If a unit is not
specified, the units are derived from spatial_ref.

intersect

geometry.intersect(spatial_ref, geometries, geometry, gis=None)

The intersect function is performed on a geometry service resource. This function constructs the set-theoretic intersection between an array of geometries and another geometry. The dimension of each resultant geometry is the minimum dimension of the input geometry in the geometries array and the other geometry specified by the geometry parameter.

Inputs:
spatial_ref - The well-known ID or a spatial reference JSON object for the
input geometries.
geometries - An array of points, multipoints, polylines, or
polygons. 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.
geometry - A single geometry of any type with a dimension equal to
or greater than the elements of geometries.

label_points

geometry.label_points(spatial_ref, polygons, gis=None)

The label_points function is performed on a geometry service resource. The labelPoints function calculates an interior point for each polygon specified in the input array. These interior points can be used by clients for labeling the polygons.

Inputs:
spatial_ref - The well-known ID of the spatial reference or a spatial
reference JSON object for the input polygons.
polygons - The array of polygons whose label points are to be
computed. The spatial reference of the polygons is specified by spatial_ref.

lengths

geometry.lengths(spatial_ref, polylines, length_unit, calculation_type, gis=None)

The lengths function is performed on a geometry service resource. This function calculates the 2D Euclidean or geodesic lengths of each polyline specified in the input array.

Inputs:
spatial_ref - The well-known ID of the spatial reference or a spatial
reference JSON object for the input polylines.
polylines - The array of polylines whose lengths are to be
computed.
length_unit - The unit in which lengths of polylines will be
calculated. If calculation_type is planar, then length_unit can be any esriUnits constant. If calculation_type is planar and length_unit is not specified, then the units are derived from spatial_ref. If calculation_type is not planar, then length_unit must be a linear esriUnits constant such as esriSRUnit_Meter or esriSRUnit_SurveyMile. If calculation_type is not planar and length_unit is not specified, then the units are meters.
calculation_type - calculation_type defines the length calculation
for the geometry. The type can be one of the following values:
planar - Planar measurements use 2D Euclidean distance to
calculate length. This type should only be used if the length needs to be calculated in the given spatial reference. Otherwise, use preserveShape.
geodesic - Use this type if you want to calculate a length
using only the vertices of the polygon and define the lines between the vertices as geodesic segments independent of the actual shape of the polyline. A geodesic segment is the shortest path between two points on an earth ellipsoid.
preserveShape - This type calculates the length of the geometry
on the surface of the earth ellipsoid. The shape of the geometry in its coordinate system is preserved.

offset

geometry.offset(geometries, offset_distance, offset_unit, offset_how='esriGeometryOffsetRounded', bevel_ratio=10, simplify_result=False, spatial_ref=None, gis=None)

The offset function is performed on a geometry service resource. This function constructs geometries that are offset from the given input geometries. If the offset parameter is positive, the constructed offset will be on the right side of the geometry. Left side offsets are constructed with negative parameters. 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, it is simple to infer where the offset of even horizontal geometries will be constructed.

Inputs:

geometries - The array of geometries to be offset. offset_distance - Specifies the distance for constructing an offset

based on the input geometries. If the offset_distance parameter is positive, the constructed offset will be on the right side of the curve. Left-side offsets are constructed with negative values.
offset_unit - A unit for offset distance. If a unit is not
specified, the units are derived from spatial_ref.
offset_how - The offset_how parameter 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 - bevel_ratio is multiplied by the offset distance, and
the result determines how far a mitered offset intersection can be located before it is bevelled. When mitered is specified, bevel_ratio is ignored and 10 is used internally. When bevelled is specified, 1.1 will be used if bevel_ratio is not specified. bevel_ratio is ignored for rounded offset.
simplify_result - if simplify_result is set to true, then self
intersecting loops will be removed from the result offset geometries. The default is false.
spatial_ref - The well-known ID or a spatial reference JSON object for the
input geometries.

project

geometry.project(geometries, in_sr, out_sr, transformation='', transform_foward=False, gis=None)

The project function is performed on a geometry service resource. This function projects an array of input geometries from the input spatial reference to the output spatial reference.

Inputs:

geometries - The array of geometries to be projected. in_sr - The well-known ID (gis,WKID) of the spatial reference or a

spatial reference JSON object for the input geometries.
out_sr - The well-known ID (gis,WKID) of the spatial reference or a
spatial reference JSON object for the input geometries.
transformation - The WKID or a JSON object specifying the
geographic transformation (gis,also known as datum transformation) to be applied to the projected geometries. Note that a transformation is needed only if the output spatial reference contains a different geographic coordinate system than the input spatial reference.
transform_forward - A Boolean value indicating whether or not to
transform forward. The forward or reverse direction of transformation is implied in the name of the transformation. If transformation is specified, a value for the transformForward parameter must also be specified. The default value is false.

relation

geometry.relation(geometries1, geometries2, spatial_ref, spatial_relation='esriGeometryRelationIntersection', relation_param='', gis=None)

The relation function is performed on a geometry service resource. This function determines the pairs of geometries from the input geometry arrays that participate in the specified spatial relation. Both arrays are assumed to be in the spatial reference specified by spatial_ref, which is a required parameter. Geometry types cannot be mixed within an array. The relations are evaluated in 2D. In other words, z coordinates are not used.

Inputs:
geometries1 - The first array of geometries used to compute the
relations.

geometries2 -The second array of geometries used to compute the relations. spatial_ref - The well-known ID of the spatial reference or a spatial

reference JSON object for the input geometries.
spatial_relation - The spatial relationship to be tested between the two
input geometry arrays. Values: esriGeometryRelationCross | esriGeometryRelationDisjoint | esriGeometryRelationIn | esriGeometryRelationInteriorIntersection | esriGeometryRelationIntersection | esriGeometryRelationLineCoincidence | esriGeometryRelationLineTouch | esriGeometryRelationOverlap | esriGeometryRelationPointTouch | esriGeometryRelationTouch | esriGeometryRelationWithin | esriGeometryRelationRelation
relation_param - The Shape Comparison Language string to be
evaluated.

reshape

geometry.reshape(spatial_ref, target, reshaper, gis=None)

The reshape function is performed on a geometry service resource. It reshapes a polyline or polygon feature by constructing a polyline over the feature. The feature takes the shape of the reshaper polyline from the first place the reshaper intersects the feature to the last.

Input:
spatial_ref - The well-known ID of the spatial reference or a spatial
reference JSON object for the input geometries.

target - The polyline or polygon to be reshaped. reshaper - The single-part polyline that does the reshaping.

to_geo_coordinate_string

geometry.to_geo_coordinate_string(spatial_ref, coordinates, conversion_type, conversion_mode='mgrsDefault', num_of_digits=None, rounding=True, add_spaces=True, gis=None)

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 spatial reference supplied by the user. Optional parameters are available for some conversion types. Note that 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.

Inputs:
spatial_ref - The well-known ID of the spatial reference or a spatial
reference json object.
coordinates - An array of xy-coordinates in JSON format to be
converted. Syntax: [[x1,y2],...[xN,yN]]
conversion_type - The conversion type of the input strings.
Allowed Values:
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. 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
180 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.
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.
rounding - If true, then numeric portions of the string are
rounded to the nearest whole magnitude as specified by numOfDigits. Otherwise, numeric portions of the string are truncated. The rounding parameter applies only to conversion types MGRS, USNG and GeoRef. The default value is true.
addSpaces - If true, then spaces are added between components of
the string. The addSpaces parameter applies only 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.

trim_extend

geometry.trim_extend(spatial_ref, polylines, trim_extend_to, extend_how=0, gis=None)

The trim_extend function is performed on a geometry service resource. This function trims or extends each polyline specified in the input array, using the user-specified guide polylines. 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 array if the corresponding input polyline is neither cut nor extended.

Inputs:
spatial_ref - The well-known ID of the spatial reference or a spatial
reference json object.

polylines - An array of polylines to be trimmed or extended. trim_extend_to - A polyline that is used as a 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.

union

geometry.union(spatial_ref, geometries, gis=None)

The union function is performed on a geometry service resource. This function constructs the set-theoretic union of the geometries in the input array. All inputs must be of the same type.

Inputs: spatial_ref - The well-known ID of the spatial reference or a spatial

reference json object.

geometries - The array of geometries to be unioned.