arcrest.common package

Submodules

arcrest.common.domain module

This module contains the JSON domain objects. Domains specify the set of valid values for a field.

class arcrest.common.domain.CodedValueDomain(name)[source]

Bases: object

Coded value domain specifies an explicit set of valid values for a field. Each valid value is assigned a unique name. The type property for coded value domains is codedValue.

addCodedValue(name, code)[source]

adds a coded value to the domain

Inputs:
name - name of the domain code - value
codedValues

gets the coded values

name

gets/sets the domain name

removeCodedValue(name)[source]

removes a codedValue by name

type

gets the domain type

value

gets the value as a dictionary

class arcrest.common.domain.InheritedDomain[source]

Bases: object

Inherited domains apply to domains on subtypes. It implies that the domain for a field at the subtype level is the same as the domain for the field at the layer level.

type

gets the domain type

value

gets the value as a dictionary

class arcrest.common.domain.RangeDomain(name, minValue, maxValue)[source]

Bases: object

Range domain specifies a range of valid values for a field. The type property for range domains is range.

maxValue

gets/sets the max value

minValue

gets/sets the min value

name

gets/sets the domain name

type

gets the domain type

value

gets the value as a dictionary

arcrest.common.errorhandlers module

contains all error handlers for ArcREST

exception arcrest.common.errorhandlers.ArcRESTError[source]

Bases: exceptions.Exception

default type of error handler raised

arcrest.common.errorhandlers.trace()[source]

trace finds the line, the filename and error message and returns it to the user

arcrest.common.filters module

class arcrest.common.filters.GeometryFilter(geomObject, spatialFilter='esriSpatialRelIntersects', bufferDistance=None, units='esriSRUnit_Meter')[source]

Bases: arcrest._abstract.abstract.BaseFilter

creates a geometry filter for queries
Inputs:

geomObject - a common.Geometry or arcpy.Geometry object spatialFilter - The spatial relationship to be applied on the

input geometry while performing the query. The supported spatial relationships include intersects, contains, envelope intersects, within, etc. The default spatial relationship is intersects (esriSpatialRelIntersects).
bufferDistance - if filter type esriSpatialRelWithin is selected
and the service supports that select type, then the geometry will be buffered at a given. Can be of type integer or float.
units - the value the distance units represents. Valid values
are: “esriSRUnit_Meter”, “esriSRUnit_StatuteMile”,
“esriSRUnit_Foot”, “esriSRUnit_Kilometer”,
“esriSRUnit_NauticalMile”, and “esriSRUnit_USNauticalMile”
Raises:AttributeError for invalid inputs
filter

returns the key/value pair of a geometry filter

geometry

gets the geometry object used by the filter

geometryType

returns the geometry type

spatialRelation

gets the filter type

class arcrest.common.filters.LayerDefinitionFilter[source]

Bases: arcrest._abstract.abstract.BaseFilter

Allows you to filter the features of individual layers in the query by specifying definition expressions for those layers. A definition expression for a layer that is published with the service will always be honored.

addFilter(layer_id, where=None, outFields='*')[source]

adds a layer definition filter

filter

returns the filter object as a list of layer defs

removeAll()[source]

removes all items from the filter

removeFilter(filter_index)[source]

removes a layer filter based on position in filter list

class arcrest.common.filters.StatisticFilter[source]

Bases: arcrest._abstract.abstract.BaseFilter

The definitions for one or more field-based statistics to be calculated

add(statisticType, onStatisticField, outStatisticFieldName=None)[source]

Adds the statistics group to the filter.

outStatistics - is supported on only those layers/tables that
indicate supportsStatistics is true.
outStatisticFieldName is empty or missing, the map server assigns a
field name to the returned statistic field. A valid field name can only contain alphanumeric characters and an underscore.
outStatisticFieldName is a reserved keyword of the underlying DBMS,
the operation can fail. Try specifying an alternative outStatisticFieldName. When using outStatistics, the only other parameters that can be used are groupByFieldsForStatistics, orderByFields, time, and where.
clear()[source]

removes all the filters

filter

returns the key/value pair of a geometry filter

remove(index)[source]

removes the filter by index

class arcrest.common.filters.TimeFilter(start_time, time_zone='UTC', end_time=None)[source]

Bases: arcrest._abstract.abstract.BaseFilter

Implements the time filter

filter

arcrest.common.find module

class arcrest.common.find.search(url=None, securityHandler=None, proxy_url=None, proxy_port=None)[source]

Bases: arcrest.web._base.BaseWebOperations

findItem(title, itemType, username=None, searchorg=False)[source]

arcrest.common.general module

class arcrest.common.general.Feature(json_string, wkid=None)[source]

Bases: object

returns a feature

asDictionary

returns the feature as a dictionary

asRow

