当前位置:   article > 正文

gdal.Translate和gdal.Wrap支持的creationOptions(命令行中的-co参数)_gdal.translate的参数

gdal.translate的参数

在使用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>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>
  <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>BAND</Value>
    <Value>PIXEL</Value>
  </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>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-PREMULTIPLIED">YES</Value>
    <Value aliasOf="UNSPECIFIED">NO</Value>
  </Option>
  <Option name="PROFILE" type="string-select" default="GDALGeoTIFF">
    <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" default="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 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>STANDARD</Value>
    <Value>ESRI_PE</Value>
  </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>STANDARD</Value>
    <Value>ESRI_PE</Value>
  </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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122

其中<CreationOptionList>标签可用于-co参数,也可用于TranslateOptionsWarpOptions中的creationOptions参数,用法如下:

gdal.Warp(out_tif,
              mem_ds,
              options=gdal.WarpOptions(
                  creationOptions=["TILED=YES", "COMPRESS=LZW"],
                  srcSRS='EPSG:3857',
                  dstSRS='EPSG:4326'
                  )
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

当然,也可用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'/>   <Option name='JPEG_QUALITY' type='int' description='JPEG quality 1-100' default='75'/>   <Option name='JPEGTAB
LESMODE' 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 c
ompression 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='st
ring' 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>BAND</Value>       <Value>PIXEL</Value>   </Option>   <Option name='TILED' type='boolean' description='Switc
h 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' 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</Value>       <Value aliasOf='UNSPECIFIED'>NO</Value>   </Option>   <Option name='PROFILE' type='string-select' default='GDALGeoTIFF'>       <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_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_TR
ANSFERFUNCTION_BLUE' type='string' description='Transfer function for blue'/>   <Option name='TIFFTAG_TRANSFERRANGE_BLACK' type='string' description='Transfer range for black'/>   <Option name='TIFFTAG_TRANSFERR
ANGE_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>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)'>       <Value>STANDARD</Value>       <Value>ESRI_PE</Value>   </Option>   <Option name='GEOREF_SOU
RCES' 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'/>   <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.'}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号