在使用gdal_translate和gdalwarp时,使用-co
参数时有时候不知道支持哪些可选项,接下来研究一下:
$ gdal_translate.exe --format GTiff
Format Details:
Short Name: GTiff
Long Name: GeoTIFF
Supports: Raster
Extensions: tif tiff
Mime Type: image/tiff
Help Topic: frmt_gtiff.html
Supports: Subdatasets
Supports: Open() - Open existing dataset.
Supports: Create() - Create writable dataset.
Supports: CreateCopy() - Create dataset by copying another.
Supports: Virtual IO - eg. /vsimem/
Creation Datatypes: Byte UInt16 Int16 UInt32 Int32 Float32 Float64 CInt16 CInt32 CFloat32 CFloat64
<CreationOptionList>
<Option name="COMPRESS" type="string-select">
<Value>NONEValue>
<Value>LZWValue>
<Value>PACKBITSValue>
<Value>JPEGValue>
<Value>CCITTRLEValue>
<Value>CCITTFAX3Value>
<Value>CCITTFAX4Value>
<Value>DEFLATEValue>
<Value>LZMAValue>
<Value>ZSTDValue>
<Value>WEBPValue>
Option>
<Option name="PREDICTOR" type="int" description="Predictor Type (1=default, 2=horizontal differencing, 3=floating point prediction)" />
<Option name="DISCARD_LSB" type="string" description="Number of least-significant bits to set to clear as a single value or comma-separated list of values for per-band values" />
<Option name="JPEG_QUALITY" type="int" description="JPEG quality 1-100" default="75" />
<Option name="JPEGTABLESMODE" type="int" description="Content of JPEGTABLES tag. 0=no JPEGTABLES tag, 1=Quantization tables only, 2=Huffman tables only, 3=Both" default="1" />
<Option name="ZLEVEL" type="int" description="DEFLATE compression level 1-9" default="6" />
<Option name="LZMA_PRESET" type="int" description="LZMA compression level 0(fast)-9(slow)" default="6" />
<Option name="ZSTD_LEVEL" type="int" description="ZSTD compression level 1(fast)-22(slow)" default="9" />
<Option name="WEBP_LEVEL" type="int" description="WEBP quality level. Low values result in higher compression ratios" default="75" />
<Option name="NUM_THREADS" type="string" description="Number of worker threads for compression. Can be set to ALL_CPUS" default="1" />
<Option name="NBITS" type="int" description="BITS for sub-byte files (1-7), sub-uint16 (9-15), sub-uint32 (17-31), or float32 (16)" />
<Option name="INTERLEAVE" type="string-select" default="PIXEL">
<Value>BANDValue>
<Value>PIXELValue>
Option>
<Option name="TILED" type="boolean" description="Switch to tiled format" />
<Option name="TFW" type="boolean" description="Write out world file" />
<Option name="RPB" type="boolean" description="Write out .RPB (RPC) file" />
<Option name="RPCTXT" type="boolean" description="Write out _RPC.TXT file" />
<Option name="BLOCKXSIZE" type="int" description="Tile Width" />
<Option name="BLOCKYSIZE" type="int" description="Tile/Strip Height" />
<Option name="PHOTOMETRIC" type="string-select">
<Value>MINISBLACKValue>
<Value>MINISWHITEValue>
<Value>PALETTEValue>
<Value>RGBValue>
<Value>CMYKValue>
<Value>YCBCRValue>
<Value>CIELABValue>
<Value>ICCLABValue>
<Value>ITULABValue>
Option>
<Option name="SPARSE_OK" type="boolean" description="Should empty blocks be omitted on disk?" default="FALSE" />
<Option name="ALPHA" type="string-select" description="Mark first extrasample as being alpha">
<Value>NON-PREMULTIPLIEDValue>
<Value>PREMULTIPLIEDValue>
<Value>UNSPECIFIEDValue>
<Value aliasOf="NON-PREMULTIPLIED">YESValue>
<Value aliasOf="UNSPECIFIED">NOValue>
Option>
<Option name="PROFILE" type="string-select" default="GDALGeoTIFF">
<Value>GDALGeoTIFFValue>
<Value>GeoTIFFValue>
<Value>BASELINEValue>
Option>
<Option name="PIXELTYPE" type="string-select">
<Value>DEFAULTValue>
<Value>SIGNEDBYTEValue>
Option>
<Option name="BIGTIFF" type="string-select" description="Force creation of BigTIFF file">
<Value>YESValue>
<Value>NOValue>
<Value>IF_NEEDEDValue>
<Value>IF_SAFERValue>
Option>
<Option name="ENDIANNESS" type="string-select" default="NATIVE" description="Force endianness of created file. For DEBUG purpose mostly">
<Value>NATIVEValue>
<Value>INVERTEDValue>
<Value>LITTLEValue>
<Value>BIGValue>
Option>
<Option name="COPY_SRC_OVERVIEWS" type="boolean" default="NO" description="Force copy of overviews of source dataset (CreateCopy())" />
<Option name="SOURCE_ICC_PROFILE" type="string" description="ICC profile" />
<Option name="SOURCE_PRIMARIES_RED" type="string" description="x,y,1.0 (xyY) red chromaticity" />
<Option name="SOURCE_PRIMARIES_GREEN" type="string" description="x,y,1.0 (xyY) green chromaticity" />
<Option name="SOURCE_PRIMARIES_BLUE" type="string" description="x,y,1.0 (xyY) blue chromaticity" />
<Option name="SOURCE_WHITEPOINT" type="string" description="x,y,1.0 (xyY) whitepoint" />
<Option name="TIFFTAG_TRANSFERFUNCTION_RED" type="string" description="Transfer function for red" />
<Option name="TIFFTAG_TRANSFERFUNCTION_GREEN" type="string" description="Transfer function for green" />
<Option name="TIFFTAG_TRANSFERFUNCTION_BLUE" type="string" description="Transfer function for blue" />
<Option name="TIFFTAG_TRANSFERRANGE_BLACK" type="string" description="Transfer range for black" />
<Option name="TIFFTAG_TRANSFERRANGE_WHITE" type="string" description="Transfer range for white" />
<Option name="STREAMABLE_OUTPUT" type="boolean" default="NO" description="Enforce a mode compatible with a streamable file" />
<Option name="GEOTIFF_KEYS_FLAVOR" type="string-select" default="STANDARD" description="Which flavor of GeoTIFF keys must be used">
<Value>STANDARDValue>
<Value>ESRI_PEValue>
Option>
CreationOptionList>
<OpenOptionList>
<Option name="NUM_THREADS" type="string" description="Number of worker threads for compression. Can be set to ALL_CPUS" default="1" />
<Option name="GEOTIFF_KEYS_FLAVOR" type="string-select" default="STANDARD" description="Which flavor of GeoTIFF keys must be used (for writing)">
<Value>STANDARDValue>
<Value>ESRI_PEValue>
Option>
<Option name="GEOREF_SOURCES" type="string" description="Comma separated list made with values INTERNAL/TABFILE/WORLDFILE/PAM/NONE that describe the priority order for georeferencing" default="PAM,INTERNAL,TABFILE,WORLDFILE" />
<Option name="SPARSE_OK" type="boolean" description="Should empty blocks be omitted on disk?" default="FALSE" />
OpenOptionList>
Other metadata items:
LIBTIFF=LIBTIFF, Version 4.0.10
Copyright (c) 1988-1996 Sam Leffler
Copyright (c) 1991-1996 Silicon Graphics, Inc.
其中
标签可用于-co参数,也可用于TranslateOptions
和WarpOptions
中的creationOptions
参数,用法如下:
gdal.Warp(out_tif,
mem_ds,
options=gdal.WarpOptions(
creationOptions=["TILED=YES", "COMPRESS=LZW"],
srcSRS='EPSG:3857',
dstSRS='EPSG:4326'
)
当然,也可用python脚本查询支持的creationOptions
参数:
In [1]: from osgeo import gdal
In [2]: driver = gdal.GetDriverByName("GTiff")
In [3]: driver.GetMetadata()
Out[3]:
{'DCAP_CREATE': 'YES',
'DCAP_CREATECOPY': 'YES',
'DCAP_OPEN': 'YES',
'DCAP_RASTER': 'YES',
'DCAP_VIRTUALIO': 'YES',
'DMD_CREATIONDATATYPES': 'Byte UInt16 Int16 UInt32 Int32 Float32 Float64 CInt16 CInt32 CFloat32 CFloat64',
'DMD_CREATIONOPTIONLIST': "<CreationOptionList> <Option name='COMPRESS' type='string-select'> <Value>NONE</Value> <Value>LZW</Value> <Value>PACKBITS</Value> <Value>JPEG</Value> <
Value>CCITTRLE</Value> <Value>CCITTFAX3</Value> <Value>CCITTFAX4</Value> <Value>DEFLATE</Value> <Value>LZMA</Value> <Value>ZSTD</Value> <Value>WEBP</Value> </Option> <Opti
on name='PREDICTOR' type='int' description='Predictor Type (1=default, 2=horizontal differencing, 3=floating point prediction)'/> <Option name='DISCARD_LSB' type='string' description='Number of least-significa
nt bits to set to clear as a single value or comma-separated list of values for per-band values'/> 'Write out _RPC.TXT file'/> <Option name='BLOCKXSIZE' type='int' description='Tile Width'/> <Option name='BLOCKYSIZE' type='int' description='Tile/Strip Height'/> <Option name='PHOTOMETRIC' typ
e='string-select'> <Value>MINISBLACK</Value> <Value>MINISWHITE</Value> <Value>PALETTE</Value> <Value>RGB</Value> <Value>CMYK</Value> <Value>YCBCR</Value> <Value>CIELAB</
Value> <Value>ICCLAB</Value> <Value>ITULAB</Value> </Option> <Option name='SPARSE_OK' type='boolean' description='Should empty blocks be omitted on disk?' default='FALSE'/> <Option name='ALPHA'
type='string-select' description='Mark first extrasample as being alpha'> <Value>NON-PREMULTIPLIED</Value> <Value>PREMULTIPLIED</Value> <Value>UNSPECIFIED</Value> <Value aliasOf='NON-PRE
MULTIPLIED'>YES NO <Value>GDALGeoTIFF</Value> <Value>GeoTIFF</Value
> <Value>BASELINE</Value> </Option> <Option name='PIXELTYPE' type='string-select'> <Value>DEFAULT</Value> <Value>SIGNEDBYTE</Value> </Option> <Option name='BIGTIFF' type='string-select'
description='Force creation of BigTIFF file'> <Value>YES</Value> <Value>NO</Value> <Value>IF_NEEDED</Value> <Value>IF_SAFER</Value> </Option> <Option name='ENDIANNESS' type='string-select' d
efault='NATIVE' description='Force endianness of created file. For DEBUG purpose mostly'> <Value>NATIVE</Value> <Value>INVERTED</Value> <Value>LITTLE</Value> <Value>BIG</Value> </Option
> <Option name='COPY_SRC_OVERVIEWS' type='boolean' default='NO' description='Force copy of overviews of source dataset (CreateCopy())'/> <Option name='SOURCE_ICC_PROFILE' type='string' description='ICC profi
le'/> > <
Option name='SOURCE_PRIMARIES_BLUE' type='string' description='x,y,1.0 (xyY) blue chromaticity'/> <Option name='SOURCE_WHITEPOINT' type='string' description='x,y,1.0 (xyY) whitepoint'/> <Option name='TIFFTAG
_TRANSFERFUNCTION_RED' type='string' description='Transfer function for red'/> <Value>STANDARD</Value> <Value>ESRI_PE</Value> </Option></CreationOptionList>",
'DMD_EXTENSION': 'tif',
'DMD_EXTENSIONS': 'tif tiff',
'DMD_HELPTOPIC': 'frmt_gtiff.html',
'DMD_LONGNAME': 'GeoTIFF',
'DMD_MIMETYPE': 'image/tiff',
'DMD_OPENOPTIONLIST': "<OpenOptionList> <Option name='NUM_THREADS' type='string' description='Number of worker threads for compression. Can be set to ALL_CPUS' default='1'/> <Option name='GEOTIFF_KEYS_FLAVO
R' type='string-select' default='STANDARD' description='Which flavor of GeoTIFF keys must be used (for writing)'> STANDARD ESRI_PE > <Optio
n name='SPARSE_OK' type='boolean' description='Should empty blocks be omitted on disk?' default='FALSE'/></OpenOptionList>",
'DMD_SUBDATASETS': 'YES',
'LIBTIFF': 'LIBTIFF, Version 4.0.10\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc.'}