GeoEco.DataManagement.ArcGISRasters.ArcGISRaster.ToPolygons
- classmethod ArcGISRaster.ToPolygons(inputRaster, outputFeatureClass, simplify=True, field=None, projectedCoordinateSystem=None, geographicTransformation=None, resamplingTechnique=None, projectedCellSize=None, registrationPoint=None, clippingDataset=None, clippingRectangle=None, mapAlgebraExpression=None, overwriteExisting=False)
Converts an ArcGIS raster to polygons that encompass groups of adjacent raster cells having the same value.
Requires: ArcGIS Pro 3.2.0 or later or ArcGIS Server equivalent to ArcGIS Pro 3.2.0 or later.
- Parameters:
inputRaster (
str) – Raster to convert. The raster will be converted to a polygon feature class using the ArcGISRastertoPolygon()tool. That tool can only convert integer rasters to polygons. If the input raster is a floating-point raster, you must use the Map Algebra Expression parameter to convert it to an integer raster. Minimum length꞉ 1. Must exist.outputFeatureClass (
str) – Output polygon feature class that will contain the converted polygons. Missing directories in this path will be created if they do not exist. Minimum length꞉ 1. Must be different than inputRaster.simplify (
bool, optional) –Determines if the output polygons will be smoothed into simpler shapes or conform to the input raster’s cell edges.
True - The polygons will be smoothed into simpler shapes. This is the default.
False - The polygons will conform to the input raster’s cell edges.
field (
str, optional) – The field used to assign values from the cells in the input raster to the polygons in the output dataset. It can be an integer or a string field. Minimum length꞉ 1. Must exist.projectedCoordinateSystem (
str, optional) – New coordinate system to project the raster to. The raster may only be projected to a new coordinate system if the original projection is defined. An error will be raised if you specify a new coordinate system without defining the original coordinate system. The ArcGISProjectRaster()tool is used to perform the projection. The documentation for that tool recommends that you also specify a cell size for the new coordinate system. Minimum length꞉ 1.geographicTransformation (
str, optional) –A transformation method used to convert between the original coordinate system and the new coordinate system.
This parameter is only needed when you specify that the raster should be projected to a new coordinate system and that new system uses a different datum than the original coordinate system, or there is some other difference between the two coordinate systems that requires a transformation. To determine if a transformation is needed:
First, run this tool without specifying a new coordinate system, to obtain the raster in the original coordinate system.
Next, use the ArcGIS
ProjectRaster()tool on the raster to project it to the desired coordinate system. If a geographic transformation is needed, that tool will prompt you for one. Write down the exact name of the transformation you used.Finally, if a transformation was needed, type in the exact name into this tool, rerun it, and verify that the raster was projected as you desired.
Minimum length꞉ 1.
resamplingTechnique (
str, optional) –The resampling algorithm to be used to project the original raster to a new coordinate system. The ArcGIS
ProjectRaster()tool is used to perform the projection and accepts the following values:NEAREST- Nearest neighbor assignment.BILINEAR- Bilinear interpolation.CUBIC- Cubic convolution, also known as bicubic interpolation.
You must specify one of these algorithms to project to a new coordinate system. An error will be raised if you specify a new coordinate system without selecting an algorithm.
Allowed values꞉
'NEAREST','BILINEAR','CUBIC'. Case sensitive.projectedCellSize (
float, optional) – The cell size of the projected coordinate system. Although this parameter is optional, to receive the best results, the ArcGIS documentation recommends you always specify it when projecting to a new coordinate system.registrationPoint (
str, optional) – The x and y coordinates (in the projected coordinate system) used for cell alignment. This parameter is ignored if you do not specify that the raster should be projected to a new coordinate system. Minimum length꞉ 1. Must match regular expression꞉([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?).clippingDataset (
str, optional) – Existing feature class, raster, or other geographic dataset having the extent to which the raster should be clipped. Minimum length꞉ 1. Must exist.clippingRectangle (
str, optional) –Rectangle to which the raster should be clipped. This should only be given if the clipping dataset parameter is omitted.
If a projected coordinate system was specified, the clipping is performed after the projection and the rectangle’s coordinates should be specified in the projected coordinate system. If no projected coordinate system was specified, the coordinates should be specified in the original coordinate system.
The ArcGIS
Clip()tool is used to perform the clip. The clipping rectangle must be passed to this tool as a string of four numbers separated by spaces. The ArcGIS user interface automatically formats the string properly; when invoking this tool from the ArcGIS UI, you need not worry about the format. But when invoking it programmatically, take care to provide a properly-formatted string. The numbers are ordered LEFT, BOTTOM, RIGHT, TOP. For example, if the raster is in a geographic coordinate system, it may be clipped to 10 W, 15 S, 20 E, and 25 N with the string'10 15 20 25'. Integers or decimal numbers may be provided.Minimum length꞉ 1. Must match regular expression꞉
([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?).mapAlgebraExpression (
str, optional) – Map algebra expression to execute on the raster. The expression is executed after the converted raster is projected and clipped (if those options are specified). UseinputRasterto represent the raster that you now want to perform map algebra upon. For example, to convert the raster to an integer raster and add 1 to all of the cells, use the expressionInt(inputRaster) + 1. Minimum length꞉ 1. Maximum length꞉ 4000. Requires: ArcGIS ‘spatial’ extension.overwriteExisting (
bool, optional) – If True, the output feature class will be overwritten, if it exists. If False, aValueErrorwill be raised if the output feature class exists.