Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  ENVI API  >  Application Control  >  ENVI::OpenRaster

ENVI::OpenRaster

ENVI::OpenRaster

The OpenRaster function method creates a new ENVIRaster from a file.

Example


; Launch the application
e = ENVI()
 
; Open an ENVI file and display it
file1 = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
  SUBDIR= ['data'])
raster1 = e.OpenRaster(file1)
view1 = e.GetView()
layer1 = view1.CreateLayer(raster1)
 
; Open a PNG file and display it
file2 = FILEPATH('avhrr.png', $
  SUBDIRECTORY = ['examples','data'])
raster2 = e.OpenRaster(file2)
view2 = e.CreateView()
layer2 = view2.CreateLayer(raster2)

Syntax


Result = ENVI.OpenRaster(URI [, Keywords=value])

Return Value


This method returns a reference to an ENVIRaster. If the associated file is a NITF multiple image segment file, this method returns an array of ENVIRaster objects.

Arguments


URI

For local datasets, specify a scalar string that is a fully-qualified file path to a raster on disk.

For remote datasets, specify a string with the direct URL of the dataset. This option is the same as the Open Remote Dataset dialog in the ENVI interface. You can connect directly to a geodatabase, IAS, JPIP, or OGC server, or to an Esri® Image Service. If you connect to a remote dataset that requires authentication, you must set the USERNAME and PASSWORD keywords. Or, optionally set the /PROMPT_USER keyword to enter the user name and password.

Keywords


Keywords are applied only during the initial creation of the object.

CUSTOM_TYPE

Use this keyword to define a custom file reader that will be used to open the raster. Set the keyword to a string with the name of the custom open procedure to call. You cannot use this keyword in conjunction with EXTERNAL_TYPE.

DATA_IGNORE_VALUE

Set this keyword to a pixel value that will be ignored when the raster is displayed. This overrides any data ignore values set in the metadata.

DATASET_INDEX

This keyword applies to the following file formats: ECRG, HDF5, Multi-page TIFF, NetCDF-4, NITF with multiple image segments, Proba-V, and SkySat-1. Specify a zero-based index number that corresponds to a specific raster dataset that you want to open within the file. For example, DATASET_INDEX=0 will open the first raster.

  • Multi-page TIFF: Specify an index number with the specific page to open. For example, DATASET_INDEX=5 will open the sixth page.
  • NITF: For files with multiple image segments, specify an index number corresponding to an individual image segment. DATASET_INDEX=0 will open the first image segment.
  • Proba-V with radiometry:
    • DATASET_INDEX=0: VNIR band
    • DATASET_INDEX=1: SWIR band
    • DATASET_INDEX=2: NDVI band
    • DATASET_INDEX=3: Quality band
  • Proba-V without radiometry:
    • DATASET_INDEX=0: NDVI band
    • DATASET_INDEX=1: Quality band

DATASET_NAME

This keyword applies to file formats with multiple datasets per file such as ECRG, generic HDF4, generic HDF5, Multi-page TIFF, NetCDF-3, NetCDF-4, and SkySat-1.

  • Set this keyword to a string with the name of a raster dataset that you want to open within the file. Strings are case-sensitive.
  • For NITF files with multiple image segments, use the DATASET_INDEX keyword instead.
  • If you do not know the dataset names, use the Dataset Browser to open the files and obtain the names.
  • You do not need to use this keyword for the following data types because ENVI reads them natively; however, you can still specify a dataset name to open an individual dataset from the file:

    • ASTER (HDF-EOS)
    • Cosmo-SkyMed (HDF5)
    • MODIS (HDF-EOS)
    • EO-1 ALI and Hyperion (HDF4)
    • MASTER (HDF4)
    • Proba-V (HDF5)
    • SeaWiFS (HDF4)
    • SPOT Vegetation (HDF4)
    • ResourceSat (HDF5)
    • SSOT (HDF5)
    • Suomi NPP VIIRS (HDF5)
  • For Landsat-8, use one of the following strings to indicate a specific band group to open: Multispectral, Panchromatic, Cirrus, Thermal, or Quality. For example:
  • File = 'LC80430342015121LGN00_MTL.txt'
    Raster = e.OpenRaster(File, DATASET_NAME='Multispectral')

    You can also open Landsat-8 data by indicating the correct array element for a specific band group. See Metaspectral Datasets for more information.

HDF5 example

For HDF5 files, you can use the IDL H5_LIST routine to list the dataset names. This example uses an HDF5 file included in the ENVI+IDL installation. Set xx to the correct version of IDL:

File = 'C:\Program Files\Harris\IDLxx\examples\data\hdf5_test.h5' 
H5_LIST, File

IDL prints:

% Loaded DLM: HDF5.
file        C:\Program Files\Harris\IDLxx\examples\data\hdf5_test.h5
dataset/2D int array                                                          H5T_INTEGER [50, 100]
dataset          /A note H5T_STRING [2]
group              /arrays
dataset          /arrays/2D float array H5T_FLOAT [50, 100]
dataset          /arrays/2D int array H5T_INTEGER [50, 100]
...
etc.

