GeoEco.DataManagement.ArcGISRasters.ArcGISRaster.FindAndProjectRastersToTemplate

classmethod ArcGISRaster.FindAndProjectRastersToTemplate(inputWorkspace, outputWorkspace, templateRaster, resamplingTechnique, wildcard='*', searchTree=False, rasterType=None, interpolationMethod=None, maxHoleSize=None, mask=False, minValue=None, maxValue=None, outputRasterPythonExpression='os.path.join(outputWorkspace, inputRaster[len(workspaceToSearch)+1:])', modulesToImport=['os.path'], skipExisting=False, overwriteExisting=False)

Finds rasters in an ArcGIS workspace and projects them to the coordinate system, cell size, and extent of a template raster.

Parameters:
  • inputWorkspace (str) – Workspace to search. Minimum length꞉ 1. Must exist.

  • outputWorkspace (str) – Workspace to receive the output rasters. Minimum length꞉ 1.

  • templateRaster (str) – Raster defining the coordinate system, cell size, and extent of the output raster. Minimum length꞉ 1. Must exist.

  • resamplingTechnique (str) –

    Resampling algorithm to be used to project the input raster to the template raster’s coordinate system. One of:

    The NEAREST and MAJORITY algorithms should be used for categorical data, such as a land use classification. It is not recommended that NEAREST or MAJORITY be used for continuous data, such as elevation surfaces.

    The BILINEAR and CUBIC options are most appropriate for continuous data. Do not use BILINEAR or CUBIC with categorical data.

    The projection is accomplished with the ArcGIS ProjectRaster() tool. Please see the documentation for that tool for more information. Allowed values꞉ 'NEAREST', 'BILINEAR', 'CUBIC', 'MAJORITY'.

  • wildcard (str, optional) – Wildcard expression specifying the rasters to find. Please see the documentation for the ArcGIS ListRasters() function for more information about the syntax. At the time of this writing, only the * wildcard character was supported, which would match zero or more of any character. Minimum length꞉ 1.

  • searchTree (bool, optional) – If True, child workspaces will be searched.

  • rasterType (str, optional) – Type of rasters to find. If provided, only rasters of this type will be found. At the time of this writing, the ArcGIS Pro 3.2 documentation specified that any of the following strings would be accepted: All (the default), BMP, GIF, GRID, IMG, JP2, JPG, PNG, TIFF. Minimum length꞉ 1.

  • interpolationMethod (str, optional) –

    Method to use to guess values for NoData cells.

    Use this option to “fill in” clusters of NoData cells with values obtained by interpolation and extrapolation. This option is appropriate for rasters representing continuous surfaces, e.g. images of sea surface temperature in which cloudy cells contain NoData. It uses algorithms based on differential calculus that may provide more accurate guesses than traditional ArcGIS approaches, such as computing the focal mean of a 3x3 neighborhood.

    This option is not appropriate for rasters representing categorical data, such as land cover classifications. Therefore, in order to use this option, you must select BILINEAR or CUBIC for the Resampling Technique parameter.

    The available algorithms are:

    • Del2a - Laplacian interpolation and linear extrapolation.

    • Del2b - Same as Del2a but does not build as large a linear system of equations. May be faster than Del2a at the cost of some accuracy.

    • Del2c - Same as Del2a but solves a direct linear system of equations for the NoData values. Faster than both Del2a and Del2b but is the least robust to noise on the boundaries of NoData cells and least able to interpolate accurately for smooth surfaces.

    • Del4 - Same as Del2a but instead of the Laplace operator (also called the ∇2 operator) it uses the biharmonic operator (also called the ∇4 operator). May result in more accurate interpolations, at some cost in speed.

    • Spring - Uses a spring metaphor. Assumes springs (with a nominal length of zero) connect each cell with every neighbor (horizontally, vertically and diagonally). Since each cell tries to be like its neighbors, extrapolation is as a constant function where this is consistent with the neighboring nodes.

    This option is applied after the input raster has been projected to the coordinate system and cell size of the template raster.

    Although this tool can fill NoData clusters of any size, you should apply common sense when using it. The larger the cluster, the less accurate the guessed values will be, especially for rasters that represent a noisy surface.

    Thanks to John D’Errico for providing the code that implements the mathematical algorithms described here (click here for more information). Allowed values꞉ 'Del2a', 'Del2b', 'Del2c', 'Del4', 'Spring'.

  • maxHoleSize (int, optional) – Maximum size, in cells of the template raster, that a region of 4-connected NoData cells may be for it to be filled in. Use this option to prevent the filling of large NoData regions (e.g. large clouds in remote sensing images) when you are concerned that values cannot be accurately guessed for those regions. If this option is omitted, all regions will be filled, regardless of size. Must be greater than 0.

  • mask (bool, optional) –

    If True, the template raster will be used to mask the input raster after it has been projected to the template raster’s coordinate system and values have been interpolated for NoData cells (if your requested that). Cells of the template raster that are NoData will be set to NoData in the output raster, even if you requested that values be interpolated for NoData cells. This is appropriate in situations where the template defines the areas for which you want to retain data; for example, when you are analyzing the ocean and you have a mask in which ocean cells have data and land cells are set to NoData.

    If False, the template raster will only be used to define the coordinate system, cell size, and rectangular extent of the output raster, and no masking will be done.

  • minValue (float, optional) –

    Minimum allowed value to use when NoData cells are interpolated (or extrapolated). This parameter is ignored if an interpolation method is not specified.

    If this parameter is provided, all cells with less than the minimum value will be rounded up to the minimum. This includes not just the cells that had NoData in the input raster and were then interpolated or extrapolated, but also the cells that did have values in the input raster.

    Use this parameter when the interpolation/extrapolation algorithm produces impossibly low values. For example, consider a situation in which a chlorophyll concentration raster coincidentally shows a negative gradient approaching a cloud that straddles the edge of the raster. Missing cells at the edge of the raster will be filled by extrapolation. If the negative gradient is strong enough, the algorithm might extrapolate negative concentrations for the cloudy cells. This should be impossible; chlorophyll concentration must be zero or higher. To enforce that, you could specify a minimum value of zero (or a very small non-zero number, if exactly zero would be problematic, as might occur if the values were in a log scale).

  • maxValue (float, optional) –

    Maximum allowed value to use when NoData cells are interpolated (or extrapolated). This parameter is ignored if an interpolation method is not specified.

    If this parameter is provided, all cells with greater than the maximum value will be rounded up to the maximum. This includes not just the cells that had NoData in the input raster and were then interpolated or extrapolated, but also the cells that did have values in the input raster.

    Use this parameter when the interpolation/extrapolation algorithm produces impossibly high values. For example, consider a situation in which a percent sea ice concentration raster shows a positive gradient approaching the coastline but does not provide data right up to shore. Say you wanted to fill the missing cells close to shore and were willing to assume that whatever gradient occurred nearby was reasonable for filling them in. If the positive gradient is strong enough, the algorithm might extrapolate ice concentration values greater than 100 percent, which is impossible. To prevent values from exceeding 100 percent, you could specify a maximum value of 100.

  • outputRasterPythonExpression (str, optional) –

    Python expression used to calculate the absolute path of an output raster. The expression may be any Python statement appropriate for passing to the eval function and must return a string. The expression may reference the following variables:

    • workspaceToSearch - the value provided for the workspace to search parameter

    • outputWorkspace - the value provided for the output workspace parameter

    • inputRaster - the absolute path to the input raster

    The default expression, os.path.join(outputWorkspace, inputRaster[len(workspaceToSearch)+1:]), stores the output rasters in the output workspace at the same relative location as the input rasters appear in the workspace to search. The output raster path is calculated by stripping the workspace to search from the input raster path and replacing it with the output workspace.

    For more information on Python syntax, please see the Python documentation. Minimum length꞉ 1.

  • modulesToImport (list of str, optional) – Python modules to import prior to evaluating the expression. If you need to access Python functions or classes that are provided by a module rather than being built-in to the interpreter, list the module here. For example, to be able to use the datetime class in your expression, list the datetime module here. In your expression, you must refer to the class using its fully-qualified name, datetime.datetime.

  • skipExisting (bool, optional) – If True, processing will be skipped for output rasters that already exist.

  • overwriteExisting (bool, optional) – If True and skipExisting is False, existing output rasters will be overwritten.

Returns:

Workspace to receive the output rasters.

Return type:

str