# JP2ECW -- ERDAS JPEG2000 (.jp2)

GDAL supports reading and writing JPEG2000 files using the ECW SDK from ERDAS.

Coordinate system and georeferencing transformations are read, and some degree of support is included for GeoJP2 (tm) (GeoTIFF-in-JPEG2000), ERDAS GML-in-JPEG2000, and the new GML-in-JPEG2000 specification developed at OGC.

Support for the JP2ECW driver in GDAL is optional, and requires linking in external ECW SDK libraries provided by ERDAS.

## Creation Issues

The ECW 4.x SDK from ERDAS is only free for image decompression. To compress images it is necessary to build with the read/write SDK and to provide an OEM licensing key at runtime which may be purchased from ERDAS.

For those still using the ECW 3.3 SDK, images less than 500MB may be compressed for free, while larger images require licensing from ERDAS. See the licensing agreement and the LARGE_OK option.

Creation Options:

- TARGET=percent: Set the target size reduction as a percentage of the original. If not provided defaults to 75 for an 75% reduction. TARGET=0 uses lossless compression.

- PROJ=name: Name of the ECW projection string to use. Common examples are NUTM11, or GEODETIC.

- DATUM=name: Name of the ECW datum string to use. Common examples are WGS84 or NAD83.

- LARGE_OK=YES: When built with the ECW 3.x SDK this option can be set to allow compressing files larger than 500MB. It is the users responsibility to ensure that the licensing requirments for large file compression are being adhered to.

- ECW_ENCODE_KEY=key: Provide the OEM encoding key purchased from Erdas which permits encoding images. The key is is approximately 129 hex digits long. It may also be provided globally as a configuration option.

- ECW_ENCODE_COMPANY=name: Provide the name of the company ERDAS issued the OEM encoding key (see ECW_ENCODE_KEY) to. This must exactly match the name used by ERDAS in issuing the OEM key. It may also be provided globally as a configuration option.

- GMLJP2=YES/NO: Indicates whether a GML box conforming to the OGC GML in JPEG2000 specification should be included in the file. Defaults to YES.

- GeoJP2=YES/NO: Indicates whether a GML box conforming to the GeoJP2 (GeoTIFF in JPEG2000) specification should be included in the file. Defaults to YES.

- PROFILE=profile: One of BASELINE_0, BASELINE_1, BASELINE_2, NPJE or EPJE. Review the ECW SDK documentation for details on profile meanings.

- PROGRESSION=LRCP/RLCP/RPCL: Set the progression order with which the JPEG2000 codestream is written.

- CODESTREAM_ONLY=YES/NO: If set to YES, only the compressed imagery code stream will be written. If NO (the default) a JP2 package will be written around the code stream including a variety of meta information.

- LEVELS=n: See ECW SDK for details.

- LAYERS=n: See ECW SDK for details.

- PRECINCT_WIDTH=n: See ECW SDK for details.

- PRECINCT_HEIGHT=n: See ECW SDK for details.

- TILE_WIDTH=n: See ECW SDK for details.

- TILE_HEIGHT=n: See ECW SDK for details.

- INCLUDE_SOP=YES/NO: See ECW SDK for details.

- INCLUDE_EPH=YES/NO: See ECW SDK for details.

- DECOMPRESS_LAYERS=n: See ECW SDK for details.

- DECOMPRESS_RECONSTRUCTION_PARAMETER=n: See ECW SDK for details.

JPEG2000 format does not support creation of overviews since the format is already considered to be optimized for "arbitrary overviews".

## Configuration Options

The ERDAS ECW SDK supports a variety of runtime configuration options to control various features. Most of these are exposed as GDAL configuration options. See the ECW SDK documentation for full details on the meaning of these options.

- ECW_CACHE_MAXMEM=bytes: maximum bytes of RAM used for in-memory caching. If not set, up to one quarter of physical RAM will be used by the SDK for in-memory caching.

- ECW_TEXTURE_DITHER=TRUE/FALSE: This may be set to FALSE to disable dithering when decompressing ECW files. Defaults to TRUE.

- ECW_FORCE_FILE_REOPEN=TRUE/FALSE: This may be set to TRUE to force open a file handle for each file for each connection made. Defaults to FALSE.

- ECW_CACHE_MAXOPEN=number: The maximum number of files to keep open for ECW file handle caching. Defaults to unlimited.

- ECW_AUTOGEN_J2I=TRUE/FALSE: Controls whether .j2i index files should be created when opening jpeg2000 files. Defaults to TRUE.

- ECW_RESILIENT_DECODING=TRUE/FALSE: Controls whether the reader should be forgiving of errors in a file, trying to return as much data as is available. Defaults to TRUE. If set to FALSE an invalid file will result in an error.

- ECW_ENCODE_KEY, ECW_ENCODE_COMPANY: These values, as described in the creation options, may also be set as configuration options. See above.

## See Also

- Implemented as `gdal/frmts/ecw/ecwdataset.cpp`.

- ECW SDK available at erdas.com.
- GDAL ECW Build Hints