Then enter the following command:

Raster = e.OpenRaster(File, DATASET_NAME='/arrays/2D float array')

SkySat-1 example

Set the URI argument to a metadata file. Valid strings for DATASET_NAME include Panchromatic, Multispectral, or Pan Sharpened.

File = 's01_20140315T161938Z_metadata.txt'
Raster = e.OpenRaster(File, DATASET_NAME='Panchromatic')

SkySat rasters open in their native spatial reference (typically RPC). They do not reproject as they would in the ENVI user interface.

Proba-V S10 example

Valid strings include VNIR, SWIR, NDVI, and Quality.

File = 'PROBAV_S10_TOC_X19Y03_20131121_333M_V001.h5'
Raster = e.OpenRaster(file, DATASET_NAME='NDVI')

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.

EXTERNAL_TYPE

Use this keyword to open raster datasets in external file formats not natively supported by the ENVI software. Only use this keyword to open data files in the specific external file formats listed below—for all other raster datasets, this keyword should not be specified.

For example, to open a WorldView-2 dataset in TIFF format this keyword is not required; simply execute the OpenRaster method with the File argument. Consequently, the list of external file formats given below is not a comprehensive list of raster formats supported by the ENVI software.

Set this keyword to a string describing the type of the external file to open:

File Type String

Description

acres

Australian Centre for Remote Sensing (ACRES) Canadian Centre for Remote Sensing (CCRS) Landsat and SPOT data

alos

Advanced Land Observing Satellite

arcview

ArcView® raster format files that have the .bil file extension and an associated header file with the .hdr extension. ENVI extracts the header information, including the UTM and State Plane projection georeferencing information.

atsr

Gridded Brightness Temperature (GBT), Gridded Browse (GBROWSE), and Gridded SST (GSST) data from ATSR-1 and ATSR-2

avhrr

Advanced Very High Resolution Radiometer (AVHRR)

avhrr_sharp

European Space Agency SHARP data

cadrg

Compressed ARC Digitized Raster Graphics (CADRG) format

cib

Controlled Image Base (CIB) format

cosmo-skymed

COSMO-SkyMed radar format

dmc

ENVI reads and displays data from the UK-DMCSat-1, ALSAT-1, and NigeriaSat-1 satellites that are part of the DMC (Disaster Monitoring Constellation).

dmsp_noaa 

NOAA Defense Meteorological Satellite Program (DMSP) Operational Linescan System (OLS) format

ecw

Enhanced Compressed Wavelet

envisat

Environmental Satellite (Envisat)

er_mapper 

ER mapper format

erdas_lan

erdas file (*.lan)

eros_l1a

Earth Resources Observation System 1A data

eros_l1b

ImageSat International EROS A Level 1B files

ers

European Remote Sensing Satellite-1 or -2

formosat-2

FORMOSAT-2 DIMAP (.dim) data

irs_fast 

Indian Remote Sensing (IRS) data in Earth Observation Satellite Company (EOSAT) Fast format

irs_super_structured

IRS Super Structured data

jers 

Japanese Earth Resources Satellite

landsat_ceos

European Space Agency CEOS Landsat TM data

landsat_fast

Landsat TM data in EOSAT Fast format

landsat_mrlc

Multi-Resolution Land Characteristic format for Landsat TM and DEM data

landsat_nlaps

National Landsat Archive Production System (NLAPS) format for Landsat TM and MSS data

pci

PCI Geomatics format (.pix)

pds

Planetary Data System format

pict

QuickDraw Picture

radarsat

Canadian Radar Satellite data

sicd

Sensor Independent Complex Data (NITF format)

spot_cap_sisa 

SPOT 1A, 2A, and 1B data

spot_geospot 

Reads the primary format for SPOT data. ArcView® raster image files have a similar format specification. The GeoSPOT format is described in detail in documentation available from SPOT Image.

srf

Spectral Response Function. Engineering data that quantify the spectral response and sensitivity of detectors on an airborne or satellite sensor. The term SRF also refers to a data format that contains SRF data for particular sensors.

srtm_dem

Shuttle Radar Topography Mission (SRTM) elevation data

tims 

Thermal Infrared Multispectral Scanner data

topsar

Raw AIRSAR Integrated Processor Data format (Cvv, incidence angle, correlation image, or DEM)

usgs_doq 

USGS Digital Orthophoto Quadrangle data

usgs_native_dem 

USGS Digital Elevation Model data

usgs_sdts_dem

USGS Spatial Data Transfer Standard

xwd

X Window Dump

INTERLEAVE

This keyword only applies to three-dimensional datasets and specifies the interleave of the dataset when an interleave is not specifically defined in the file (as with HDF5 datasets). Set this keyword to one of the following strings:

String Interleave Data Array
bil Band interleaved by line [ncolumns, nbands, nrows]
bip Band interleaved by pixel [nbands, ncolumns, nrows]
bsq Band sequential [ncolumns, nrows, nbands]

