Skip To Content

Extract Subdataset

Summary

Creates a new raster dataset from a selection of an HDF or NITF dataset.

Usage

  • Subdataset file formats can be either Hierarchical Data Format (HDF) or National Imagery Transmission Format (NITF) files

  • The data structure allows the file format to consist of multiple datasets in one parent file. In addition, each of the subdatasets can consist of one band or multiple bands.

  • If you do not choose any subdatasets, the default will be to only return the first subdataset.

  • When storing your raster dataset to a JPEG file, a JPEG 2000 file, or a geodatabase, you can specify a Compression type and Compression Quality within the Environment Settings.

  • The GIF format does not support multiband; therefore, it is not a valid output format unless your raster dataset is single band.

Syntax

ExtractSubDataset_management (in_raster, out_raster, {subdataset_index})
ParameterExplanationData Type
in_raster

The HDF or NITF dataset that has the layers you want to extract.

Raster Layer
out_raster

The name, location, and format for the dataset you are creating.

When storing the raster dataset in a file format, you need to specify the file extension:

  • .bil—Esri BIL
  • .bip—Esri BIP
  • .bmp—BMP
  • .bsq—Esri BSQ
  • .dat—ENVI DAT
  • .gif—GIF
  • .img—ERDAS IMAGINE file
  • .jpg—JPEG
  • .jp2—JPEG 2000
  • .png—PNG
  • .tif—TIFF
  • no extension—Esri GRID

When storing a raster dataset in a geodatabase, do not add a file extension to the name of the raster dataset.

When storing your raster dataset to a JPEG file, a JPEG 2000 file, or a geodatabase, you can specify a Compression type and Compression Quality within the Environment Settings.

Raster Dataset
subdataset_index
[subdataset_index,...]
(Optional)

The subdatasets that you want to extract.

Value Table

Code sample

ExtractSubDataset example 1 (Python window)

This is a Python sample for ExtractSubDataset.

import arcpy
arcpy.ExtractSubDataset_management("c:/data/MyNITF.ntf","extracted.tif", "2")
ExtractSubDataset example 2 (stand-alone script)

This is a Python script sample for ExtractSubDataset.

##====================================
##Extract Subdataset
##Usage: ExtractSubdataset_management in_raster out_raster {ID;ID...}

import arcpy
arcpy.env.workspace = r"C:/Workspace"

##Extract 3-band subdataset from HDF
arcpy.ExtractSubDataset_management("MHDF.hdf", "subds.tif", "5;6;7")

##Extract 1-band subdataset from NITF
arcpy.ExtractSubDataset_management("MNITF.ntf","subds_ntf.tif", "2")

Licensing information

  • ArcGIS Desktop Basic: Yes
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes