ENVIGridDefinition::Intersection
This function method returns the spatial extent of the geometric intersection between two ENVIGridDefinition objects:
Example
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 from our ENVI Tutorials web page. Click the API Gridding Examples link to download the .zip file to your machine, then unzip the files.
- 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 intersection of the two rasters
SpatialExtent = MODISGrid.Intersection(VIIRSGrid)
IntersectGrid = ENVIGridDefinition(MODISCoordSys, $
EXTENT=SpatialExtent, $
PIXEL_SIZE=MODISRaster.SPATIALREF.PIXEL_SIZE)
ReprojectedMODIS = ENVISpatialGridRaster(MODISRaster, $
GRID_DEFINITION=IntersectGrid)
ReprojectedVIIRS = ENVISpatialGridRaster(VIIRSRaster, $
GRID_DEFINITION=IntersectGrid)
; Display the reprojected rasters
View = e.GetView()
Layer1 = View.CreateLayer(ReprojectedMODIS)
Layer2 = View.CreateLayer(ReprojectedVIIRS)
View.Animate, 2.0, /FLICKER
Syntax
Result = ENVIGridDefinition.Intersection(ENVIGridDefinition2, [, ERROR=variable])
Arguments
ENVIGridDefinition2
Specify a second ENVIGridDefinition object from which to compute an intersection.
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, CalculateGridDefinitionFromRasterIntersection Task