converts a feature to a list for insertion into an insert cursor Output:

[row items], [field names] returns a list of fields and the row object
static fc_to_features(dataset)[source]

converts a dataset to a list of feature objects Input:

dataset - path to table or feature class
Output:
list of feature objects
fields

returns a list of feature fields

geometry

returns the feature geometry

geometryType

returns the feature’s geometry type

get_value(field_name)[source]

returns a value for a given field name

set_value(field_name, value)[source]

sets an attribute value for a given field name

class arcrest.common.general.FeatureSet(fields, features, hasZ=False, hasM=False, geometryType=None, spatialReference=None, displayFieldName=None, objectIdFieldName=None, globalIdFieldName=None)[source]

Bases: object

This featureSet contains Feature objects, including the values for the fields requested by the user. For layers, if you request geometry information, the geometry of each feature is also returned in the featureSet. For tables, the featureSet does not include geometries. If a spatialReference is not specified at the featureSet level, the featureSet will assume the spatialReference of its first feature. If the spatialReference of the first feature is also not specified, the spatial reference will be UnknownCoordinateSystem.

displayFieldName

gets/sets the displayFieldName

features

gets the features in the FeatureSet

fields

gets the featureset’s fields

static fromJSON(jsonValue)[source]

returns a featureset from a JSON string

geometryType

gets/sets the geometry Type

globalIdFieldName

gets/sets the globalIdFieldName

hasM

gets/set the M-property

hasZ

gets/sets the Z-property

objectIdFieldName

gets/sets the object id field

save(saveLocation, outName)[source]

Saves a featureset object to a feature class Input:

saveLocation - output location of the data outName - name of the table the data will be saved to
spatialReference

gets the featureset’s spatial reference

toJSON

converts the object to JSON

value

returns object as dictionary

arcrest.common.general.local_time_to_online(dt=None)[source]

converts datetime object to a UTC timestamp for AGOL Inputs:

dt - datetime object
Output:
Long value
arcrest.common.general.online_time_to_string(value, timeFormat, utcOffset=0)[source]

Converts AGOL timestamp to formatted string.

Parameters:
  • value (float) – A UTC timestamp as reported by AGOL (time in ms since Unix epoch * 1000)
  • timeFormat (str) – Date/Time format string as parsed by datetime.strftime().
  • utcOffset (int) – Hours difference from UTC and desired output. Default is 0 (remain in UTC).
Returns:

A string representation of the timestamp.

Return type:

str

Examples

>>> rcrest.general.online_time_to_string(1457167261000.0, "%Y-%m-%d %H:%M:%S")
'2016-03-05 00:41:01'
>>> rcrest.general.online_time_to_string(731392515000.0, '%m/%d/%Y %H:%M:%S', -8) # PST is UTC-8:00
'03/05/1993 12:35:15'

See also

local_time_to_online() for converting a datetime.datetime object to AGOL timestamp

arcrest.common.general.timestamp_to_datetime(timestamp)[source]

Converts a timestamp to a datetime object Inputs:

timestamp - timestamp value as Long
output:
datetime object
class arcrest.common.general.MosaicRuleObject(mosaicMethod, where='', sortField='', sortValue='', ascending=True, lockRasterIds=[], viewpoint=None, fids=[], mosaicOperation=None, itemRenderingRule='')[source]

Bases: object

The image service uses a mosaic rule to mosaick multiple rasters on the fly. The mosaic rule parameter is used by many image service operations, for example, export image and identify operations.

ascending
fids
itemRenderingRule
lockRasterIds
mosaicMethod

get/set the mosaic method

mosaicOperation
sortField
sortValue
value

gets the mosaic rule object as a dictionary

viewpoint
where

Use where clause to define a subset of rasters used in the mosaic, be aware that the rasters may not be visible at all scales

arcrest.common.geometry module

class arcrest.common.geometry.Envelope(xmin, ymin, xmax, ymax, wkid=None, wkt=None, zmin=None, zmax=None, mmin=None, mmax=None)[source]

Bases: arcrest._abstract.abstract.AbstractGeometry

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.

asArcPyObject

returns the Envelope as an ESRI arcpy.Polygon object

asDictionary

returns the envelope as a dictionary

asJSON

returns a geometry as JSON

spatialReference

returns the geometry spatial reference

type

returns the geometry type

value

returns the envelope as a dictionary

class arcrest.common.geometry.MultiPoint(points, wkid=None, wkt=None, hasZ=False, hasM=False)[source]

Bases: arcrest._abstract.abstract.AbstractGeometry

Implements the ArcGIS JSON MultiPoint Geometry Object

asArcPyObject

returns the Point as an ESRI arcpy.MultiPoint object

asDictionary

returns the object as a python dictionary

asJSON

returns a geometry as JSON

spatialReference

