# arcgis.raster.analytics module¶

Functions for calling the Raster Analysis Tools. The RasterAnalysisTools service is used by ArcGIS Server to provide distributed raster analysis.

## get_datastores¶

analytics.get_datastores()

Returns a helper object to manage raster analytics datastores in the GIS. If a gis isn’t specified, returns datastore manager of arcgis.env.active_gis

## is_supported¶

analytics.is_supported()

Returns True if the GIS supports raster analytics. If a gis isn’t specified, checks if arcgis.env.active_gis supports raster analytics

## generate_raster¶

analytics.generate_raster(function_arguments=None, output_raster_properties=None, output_name=None, gis=None)

raster_function : Required, see http://resources.arcgis.com/en/help/rest/apiref/israsterfunctions.html

function_arguments : Optional, for specifying input Raster alone, portal Item can be passed

output_raster_properties : Optional

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead.

Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool.

A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_raster : Image layer item

## interpolate_points¶

analytics.interpolate_points(interpolate_field, optimize_for='BALANCE', transform_data=False, size_of_local_models=None, number_of_neighbors=None, output_cell_size=None, output_prediction_error=False, output_name=None, gis=None)

This tool allows you to predict values at new locations based on measurements from a collection of points. The tool takes point data with values at each point and returns a raster of predicted values:

• An air quality management district has sensors that measure pollution levels. Interpolate Points can be used to

predict pollution levels at locations that don’t have sensors, such as locations with at-risk populations- schools or hospitals, for example.

• Predict heavy metal concentrations in crops based on samples taken from individual plants.

• Predict soil nutrient levels (nitrogen, phosphorus, potassium, and so on) and other indicators (such as electrical

conductivity) in order to study their relationships to crop yield and prescribe precise amounts of fertilizer for each location in the field.

• Meteorological applications include prediction of temperatures, rainfall, and associated variables (such as acid

rain).

input_point_featuresRequired point layer containing locations with known values

The point layer that contains the points where the values have been measured.

interpolate_fieldRequired string - field to interpolate

Choose the field whose values you wish to interpolate. The field must be numeric.

optimize_forOptional string - Choose your preference for speed versus accuracy.

More accurate predictions take longer to calculate. This parameter alters the default values of several other parameters of Interpolate Points in order to optimize speed of calculation, accuracy of results, or a balance of the two. By default, the tool will optimize for balance. One of the following: [‘SPEED’, ‘BALANCE’, ‘ACCURACY’]

transform_dataOptional bool - Choose whether to transform your data to the normal distribution.

Interpolation is most accurate for data that follows a normal (bell-shaped) distribution. If your data does not appear to be normally distributed, you should perform a transformation.

size_of_local_modelsOptional int - Size of local models

Interpolate Points works by building local interpolation models that are mixed together to create the final prediction map. This parameter controls how many points will be contained in each local model. Smaller values will make results more local and can reveal small-scale effects, but it may introduce some instability in the calculations. Larger values will be more stable, but some local effects may be missed. The value can range from 30 to 500, but typical values are between 50 and 200.

number_of_neighborsOptional int - Number of Neighbors

Predictions are calculated based on neighboring points. This parameter controls how many points will be used in the calculation. Using a larger number of neighbors will generally produce more accurate results, but the results take longer to calculate. This value can range from 1 to 64, but typical values are between 5 and 15.

output_cell_sizeOptional LinearUnit - Output cell size

Enter the cell size and unit for the output rasters. The available units are Feet, Miles, Meters, and Kilometers.

output_prediction_errorOptional bool - Output prediction error

Choose whether you want to create a raster of standard errors for the predicted values. Standard errors are useful because they provide information about the reliability of the predicted values. A simple rule of thumb is that the true value will fall within two standard errors of the predicted value 95 percent of the time. For example, suppose a new location gets a predicted value of 50 with a standard error of 5. This means that this tool’s best guess is that the true value at that location is 50, but it reasonably could be as low as 40 or as high as 60. To calculate this range of reasonable values, multiply the standard error by 2, add this value to the predicted value to get the upper end of the range, and subtract it from the predicted value to get the lower end of the range.

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

dict with the following keys:

