ENVIGridDefinition::Union

This function method returns the spatial extent of the geometric union between two ENVIGridDefinition objects:

Example

This example creates a new spatial grid that is based on the geometric union of two different spatial grids. The images in the two grids are available from our ENVI Tutorials web page. Click the API Gridding Examples link to download the .zip file to your machine, then unzip the files.

; Start the application

e = ENVI()

 

; Open the MODIS LST raster

File1 = 'MODIS_LST_2009-03-07.dat'

MODISRaster = e.OpenRaster(File1)

MODISCoordSysString = MODISRaster.SPATIALREF.COORD_SYS_STR

MODISCoordSys = ENVICoordSys(COORD_SYS_STR=MODISCoordSysString)

 

; Open the Suomi NPP VIIRS LST raster

File2 = 'VIIRSLST2014-03-07.dat'

VIIRSRaster = e.OpenRaster(File2)

VIIRSCoordSysString = VIIRSRaster.SPATIALREF.COORD_SYS_STR

VIIRSCoordSys = ENVICoordSys(COORD_SYS_STR=VIIRSCoordSysString)

 

; Create a grid definition with the same coordinate

; system and dimensions as the input MODIS raster

MODISGrid = ENVIGridDefinition(MODISCoordSys, $

  PIXEL_SIZE=MODISRaster.SPATIALREF.PIXEL_SIZE, $

  NROWS=MODISRaster.NROWS, $

  NCOLUMNS=MODISRaster.NCOLUMNS, $

  TIE_POINT_MAP=MODISRaster.SPATIALREF.TIE_POINT_MAP, $

  TIE_POINT_PIXEL=MODISRaster.SPATIALREF.TIE_POINT_PIXEL)

 

; Create a grid definition with the same coordinate

; system and dimensions as the input VIIRS raster

VIIRSGrid = ENVIGridDefinition(VIIRSCoordSys, $

  PIXEL_SIZE=VIIRSRaster.SPATIALREF.PIXEL_SIZE, $

  NROWS=VIIRSRaster.NROWS, $

  NCOLUMNS=VIIRSRaster.NCOLUMNS, $

  TIE_POINT_MAP=VIIRSRaster.SPATIALREF.TIE_POINT_MAP, $

  TIE_POINT_PIXEL=VIIRSRaster.SPATIALREF.TIE_POINT_PIXEL)

 

; Get the union of the two rasters

SpatialExtent = MODISGrid.Union(VIIRSGrid)

UnionGrid = ENVIGridDefinition(MODISCoordSys, $

  EXTENT=SpatialExtent, $

  PIXEL_SIZE=MODISRaster.SPATIALREF.PIXEL_SIZE)

 

ReprojectedMODIS = ENVISpatialGridRaster(MODISRaster, $

  GRID_DEFINITION=UnionGrid)

 

ReprojectedVIIRS = ENVISpatialGridRaster(VIIRSRaster, $

  GRID_DEFINITION=UnionGrid)

 

; Display the reprojected rasters

View = e.GetView()

Layer1 = View.CreateLayer(ReprojectedMODIS)

Layer2 = View.CreateLayer(ReprojectedVIIRS)

View.Animate, 2.0, /FLICKER

Syntax

Result = ENVIGridDefinition.Union(ENVIGridDefinition2, [, ERROR=variable])

Arguments

ENVIGridDefinition2

Specify a second ENVIGridDefinition object from which to compute a union.

Keywords

Keywords are applied only during the initial creation of the object.

ERROR

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.

Version History

ENVI 5.2

Introduced

API Version

4.2

See Also

ENVIGridDefinition, ENVICoordSys, CalculateGridDefinitionFromRasterUnion Task