This keyword is optional and the default value 'bsq' is used if it is not set.

METADATA_OVERRIDE

Set this keyword to an ENVIRasterMetadata object (or an array of these objects, for files with multiple data groups). The metadata information for the newly created ENVIRaster will be taken from both the specified object and the ENVIRaster on disk (specified with URI).

If the ENVIRasterMetadata object specified by this keyword and the ENVIRaster specified by URI both have the same tag, the tag information from the ENVIRasterMetadata object will take precedence. Although this process only happens in memory, the information will be persisted to a header file if the ENVIRaster::WriteMetadata method is called.

If the ENVIRasterMetadata object contains the string 'read procedures,' then the ENVIRaster is opened using a custom read routine.

The DATA_IGNORE_VALUE keyword takes precedence over the METADATA_OVERRIDE keyword.

For NPP VIIRS files, only the I, M, DNB, or NCC bands (rasters) can be overridden. Metadata override is not allowed for the Latitude, Longitude, Height, or Quality bands.

PASSWORD

Set this keyword to a string with a valid password for opening a remote dataset that requires authentication.

PROMPT_USER

Set this keyword in an interactive session (not for use with batch mode) if you want ENVI to prompt you for certain input parameters instead of performing default actions.

If you set the PROMPT_USER keyword and open an NPP VIIRS dataset, the NPP VIIRS Parameters dialog will appear for you to select calibration options. If you do not set this keyword and you open an NPP VIIRS dataset, the dataset will be calibrated to radiance, by default.

SPATIALREF_OVERRIDE

Set this keyword to an ENVINITFCSMRasterSpatialRef, ENVIPseudoRasterSpatialRef, ENVIRPCRasterSpatialRef, or ENVIStandardRasterSpatialRef object (or an array of these objects, for files with multiple data groups). The spatial reference information for the newly created ENVIRaster will be taken from the specified object (or array of objects), and not from the associated raster data file(s). Although this process only happens in memory, the information will be persisted to a header file if the ENVIRaster::WriteMetadata method is called.

If the ENVIRaster contains a combination of standard and auxiliary (RPCs or pseudo) map information, and you set SPATIALREF_OVERRIDE to an ENVIStandardRasterSpatialRef object, the original auxiliary map information will be lost.

Note: You cannot set this keyword to an object of type 'arbitrary'. Also, this keyword is not supported when opening a file using the EXTERNAL_TYPE keyword.

TEMPLATE

Set this keyword to a string with the name of a custom XML template used to open generic HDF4, generic HDF5 , NetCDF-3, and NetCDF-4 datasets. Creating and restoring templates can be helpful when you want to build the same raster and metadata structure from several source files. See Work with Templates for instructions on creating templates. Save templates to the directory specified by the Custom Code Directory preference. If you set this keyword, you cannot also set the DATASET_NAME keyword.

The following example code shows how to open an AVHRR sea surface temperature (SST) dataset using a template that resides in the Custom Code Directory.

file = '2014_290_1122_n19_eb.hdf'
raster = e.OpenRaster(file, TEMPLATE='NOAA-19 AVHRR SST')

TIME_OVERRIDE

Set this keyword to an ENVITime object (or an array of these objects, for files with multiple data groups). The time information for the newly created ENVIRaster will be taken from the specified object (or array of objects), and not from the associated raster data file(s). Although this process only happens in memory, the information will be persisted to a header file if the ENVIRaster::WriteMetadata method is called.

USERNAME

Set this keyword to a string with a valid user name for opening a remote dataset that requires authentication.

UVALUE

Use this keyword only in conjunction with the CUSTOM_TYPE keyword to indicate that the raster should be opened with a custom open procedure. The value set with this keyword will be passed into the custom open procedure's UVALUE keyword. If the custom open procedure does not accept the UVALUE keyword, then it will be ignored.

Version History


ENVI 5

Introduced

ENVI 5, Service Pack 2

Added new keywords: CUSTOM_TYPE, TIME_OVERRIDE, and UVALUE

ENVI 5.1

Added new keywords: DATASET and INTERLEAVE

Added 'sicd' to EXTERNAL_TYPE keyword

ENVI 5.2, Service Pack 1

Bitmap ('bmp') and USGS DRG ('usgs_drg') are obsolete with the EXTERNAL_TYPE keyword; ENVI::OpenRaster automatically supports these formats.

ENVI 5.4

Added generic HDF4 and NetCDF-3 as supported formats for the DATASET_NAME and TEMPLATE keywords.

Added srtm_dem to the EXTERNAL_TYPE keyword.

The following strings for the EXTERNAL_TYPE keyword are obsolete because ENVI::OpenRaster automatically supports these formats: ads40, eo1_hdf, eos_aster, eos_modis, master, png, seawifs, spot_vegetation, and landsat_hdf. However, these strings will still work if you specify them.

API Version


3.2

See Also


ENVI function, ENVI::GetView, ENVIView::CreateLayer, ENVIRaster



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us