基于gdal的wcs输出格式

基于gdal_translate的输出格式利用gdal_translate命令的可用性,允许生成比geoserver本机可以生成的输出格式更多的输出格式。基本思想是将gdal_翻译可以翻译、调用、压缩和返回翻译输出的文件转储到文件系统。

因此,此扩展相当于 OGR extension 对于栅格数据。

开箱即用的行为

插件开箱即用,假设如下:

  • 路径中提供了gdal_翻译

  • gdal_数据变量指向gdal数据目录(该目录存储gdal的空间参考信息)

在默认配置中,支持以下格式:

  • jpeg-2000第1部分(ISO/IEC 15444-1)

  • 地理空间PDF

  • Arc/Info ASCII Grid

  • ASCII Gridded XYZ

如果没有为上述格式(例如,默认的JPEG-2000格式依赖于 JasPer-based GDAL driver

一旦安装到GeoServer中,将在 ServiceMetadata WCS 2.0 GetCapabilities文档的一节,例如。 image/jp2application/pdf .

gdal_翻译转换能力

gdal_translate实用程序通常能够转换比此输出格式的默认设置允许的格式更多的格式,但确切的列表取决于该实用程序是如何从源代码构建的。要获取您的ogr2ogr构建可用格式的完整列表,请运行:

gdal_translate --long-usage

您将获得程序可用的完整选项集,以及支持的格式。

例如,上面使用使用libgeotiff 1.4.0、libpng 1.6、libjpeg turbo 1.3.1、libjasper 1.900.1和libecwj2 3.3编译的gdal 1.11.2生成以下输出:

Usage: gdal_translate [--help-general] [--long-usage]
    [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
          CInt16/CInt32/CFloat32/CFloat64}] [-strict]
    [-of format] [-b band] [-mask band] [-expand {gray|rgb|rgba}]
    [-outsize xsize[%] ysize[%]]
    [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* [-exponent[_bn] exp_val]*
    [-srcwin xoff yoff xsize ysize] [-projwin ulx uly lrx lry] [-epo] [-eco]
    [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value]
    [-gcp pixel line easting northing [elevation]]*
    [-mo "META-TAG=VALUE"]* [-q] [-sds]
    [-co "NAME=VALUE"]* [-stats] [-norat]
    src_dataset dst_dataset

GDAL 1.11.2, released 2015/02/10

The following format drivers are configured and support output:
  VRT: Virtual Raster
  GTiff: GeoTIFF
  NITF: National Imagery Transmission Format
  HFA: Erdas Imagine Images (.img)
  ELAS: ELAS
  AAIGrid: Arc/Info ASCII Grid
  DTED: DTED Elevation Raster
  PNG: Portable Network Graphics
  JPEG: JPEG JFIF
  MEM: In Memory Raster
  GIF: Graphics Interchange Format (.gif)
  XPM: X11 PixMap Format
  BMP: MS Windows Device Independent Bitmap
  PCIDSK: PCIDSK Database File
  PCRaster: PCRaster Raster File
  ILWIS: ILWIS Raster Map
  SGI: SGI Image File Format 1.0
  SRTMHGT: SRTMHGT File Format
  Leveller: Leveller heightfield
  Terragen: Terragen heightfield
  ISIS2: USGS Astrogeology ISIS cube (Version 2)
  ERS: ERMapper .ers Labelled
  ECW: ERDAS Compressed Wavelets (SDK 3.x)
  JP2ECW: ERDAS JPEG2000 (SDK 3.x)
  FIT: FIT Image
  JPEG2000: JPEG-2000 part 1 (ISO/IEC 15444-1)
  RMF: Raster Matrix Format
  RST: Idrisi Raster A.1
  INGR: Intergraph Raster
  GSAG: Golden Software ASCII Grid (.grd)
  GSBG: Golden Software Binary Grid (.grd)
  GS7BG: Golden Software 7 Binary Grid (.grd)
  R: R Object Data Store
  PNM: Portable Pixmap Format (netpbm)
  ENVI: ENVI .hdr Labelled
  EHdr: ESRI .hdr Labelled
  PAux: PCI .aux Labelled
  MFF: Vexcel MFF Raster
  MFF2: Vexcel MFF2 (HKV) Raster
  BT: VTP .bt (Binary Terrain) 1.3 Format
  LAN: Erdas .LAN/.GIS
  IDA: Image Data and Analysis
  LCP: FARSITE v.4 Landscape File (.lcp)
  GTX: NOAA Vertical Datum .GTX
  NTv2: NTv2 Datum Grid Shift
  CTable2: CTable2 Datum Grid Shift
  KRO: KOLOR Raw
  ARG: Azavea Raster Grid format
  USGSDEM: USGS Optional ASCII DEM (and CDED)
  ADRG: ARC Digitized Raster Graphics
  BLX: Magellan topo (.blx)
  Rasterlite: Rasterlite
  PostGISRaster: PostGIS Raster driver
  SAGA: SAGA GIS Binary Grid (.sdat)
  KMLSUPEROVERLAY: Kml Super Overlay
  XYZ: ASCII Gridded XYZ
  HF2: HF2/HFZ heightfield raster
  PDF: Geospatial PDF
  ZMap: ZMap Plus Grid

gdalúu translate能够支持的格式的完整列表可以在 GDAL site . 请注意,此输出格式只能处理基于文件且支持创建的输出。因此,例如,您将无法使用PostGIS栅格输出(因为它基于数据库)或Arc/Info二进制网格(不支持创建)。

定制

如果在默认路径中gdal_translate不可用,则不设置gdal_数据环境变量,或者如果输出格式需要调整,则 gdal_translate.xml 可以创建配置文件以自定义输出格式。文件应该放在 gdal GeoServer数据目录根目录中的文件夹。

备注

geoserver将自动检测文件的任何更改并重新加载配置,而无需重新启动。

默认配置相当于以下XML文件:

<ToolConfiguration>
  <executable>gdal_translate</executable>
  <environment>
    <variable name="GDAL_DATA" value="/usr/local/share/gdal" />
  </environment>
  <formats>
    <Format>
      <toolFormat>JPEG2000</toolFormat>
      <geoserverFormat>GDAL-JPEG2000</geoserverFormat>
      <fileExtension>.jp2</fileExtension>
      <singleFile>true</singleFile>
      <mimeType>image/jp2</mimeType>
      <type>binary</type> <!-- not really needed, it's the default -->
      <option>-co</option>
      <option>FORMAT=JP2</option>
    </Format>
    <Format>
      <toolFormat>PDF</toolFormat>
      <geoserverFormat>GDAL-PDF</geoserverFormat>
      <fileExtension>.pdf</fileExtension>
      <singleFile>true</singleFile>
      <mimeType>application/pdf</mimeType>
      <formatAdapters>
             <GrayAlphaToRGBA/>
             <PalettedToRGB/>
      </formatAdapters>
    </Format>
    <Format>
      <toolFormat>AAIGrid</toolFormat>
      <geoserverFormat>GDAL-ArcInfoGrid</geoserverFormat>
      <fileExtension>.asc</fileExtension>
      <singleFile>false</singleFile>
    </Format>
    <Format>
      <toolFormat>XYZ</toolFormat>
      <geoserverFormat>GDAL-XYZ</geoserverFormat>
      <fileExtension>.txt</fileExtension>
      <singleFile>true</singleFile>
      <mimeType>text/plain</mimeType>
      <type>text</type>
    </Format>
  </formats>
</ToolConfiguration>

该文件展示了配置元素的所有可能用法:

  • executable 如果命令位于路径中,则可以仅为gdal_translate,否则应为可执行文件的完整路径。例如,在带有自定义构建GDAL库的Linux机器上,可能是:

    <executable>/usr/local/bin/gdal_translate</executable>
    
  • environment 包含的列表 variable 元素,可用于定义应在调用gdal_translate之前设置的环境变量。例如,要设置指向GDAL数据目录的GDAL_数据环境变量,配置可能是:

    <environment>
     <variable name="GDAL_DATA" value="/usr/local/share/gdal" />
    </environment>
    
  • Format 定义单个格式,该格式由以下标记定义:

    • toolFormat :要传递给带有-of选项的gdal_translate的格式的名称(不区分大小写)。

    • geoserverFormat :是GeoServer公布的输出格式的名称

    • fileExtension :是翻译后生成的文件的扩展名(如果有)(可以省略)

    • option: can be used to add one or more options to the gdal_translate command line. As you can see by the JPEG2000 example, each item must be contained in its own option tag. You can get a full list of options by running gdal_translate --help or by visiting the GDAL website). Also, consider that each format supports specific creation options, listed in the description page for each format (for example, here is the JPEG2000 one).

    • singleFile :如果为true,则转换的输出应该是一个可以直接流回的单个文件,而无需将其包装成zip文件

    • mimeType :使用时返回的文件的mime类型 singleFile . 如果未指定 application/octet-stream 将用作默认值。

    • formatAdapters :为了成功地对输出进行编码,可能需要对覆盖范围应用的转换。仅当满足输入条件时才应用转换。

可用的格式适配器有:

  • GrayAlphaToRGBA :使用alpha通道将灰色图像扩展到RGBA(例如,对于地理空间PDF是必需的)

  • PallettedToRGB :展开调色板图像RGB(a)(例如,对于地理空间PDF是必需的)