“output_raster” : layer “output_error_raster” : layer “process_info” : layer

## create_viewshed¶

analytics.create_viewshed(input_observer_features, optimize_for=None, maximum_viewing_distance=None, maximum_viewing_distance_field=None, minimum_viewing_distance=None, minimum_viewing_distance_field=None, viewing_distance_is_3d=None, observers_elevation=None, observers_elevation_field=None, observers_height=None, observers_height_field=None, target_height=None, target_height_field=None, above_ground_level_output_name=None, output_name=None, gis=None)

Compute visibility for an input elevation raster using geodesic method.

input_elevation_surface : Required string

input_observer_features : Required FeatureSet

optimize_forOptional string

One of the following: [‘SPEED’, ‘ACCURACY’]

maximum_viewing_distance : Optional LinearUnit

maximum_viewing_distance_field : Optional string

minimum_viewing_distance : Optional LinearUnit

minimum_viewing_distance_field : Optional string

viewing_distance_is_3d : Optional bool

observers_elevation : Optional LinearUnit

observers_elevation_field : Optional string

observers_height : Optional LinearUnit

observers_height_field : Optional string

target_height : Optional LinearUnit

target_height_field : Optional string

above_ground_level_output_name : Optional string

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

dict with the following keys:

“output_raster” : layer “output_above_ground_level_raster” : layer

## summarize_raster_within¶

analytics.summarize_raster_within(input_raster_layer_to_summarize, zone_field='Value', statistic_type='Mean', ignore_missing_values=True, output_name=None, gis=None)
input_zone_layerRequired layer - area layer to summarize a raster layer within defined boundaries.

The layer that defines the boundaries of the areas, or zones, that will be summarized. The layer can be a raster or feature data. For rasters, the zones are defined by all locations in the input that have the same cell value. The areas do not have to be contiguous.

input_raster_layer_to_summarizeRequired - raster layer to summarize.

The raster cells in this layer will be summarized by the areas (zones) that they fall within.

zone_fieldRequired string - field to define the boundaries. This is the attribute of the layer that will be used

to define the boundaries of the areas. For example, suppose the first input layer defines the management unit boundaries, with attributes that define the region, the district, and the parcel ID of each unit. You also have a raster layer defining a biodiversity index for each location. With the field you select, you can decide to calculate the average biodiversity at local, district, or regional levels.

statistic_typeOptional string - statistic to calculate.

You can calculate statistics of any numerical attribute of the points, lines, or areas within the input area layer. The available statistics types when the selected field is integer are Mean, Maximum, Median, Minimum, Minority, Range, Standard deviation(STD), Sum, and Variety. If the field is floating point, the options are Mean, Maximum, Minimum, Range, Standard deviation, and Sum. One of the following: [‘Mean’, ‘Majority’, ‘Maximum’, ‘Median’, ‘Minimum’, ‘Minority’, ‘Range’, ‘STD’, ‘SUM’, ‘Variety’]

ignore_missing_valuesOptional bool.

If you choose to ignore missing values, only the cells that have a value in the layer to be summarized will be used in determining the output value for that area. Otherwise, if there are missing values anywhere in an area, it is deemed that there is insufficient information to perform statistical calculations for all the cells in that zone, and that area will receive a null (NoData) value in the output.

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_raster : Image layer item

## calculate_density¶

analytics.calculate_density(count_field=None, search_distance=None, output_area_units=None, output_cell_size=None, output_name=None, gis=None)

Density analysis takes known quantities of some phenomenon and creates a density map by spreading these quantities across the map. You can use this tool, for example, to show concentrations of lightning strikes or tornadoes, access to health care facilities, and population densities.

This tool creates a density map from point or line features by spreading known quantities of some phenomenon (represented as attributes of the points or lines) across the map. The result is a layer of areas classified from least dense to most dense.

For point input, each point should represent the location of some event or incident, and the result layer represents a count of the incident per unit area. A larger density value in a new location means that there are more points near that location. In many cases, the result layer can be interpreted as a risk surface for future events. For example, if the input points represent locations of lightning strikes, the result layer can be interpreted as a risk surface for future lightning strikes.

For line input, the line density surface represents the total amount of line that is near each location. The units of the calculated density values are the length of line-per-unit area. For example, if the lines represent rivers, the result layer will represent the total length of rivers that are within the search radius. This result can be used to identify areas that are hospitable to grazing animals.

Other use cases of this tool include the following:

• Creating crime density maps to help police departments properly allocate resources to high crime areas.

• Calculating densities of hospitals within a county. The result layer will show areas with high and low accessibility to hospitals, and this information can be used to decide where new hospitals should be built.

• Identifying areas that are at high risk of forest fires based on historical locations of forest fires.

• Locating communities that are far from major highways in order to plan where new roads should be constructed.

input_point_or_line_featuresRequired feature layer - The input point or line layer that will be used to calculate

the density layer.

count_fieldOptional string - count field

Provide a field specifying the number of incidents at each location. For example, if you have points that represent cities, you can use a field representing the population of the city as the count field, and the resulting population density layer will calculate larger population densities near cities with larger populations. If the default choice of None is used, then each location will be assumed to represent a single count.

search_distanceOptional LinearUnit - Search distance

Enter a distance specifying how far to search to find point or line features when calculating density values. For example, if you provide a search distance of 10,000 meters, the density of any location in the output layer is calculated based on features that are within 10,000 meters of the location. Any location that does not have any incidents within 10,000 meters will receive a density value of zero. If no distance is provided, a default will be calculated that is based on the locations of the input features and the values in the count field (if a count field is provided).

output_area_unitsOptional string - Output area units

Specify the output area unit. Density is count divided by area, and this parameter specifies the unit of the area in the density calculation. The available areal units are Square Miles and Square Kilometers.

output_cell_sizeOptional LinearUnit - Output cell size

Enter the cell size and unit for the output rasters.

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_raster : Image layer item

## classify¶

analytics.classify(input_classifier_definition, additional_input_raster=None, output_name=None, gis=None)

input_raster : Required string

input_classifier_definition : Required string

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_raster : Image layer item

## segment¶

analytics.segment(spectral_detail='15.5', spatial_detail='15', minimum_segment_size_in_pixels='20', band_indexes='0, 1, 2', remove_tiling_artifacts='false', output_name=None, gis=None)

input_raster : Required string

spectral_detail : Required string

spatial_detail : Required string

minimum_segment_size_in_pixels : Required string

band_indexes : Required string

remove_tiling_artifacts : Required string

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_raster : Image layer item

## train_classifier¶

analytics.train_classifier(input_training_sample_json, classifier_parameters, segmented_raster=None, segment_attributes='COLOR;MEAN', gis=None)

input_raster : Required string

input_training_sample_json : Required string

segmented_raster : Optional string

classifier_parameters : Required string

segment_attributes : Required string

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_classifier_definition

## convert_feature_to_raster¶

analytics.convert_feature_to_raster(output_cell_size, value_field=None, output_name=None, gis=None)

Creates a new raster dataset from an existing feature dataset. Any feature class containing point, line, or polygon features can be converted to a raster dataset. The cell center is used to decide the value of the output raster pixel. The input field type determines the type of output raster. If the field is integer, the output raster will be integer; if it is floating point, the output will be floating point.

input_feature : Required. The input feature layer to convert to a raster dataset.

output_cell_sizeRequired LinearUnit. The cell size and unit for the output rasters.

The available units are Feet, Miles, Meters, and Kilometers. eg - {“distance”:60,”units”:meters}

value_field : Optional string. The field that will be used to assign values to the output raster.

output_nameOptional. The name of the layer that will be created in My Content.

If not provided, an Image Service is created by the method and used as the output raster. You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_raster : Image layer item

## convert_raster_to_feature¶

analytics.convert_raster_to_feature(field='Value', output_type='Polygon', simplify=True, output_name=None, gis=None)

This service tool converts imagery data to feature class vector data.

input_raster : Required. The input raster that will be converted to a feature dataset.

fieldOptional string - field that specifies which value will be used for the conversion.

It can be any integer or a string field. A field containing floating-point values can only be used if the output is to a point dataset. Default is “Value”

output_typeOptional string