returns the geometry spatial reference

type

returns the geometry type

class arcrest.common.geometry.Point(coord, wkid=None, wkt=None, z=None, m=None)[source]

Bases: arcrest._abstract.abstract.AbstractGeometry

Point Geometry Inputs:

coord - list of [X,Y] pair or arcpy.Point Object wkid - well know id of spatial references z - is the Z coordinate value m - m value
X

gets the X coordinate

Y

gets the Y Coordinate

Z

gets the Z Coordinate

asArcPyObject

returns the Point as an ESRI arcpy.Point object

asDictionary

returns the object as a python dictionary

asJSON

returns a geometry as JSON

asList

returns a Point value as a list of [x,y,<z>,<m>]

spatialReference

returns the geometry spatial reference

type

returns the geometry type

wkid

gets the wkid

wkt

get/set the wkt

class arcrest.common.geometry.Polygon(rings, wkid=None, wkt=None, hasZ=False, hasM=False)[source]

Bases: arcrest._abstract.abstract.AbstractGeometry

Implements the ArcGIS REST JSON for Polygon Object

asArcPyObject

returns the Polyline as an ESRI arcpy.Polyline object

asDictionary

returns the object as a python dictionary

asJSON

returns a geometry as JSON

spatialReference

returns the geometry spatial reference

type

returns the geometry type

class arcrest.common.geometry.Polyline(paths, wkid=None, wkt=None, hasZ=False, hasM=False)[source]

Bases: arcrest._abstract.abstract.AbstractGeometry

Implements the ArcGIS REST API Polyline Object Inputs:

paths - list - list of lists of Point objects wkid - integer - well know spatial reference id hasZ - boolean - hasM - boolean -
asArcPyObject

returns the Polyline as an ESRI arcpy.Polyline object

asDictionary

returns the object as a python dictionary

asJSON

returns a geometry as JSON

spatialReference

returns the geometry spatial reference

type

returns the geometry type

class arcrest.common.geometry.SpatialReference(wkid=None, wkt=None)[source]

Bases: arcrest._abstract.abstract.AbstractGeometry

creates a spatial reference instance

asDictionary

returns the wkid id for use in json calls

value

returns the wkid id for use in json calls

wkid

get/set the wkid

wkt

get/set the wkt

arcrest.common.renderer module

class arcrest.common.renderer.BaseRenderer[source]

Bases: object

base renderer object

class arcrest.common.renderer.ClassBreakRenderer(defaultSymbol, defaultLabel, field, classificationMethod, normalizationType=None, normalizationField=None, normalizationTotal=None, backgroundFillSymbol=None, minValue=None, rotationType='aritmetic', rotationExpression=None)[source]

Bases: arcrest.common.renderer.BaseRenderer

A simple renderer is a renderer that uses one symbol only

addClassBreak(classMinValue, classMaxValue, label, description, symbol)[source]

adds a classification break value to the renderer

classBreakInfos

gets the class breaks

classificationMethod

gets/sets the classificationMethod

defaultLabel

gets/sets the label

defaultSymbol

gets/sets the symbol

field

gets/sets the field

minValue

gets/sets the minValue

normalizationField

gets/sets the normalizationField

normalizationTotal

gets/sets the normalizationTotal

normalizationType

gets/sets the normalizationType

removeClassBreak(label)[source]

removes a classification break value to the renderer

rotationExpression

gets/sets the rotationExpression

rotationType

gets/sets the rotationType

type

gets the type

value

returns object as dictionary

class arcrest.common.renderer.SimpleRenderer(symbol, label=None, description=None, rotationType='aritmetic', rotationExpression=None)[source]

Bases: arcrest.common.renderer.BaseRenderer

A simple renderer is a renderer that uses one symbol only

description

gets/sets the description

label

gets/sets the label

rotationExpression

gets/sets the rotationExpression

rotationType

gets/sets the rotationType

symbol

gets/sets the symbol

type

gets the type

value

returns object as dictionary

class arcrest.common.renderer.UniqueValueRenderer(defaultSymbol, defaultLabel, field1, field2=None, field3=None, fieldDelimiter=None, rotationType='aritmetic', rotationExpression=None)[source]

Bases: arcrest.common.renderer.BaseRenderer

A simple renderer is a renderer that uses one symbol only

addUniqueValue(value, label, description, symbol)[source]

adds a unique value to the renderer

defaultLabel

gets/sets the label

defaultSymbol

gets/sets the symbol

field1

gets/sets the field1

field2

gets/sets the field2

field3

gets/sets the field3

fieldDelimiter

gets/sets the fieldDelimiter

removeUniqueValue(value)[source]

removes a unique value in unique Value Info

rotationExpression

gets/sets the rotationExpression

rotationType

gets/sets the rotationType

type

gets the type

uniqueValueInfos

