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



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


This example creates a new spatial grid that is based on the geometric intersection 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)
; Open the Suomi NPP VIIRS LST raster
File2 = 'VIIRSLST2014-03-07.dat'
VIIRSRaster = e.OpenRaster(File2)
; Create a grid definition with the same coordinate
; system and dimensions as the input MODIS raster
MODISGrid = ENVIGridDefinition(MODISCoordSys, $
; Create a grid definition with the same coordinate
; system and dimensions as the input VIIRS raster
VIIRSGrid = ENVIGridDefinition(VIIRSCoordSys, $
; Get the intersection of the two rasters
SpatialExtent = MODISGrid.Intersection(VIIRSGrid)
IntersectGrid = ENVIGridDefinition(MODISCoordSys, $
  EXTENT=SpatialExtent, $
ReprojectedMODIS = ENVISpatialGridRaster(MODISRaster, $
ReprojectedVIIRS = ENVISpatialGridRaster(VIIRSRaster, $
; Display the reprojected rasters
View = e.GetView()
Layer1 = View.CreateLayer(ReprojectedMODIS)
Layer2 = View.CreateLayer(ReprojectedVIIRS)
View.Animate, 2.0, /FLICKER


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



Specify a second ENVIGridDefinition object from which to compute an intersection.


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


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


API Version


See Also

ENVIGridDefinition, ENVICoordSys, ENVICalculateGridDefinitionFromRasterIntersectionTask

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