ENVIStandardRasterSpatialRef::ConvertLonLatToFile
The ConvertLonLatToFile method converts a set of geographic latitude/longitude coordinates in a standard spatial reference to file coordinates within the same spatial reference.
Example
The following example converts a set of lon/lat coordinates to file coordinates.
; Launch the application
e = ENVI(/HEADLESS)
; Open a file with a standard spatial reference
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
; Get the spatial reference
spatialRef = raster.spatialRef
; Provide a set of lon/lat coordinates
Lon = -105.2212463D
Lat = 40D
; Convert to file coordinates
spatialRef.ConvertLonLatToFile, Lon, Lat, FileX, FileY
PRINT, 'Lon/Lat coordinates: ',Lon, Lat
PRINT, 'Map coordinates: ',FileX, FileY
Syntax
ENVIStandardRasterSpatialRef.ConvertLonLatToFile, Lon, Lat, FileX, FileY
Arguments
Lon
The longitude coordinate. You can specify a scalar or a vector of longitude values; if it is a vector, the Lat argument should also be a vector with the same number of elements; for example:
Lon = [-123.58, -134.64]
Lat = [48.23, 49.56]
Lat
The latitude coordinate
FileX
A named variable that contains the pixel x-coordinate
FileY
A named variable that contains the pixel y-coordinate
Keywords
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.6.1 |
Introduced |
API Version
4.2
See Also
ENVIStandardRasterSpatialRef, ENVIPseudoRasterSpatialRef::ConvertLonLatToFile, ENVIRPCRasterSpatialRef::ConvertLonLatToFile