gets the uniqueValueInfos

value

returns object as dictionary

arcrest.common.servicedef module

arcrest.common.servicedef.MXDtoFeatureServiceDef(mxd_path, service_name=None, tags=None, description=None, folder_name=None, capabilities='Query, Create, Update, Delete, Uploads, Editing, Sync', maxRecordCount=1000, server_type='MY_HOSTED_SERVICES', url='http://www.arcgis.com')[source]

arcrest.common.spatial module

Contains all the spatial functions

arcrest.common.spatial.create_feature_class(out_path, out_name, geom_type, wkid, fields, objectIdField)[source]

creates a feature class in a given gdb or folder

arcrest.common.spatial.create_feature_layer(ds, sql, name='layer')[source]

creates a feature layer object

arcrest.common.spatial.featureclass_to_json(fc)[source]

converts a feature class to JSON

arcrest.common.spatial.getDateFields(fc)[source]

Returns a list of fields that are of type DATE Input:

fc - feature class or table path
Output:
List of date field names as strings
arcrest.common.spatial.get_OID_field(fs)[source]

returns a featureset’s object id field

arcrest.common.spatial.get_attachment_data(attachmentTable, sql, nameField='ATT_NAME', blobField='DATA', contentTypeField='CONTENT_TYPE', rel_object_field='REL_OBJECTID')[source]

gets all the data to pass to a feature service

arcrest.common.spatial.get_records_with_attachments(attachment_table, rel_object_field='REL_OBJECTID')[source]
arcrest.common.spatial.insert_rows(fc, features, fields, includeOIDField=False, oidField=None)[source]

inserts rows based on a list features object

arcrest.common.spatial.json_to_featureclass(json_file, out_fc)[source]

converts a json file (.json) to a feature class

arcrest.common.spatial.lookUpFieldType(field_type)[source]

Converts the ArcGIS REST field types to Python Types Input:

field_type - string - type of field as string
Output:
Python field type as string
arcrest.common.spatial.lookUpGeometry(geom_type)[source]

converts ArcRest API geometry name to Python names Input:

geom_type - string - name of geometry
Output:
name of python geometry type for create feature class function
arcrest.common.spatial.merge_feature_class(merges, out_fc, cleanUp=True)[source]

merges featureclass into a single feature class

arcrest.common.spatial.recordset_to_json(table)[source]

converts the table to JSON

arcrest.common.spatial.scratchFolder()[source]

returns the scratch foldre

arcrest.common.spatial.scratchGDB()[source]

returns the arcpy scratch file geodatabase

arcrest.common.spatial.table_to_json(table)[source]

returns a table as JSON

arcrest.common.spatial.toDateTime(unix_timestamp)[source]

converts a unix time stamp to a datetime object

arcrest.common.symbology module

class arcrest.common.symbology.BaseSymbol[source]

Bases: object

base symbol class

class arcrest.common.symbology.Color(red, green, blue, alpha=255)[source]

Bases: object

Color is represented as a four-element array. The four elements represent values for red, green, blue, and alpha in that order. Values range from 0 through 255. If color is undefined for a symbol, the color value is null.

alpha

gets/sets the alpha value

blue

gets/sets the blue value

green

gets/sets the green value

red

gets/sets the red value

value

gets the color value

class arcrest.common.symbology.SimpleFillSymbol(style, color, outline=None)[source]

Bases: arcrest.common.symbology.BaseSymbol

Simple fill symbols can be used to symbolize polygon geometries. The type property for simple fill symbols is esriSFS.

color

gets/sets the color

style

gets/sets the style

type

gets the type

value

gets the color value

class arcrest.common.symbology.SimpleLineSymbol(style, color, width=1)[source]

Bases: arcrest.common.symbology.BaseSymbol

Simple line symbols can be used to symbolize polyline geometries or outlines for polygon fills. The type property for simple line symbols is esriSLS.

color

gets/sets the color

value

gets the color value

width

gets/sets the width

class arcrest.common.symbology.SimpleMarkerSymbol(style, color, size, angle=0, xoffset=0, yoffset=0, outlineColor=None, outlineWidth=1)[source]

Bases: arcrest.common.symbology.BaseSymbol

Simple marker symbols can be used to symbolize point geometries. The type property for simple marker symbols is esriSMS. The angle property defines the number of degrees (0 to 360) that a marker symbol is rotated. The rotation is from East in a counter-clockwise direction where East is the 0 degrees axis.

angle

gets/sets the angle

color

gets/sets the color

outlineColor

gets/sets the outlineColor

outlineWidth

gets/sets the outlineWidth

size

gets/sets the size

style

gets/sets the style

type

gets the type

value

returns the object as dictionary

xoffset

gets/sets the xoffset

yoffset

gets/sets the yoffset

Module contents