Skip to content

RS_AsGeoTiff

Encodes a raster as a GeoTIFF and returns the bytes as binary, with optional compression and tiling.

Usage

binary RS_AsGeoTiff(rast: raster)
binary RS_AsGeoTiff(rast: raster, tile_size: integer)
binary RS_AsGeoTiff(rast: raster, compression: string, quality: double)
binary RS_AsGeoTiff(rast: raster, compression: string, quality: double, tile_size: integer)
binary RS_AsGeoTiff(rast: raster, compression: string, quality: double, tile_width: integer, tile_height: integer)

Arguments

  • rast (raster): Input raster
  • compression (string)
  • quality (double)
  • tile_width (integer): Tile width in pixels. When given together with tile_height, the GeoTIFF is written tiled rather than stripped. TIFF tile dimensions must be multiples of 16.
  • tile_height (integer): Tile height in pixels; must be a multiple of 16.
  • tile_size (integer)

[!WARNING]

Experimental. This function is experimental; its behavior may change without notice.

Description

RS_AsGeoTiff encodes a raster as a GeoTIFF (via GDAL) and returns the file bytes as a binary value — the inverse of reading a GeoTIFF into a raster. The result is NULL for a NULL raster. A NULL option argument means “not specified”: e.g. a NULL compression writes an uncompressed GeoTIFF rather than propagating NULL to the result.

The two-argument form RS_AsGeoTiff(raster, tile_size) writes a tiled GeoTIFF with square tile_size blocks. Compression is selected by name; a JPEG quality factor and explicit tile dimensions can be supplied via the longer overloads.

Examples

SELECT RS_AsGeoTiff(RS_Example()) IS NOT NULL;
┌────────────────────────────────────────┐
│ rs_asgeotiff(rs_example()) IS NOT NULL │
│                 boolean                │
╞════════════════════════════════════════╡
│ true                                   │
└────────────────────────────────────────┘
SELECT RS_AsGeoTiff(RS_Example(), 16) IS NOT NULL;
┌──────────────────────────────────────────────────┐
│ rs_asgeotiff(rs_example(),Int64(16)) IS NOT NULL │
│                      boolean                     │
╞══════════════════════════════════════════════════╡
│ true                                             │
└──────────────────────────────────────────────────┘
SELECT RS_AsGeoTiff(RS_Example(), 'DEFLATE', 0.85) IS NOT NULL;
┌──────────────────────────────────────────────────────────────────────┐
│ rs_asgeotiff(rs_example(),Utf8("DEFLATE"),Float64(0.85)) IS NOT NULL │
│                                boolean                               │
╞══════════════════════════════════════════════════════════════════════╡
│ true                                                                 │
└──────────────────────────────────────────────────────────────────────┘
SELECT RS_AsGeoTiff(RS_Example(), 'LZW', 0.85, 16, 16) IS NOT NULL;
┌──────────────────────────────────────────────────────────────────────────────┐
│ rs_asgeotiff(rs_example(),Utf8("LZW"),Float64(0.85),Int64(16),Int64(16)) IS  │
│                                   NOT NULL…                                  │
╞══════════════════════════════════════════════════════════════════════════════╡
│ true                                                                         │
└──────────────────────────────────────────────────────────────────────────────┘