This function constructs an ENVIRaster from a source raster that has been reprojected and resampled to a grid with a standard spatial reference, a pre-defined pixel size, and the same number of rows and columns.

Rasters that share a common spatial grid are often used for spatiotemporal analysis, for example, studying the change in atmospheric pressure or a glacier's extent over time in a specific location.

This routine is designed for use with two or more images with different projections. MODIS Level-3 gridded products do not need this routine; the images already are gridded to the same spatial reference. Even when you run processes like RPC orthorectification or GLT reprojection on a series of images (for spatiotemporal analysis), the results may not necessarily be in a common spatial grid. Instrument drift over time may result in a slight shift of pixels over a given geographic coordinate. Reprojecting these images to a spatial grid will ensure accurate spatial extents.

If the spatial grid extends beyond the boundaries of an input raster, those pixels will have values of 0. If the spatial grid does not overlap the input raster, then an error will be thrown.

The result is a virtual raster, which has some additional considerations with regard to methods and properties. See Virtual Rasters for more information, including how they differ from ENVITasks.

The equivalent task is RegridRaster.


See the following examples:


Result = ENVISpatialGridRaster(Input_Raster [, Keywords=value])

Return Value

This routine returns a reference to an ENVIRaster.



Specify an input ENVIRaster. If you are working with two or more source rasters, you must run the ENVISpatialGridRaster function separately for each raster.


This virtual raster inherits methods and properties from ENVIRaster; however the following methods will override the ENVIRaster methods:





Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.


Specify an ENVIGridDefinition object that defines the pixel size, rows and columns, and coordinate system of the desired spatial reference.


Specify a string that identifies the raster.

RESAMPLING (optional)

Specify the resampling method to use when creating the spatial grid:

  • Nearest Neighbor (default): Uses the nearest pixel without any interpolation.
  • Bilinear: Performs a linear interpolation using four pixels to resample.
  • Cubic Convolution: Uses 16 pixels to approximate the sinc function using cubic polynomials to resample the image.

Version History

ENVI 5.2


ENVI 5.3.1

Documented the dehydrated form of this virtual raster

ENVI 5.4

Added Dehydrate and Hydrate methods; added NAME keyword

API Version


See Also

ENVIRaster, RegridRaster Task, ENVIRasterSeries, ENVIRasterSeriesLayer, BuildRasterSeries Task, BuildTimeSeries Task