ENVIStandardRasterSpatialRef::ConvertFileToFile
The ConvertFileToFile method converts a set of pixel (x,y) coordinates in a standard spatial reference to the same pixel location in another standard spatial reference.
Example
; Launch the application
e = ENVI(/HEADLESS)
; Open a file but override its spatial reference
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
spatialRef1 = raster.spatialRef
; re-define the spatial reference as NAD 27 Colorado North
; this information was retrieved from the spatialref after reprojecting
; qb_boulder_msi to NAD27 to create an example file
coord_sys_str = $
'GEOGCS["GCS_North_American_1927",' + $
'DATUM["D_North_American_1927",' + $
'SPHEROID["Clarke_1866",6378206.4,294.9786982]],' + $
'PRIMEM["Greenwich",0.0],' + $
'UNIT["Degree",0.0174532925199433]]'
; Create a custom spatial reference object
spatialRef2 = ENVIStandardRasterSpatialRef( $
COORD_SYS_STR=coord_sys_str, $
PIXEL_SIZE=[3.2788230e-005,2.5217370e-005], $
TIE_POINT_PIXEL=spatialRef1.tie_point_pixel, $
TIE_POINT_MAP=[-105.23065, 40.010842])
; List file coordinates from the original spatial reference
File1X = 685.0
File1Y = 301.0
spatialRef1.ConvertFileToFile, File1X, File1Y, File2X, File2Y, spatialRef2
PRINT, 'File 1 coordinates: ', File1X, File1Y
PRINT, 'File 2 coordinates: ', File2X, File2Y
Syntax
ENVIStandardRasterSpatialRef.ConvertFileToFile, File1X, File1Y, File2X, File2Y, SpatialRef2
Arguments
File1X
The file X-coordinate in the first spatial reference. You can specify a scalar or a vector of File1X values; if it is a vector, the File1Y argument should also be a vector with the same number of elements:
File1X = [688.0, 641.1]
File1Y = [301.0, 280.0]
File1Y
The file Y-coordinate in the second spatial reference
File 2X
A named variable that will contain the file X-coordinate in the second spatial reference
File2Y
A named variable that will contain the file Y-coordinate in the second spatial reference
SpatialRef2
A reference to an ENVIStandardRasterSpatialRef object in the second spatial reference
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.1 |
Introduced |
API Version
4.2
See Also
ENVIStandardRasterSpatialRef, ENVIPseudoRasterSpatialRef::ConvertFileToFile, ENVIRPCRasterSpatialRef::ConvertFileToFile