ENVIView::GetCenterLocation
The GetCenterLocation function method returns the coordinates of the view's center.
Note: Only one coordinate keyword (DATA, GEO, MAP, MGRS) may be set.
Example
; Launch the application
e = ENVI()
; Open a file
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
; Display the data
view = e.GetView()
layer = view.CreateLayer(raster)
; Get the center of the view in lon, lat
center = view.GetCenterLocation()
PRINT, 'View Center'
PRINT, 'lon = ', center[0]
PRINT, 'lat = ', center[1]
Syntax
Result = ENVIView.GetCenterLocation([, Keywords=value])
Return Value
For geographical coordinates, result is an array of the form [lon,lat].
For map coordinates, result is an array of the form [x,y].
For MGRS coordinates, result is a string.
For DATA, result is an array [x,y] containing the pixel location.
Keywords
Keywords are applied only during the initial creation of the object.
DATA
Set this keyword to an ENVIRasterLayer that exists in the ENVIView. The function method returns the location of the pixel in this layer.
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.
GEO
Set this keyword to return the center location in [lon,lat] coordinates (for geographical coordinate systems). If no coordinate keyword is set, the return value will be in geographic coordinates.
MAP
Set this keyword to return the center location in eastings and northings (for projected coordinate systems).
MGRS
Set this keyword to return the center location as an alphanumeric string of Military Grid Reference System (MGRS) coordinates. Use the NUM_DIGITS keyword to set the precision for MGRS coordinates.
NUM_DIGITS
Note: This keyword is valid only if you also set the MGRS keyword.
Set this keyword to an integer between 0 and 5 to change the precision (the number of digits in the northing and easting) of the returned MGRS coordinates. If this keyword is not set, the number of digits returned is 5 (1-square-meter precision).
Version History
ENVI 5 |
Introduced |
API Version
4.2