One of the following: [‘Point’, ‘Line’, ‘Polygon’]

simplifyOptional bool, This option that specifies how the features should be smoothed. It is

only available for line and polygon output. True, then the features will be smoothed out. This is the default. if False, then The features will follow exactly the cell boundaries of the raster dataset.

output_nameOptional. If not provided, an Feature layer is created by the method and used as the output .

You can pass in an existing Feature Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Feature Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_features : Image layer item

## copy_raster¶

analytics.copy_raster(output_cellsize=None, resampling_method='NEAREST', clip_setting=None, output_name=None, gis=None)

input_raster : Required string

output_cellsize : Optional string

resampling_methodOptional string

One of the following: [‘NEAREST’, ‘BILINEAR’, ‘CUBIC’, ‘MAJORITY’]

clip_setting : Optional string

output_nameOptional. If not provided, an Image Service is created by the method and used as the output raster.

You can pass in an existing Image Service Item from your GIS to use that instead. Alternatively, you can pass in the name of the output Image Service that should be created by this method to be used as the output for the tool. A RuntimeError is raised if a service by that name already exists

gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.

output_raster : Image layer item

## create_image_collection¶

analytics.create_image_collection(input_rasters, raster_type_name, raster_type_params=None, out_sr=None, context=None, gis=None)

Create a collection of images that will participate in the ortho-mapping project. Provides provision to use input rasters by reference and to specify image collection properties through context parameter.

Returns

The imagery layer item

analytics.add_image(input_rasters, raster_type_name=None, raster_type_params=None, context=None, gis=None)

Add a collection of images to an existing image_collection. Provides provision to use input rasters by reference and to specify image collection properties through context parameter.

It can be used when new data is available to be included in the same orthomapping project. When new data is added to the image collection the entire image collection must be reset to the original state.

 Argument Description input_rasters Required, the list of input rasters to be added to the image collection being created. This parameter can be any one of the following: - List of portal Items of the images - An image service URL - Shared data path (this path must be accessible by the server) - Name of a folder on the portal image_collection Required, the item representing the image collection to add input_rasters to. The image collection must be an existing image collection. This is the output image collection (mosaic dataset) item or url or uri raster_type_name Required, the name of the raster type to use for adding data to the image collection. raster_type_params Optional, additional raster_type specific parameters. The process of add rasters to the image collection can be controlled by specifying additional raster type arguments. The raster type parameters argument is a dictionary. context Optional, The context parameter is used to provide additional input parameters{“image_collection_properties”: {“imageCollectionType”:”Satellite”},”use_by_ref”:True} use image_collection_properties key to set value for imageCollectionType. Note: the “imageCollectionType” property is important for image collection that will later on be adjusted by orthomapping system service. Based on the image collection type, the orthomapping system service will choose different algorithm for adjustment. Therefore, if the image collection is created by reference, the requester should set this property based on the type of images in the image collection using the following keywords. If the imageCollectionType is not set, it defaults to “UAV/UAS” If use_input_rasters_by_ref is set to True, the data will not be uploaded. If it is not set, the default is False gis Optional GIS. The GIS on which this tool runs. If not specified, the active GIS is used.
Returns

The imagery layer item

## delete_image¶

analytics.delete_image(where, gis=None)

delete_image allows users to remove existing images from the image collection (mosaic dataset). The function will not only delete the raster item in the mosaic dataset but also remove the source image from the server.

 Argument Description image_collection Required, the input image collection from which to delete images This can be the ‘itemID’ of an exisiting portal item or a url to an Image Service or a uri where Required string, a SQL ‘where’ clause for selecting the images to be deleted from the image collection gis Optional GIS. The GIS on which this tool runs. If not specified, the active GIS is used.
Returns

The imagery layer url

## delete_image_collection¶

analytics.delete_image_collection(gis=None)

Delete the image collection. This service tool will delete the image collection image service, portal item and all the source image data it references to.

 Argument Description image_collection Required, the input image collection to delete. The image_collection can be a portal Item or an image service URL or a URI. The image_collection must exist. gis Optional GIS. The GIS on which this tool runs. If not specified, the active GIS is used.
Returns

Boolean value indicating whether the deletion was successful or not