GeoEco.DataManagement.ArcGISRasters.ArcGISRaster.ProjectToTemplate

classmethod ArcGISRaster.ProjectToTemplate(inputRaster, templateRaster, outputRaster, resamplingTechnique, interpolationMethod=None, maxHoleSize=None, mask=False, minValue=None, maxValue=None, overwriteExisting=False)

Projects a raster to the coordinate system, cell size, and extent of a template raster.

Requires: ArcGIS Pro 3.2.0 or later or ArcGIS Server equivalent to ArcGIS Pro 3.2.0 or later, ArcGIS ‘spatial’ extension.

Parameters:
  • inputRaster (str) – Raster to project to the template raster’s coordinate system, cell size, and extent. Minimum length꞉ 1. Must exist.

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

  • outputRaster (str) – Output raster to create. If this path refers to the file system, missing directories in the path will be created if they do not exist. Minimum length꞉ 1. Must be different than inputRaster and templateRaster.

  • 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'.

  • 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.

  • overwriteExisting (bool, optional) – If True, the raster will be overwritten, if it exists. If False, a ValueError will be raised if the raster exists.