Welcome to the Harris Geospatial documentation center. Here you will find reference guides and help documents.


  >  Docs Center  >  ENVI API  >  Data Control  >  ENVIGridDefinition::Union

ENVIGridDefinition::Union

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 on the ENVI Resource DVD (in the APIGriddingExamples folder) or from the ENVI Tutorials web page. Click the "ENVI Tutorial Data" hyperlink. Copy the images to your local drive.

  • MODIS Land Surface Temperature (MOD11_L2) swath image from 07 March 2009, georeferenced to a UTM Zone 54 coordinate system using ENVI's Georeference MODIS tool, corrected for bowtie artifacts, spatially subsetted, and scaled by 0.02 so that the pixel values are in Kelvins.
  • Suomi NPP VIIRS Land Surface Temperature EDR image from 07 March 2014, georeferenced to a Geographic Lat/Lon (WGS-84) coordinate system, and spatially subsetted.

; 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


3.3

See Also


ENVIGridDefinition, ENVICoordSys, ENVICalculateGridDefinitionFromRasterUnionTask



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us