This method has been deprecated. Use ENVISubsetRaster for spatial and spectral subsetting. Use ENVIROIMaskRaster for applying ROI information to a raster.
The Subset function method returns an ENVIRaster object that is a spatial and/or spectral subset of the original raster.
Result = ENVIRaster.Subset([, Keywords=value])
This method returns an ENVIRaster that is a spatial and/or spectral subset of an original raster file.
Keywords are applied only during the initial creation of the object.
Set this keyword to an array of band indices, indicating the specific bands (a spectral subset) to process.
- Bands are zero-based, so 0=Band 1, 1=Band 2, etc.
- If you do not specify this keyword, all available bands will be used for processing.
- The valid range of values is 0 to numBands-1.
- Band indices cannot be repeated (for example, [0,0,1]).
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.
Set this keyword to an ENVIROI object. When this keyword is set, the returned ENVIRaster will contain information on which pixels are inside or outside of the ENVIROI object. To get this information, use the PIXEL_STATE keyword with ENVIRaster::GetData or ENVIRasterIterator::GetData.
Set this keyword to an ENVIGLTRasterSpatialRef, ENVIPseudoRasterSpatialRef, ENVIRPCRasterSpatialRef, or ENVIStandardRasterSpatialRef object, indicating the spatial reference of the spatial subset. You must also set the SUB_RECT keyword. If you set the SPATIALREF keyword, the SUB_RECT array values are treated as geographic coordinates in the specified spatial reference, instead of pixel coordinates.
Set this keyword to a four-element array expressing the spatial range of the raster data. The array is of the form:
[x1, y1, x2, y2]
The following table defines the x and y values of the SUB_RECT array:
First pixel of the columns dimension
Minimum value in the map x-dimension
First pixel of the rows dimension
Minimum value in the map y-dimension
Last pixel of the columns dimension
Maximum value in the map x-dimension
Last pixel of the rows dimension
Maximum value in the map y-dimension
The array values differ, depending on whether or not the SPATIALREF keyword is also set.
- If you do not set the SPATIALREF keyword, then x and y refer to pixel coordinates. These are zero-based and must be integers.
- If you set the SPATIALREF keyword, then x and y refer to map or geographic coordinates.
- They can be floating-point or integer values.
- They can be represented as map coordinates (x=eastings, y=northings) or geographic coordinates (x=longitude, y=latitude), depending on the spatial reference object used. The x,y coordinates must be in the same units (degrees, meters, feet, etc.) as the spatial reference object. See More Examples below.
- If you do not specify this keyword, the entire raster will be used for processing.
If you set the SPATIALREF keyword, the geographic extent of SUB_RECT is determined by transforming all four coordinates from the spatial reference defined by SPATIALREF into the spatial reference of the subset. This is followed by a reprojection into pixel coordinates. The reprojection may result in a rotated rectangle or trapezoid. In this case, the subset will be a rectangle that encompasses the extent of the input subset, as the following figure shows:
Suppose that you have an image that is a UTM projection, with coordinates in eastings and northings (in meters). You want to define a spatial subset based on known latitude and longitude coordinates (in degrees). Because the spatial reference of the source image uses map coordinates, then the SUB_RECT value must also use map coordinates. You can use the ConvertLonLatToMap method to convert the geographic coordinates to map coordinates as follows. Be sure to arrange the minimum and maximum x,y values in the correct order.
Raster = e.OpenRaster(File)
UpperLeftLat = 35.1
UpperLeftLon = -112.1
LowerRightLat = 34.7
LowerRightLon = -111.6
SpatialRef = Raster.SPATIALREF
SpatialRef.ConvertLonLatToMap, UpperLeftLon, UpperLeftLat, MapX, MapY
SpatialRef.ConvertLonLatToMap, LowerRightLon, LowerRightLat, MapX2, MapY2
Subset = Raster.Subset(SPATIALREF=SpatialRef, $
SUB_RECT=[MapX, MapY2, MapX2, MapY])
ENVIRaster, ENVIRaster::GetData, ENVIRaster::Save, ENVIRaster::Export, ENVIROI