TransWikia.com

PNG driver chokes on raster gdal_transformed to ot byte

Geographic Information Systems Asked by adminopasswordo on March 6, 2021

I’d like to extract a part of a DEM (data.linz.govt.nz wellinton lidar dem) and analyse it using gdaldem:

$ gdalinfo /vagrant/public/assets/GeoTIFFs/17a17d1fae/lenz-mean-annual-temperature.2193.tif               
Driver: GTiff/GeoTIFF
Files: /vagrant/public/assets/GeoTIFFs/17a17d1fae/lenz-mean-annual-temperature.2193.tif
Size is 40827, 59684
Coordinate System is:
PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",
    GEOGCS["NZGD2000",
        DATUM["New_Zealand_Geodetic_Datum_2000",
            SPHEROID["GRS 1980",6378137,298.2572221010002,
                AUTHORITY["EPSG","7019"]],
            AUTHORITY["EPSG","6167"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4167"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",173],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",1600000],
    PARAMETER["false_northing",10000000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","2193"]]
Origin = (1079625.000000000000000,6229400.000000000000000)
Pixel Size = (25.000000000000000,-25.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 1079625.000, 6229400.000) (167d22'19.08"E, 33d56'49.88"S)
Lower Left  ( 1079625.000, 4737300.000) (166d 6'50.17"E, 47d18'37.53"S)
Upper Right ( 2100300.000, 6229400.000) (178d24'42.42"E, 33d57'24.89"S)
Lower Right ( 2100300.000, 4737300.000) (179d37'20.18"E, 47d19'33.76"S)
Center      ( 1589962.500, 5483350.000) (172d52'51.63"E, 40d48' 2.84"S)
Band 1 Block=256x256 Type=Int16, ColorInterp=Gray
  NoData Value=-32768
  Metadata:
    LAYER_TYPE=athematic

That my source.

$ gdal_translate -q -scale -ot Byte -a_nodata 0 -of GTiff -projwin 1744670.939733, 5432632.999810, 1759079.145998, 5417666.249587 -outsize 256 256 /vagrant/public/assets/GeoTIFFs/17a17d1fae/lenz-mean-annual-temperature.2193.tif /tmp/silverstripe-cache-php7.2.15-1+ubuntu16.04.1+deb.sury.org+1-vagrant/www-data/5ca433d05e16b

I tried all combinations, with or without scale, ot and a_nodata.

$ gdalinfo /tmp/silverstripe-cache-php7.2.15-1+ubuntu16.04.1+deb.sury.org+1-vagrant/www-data/5ca433d05e16b
Driver: GTiff/GeoTIFF
Files: /tmp/silverstripe-cache-php7.2.15-1+ubuntu16.04.1+deb.sury.org+1-vagrant/www-data/5ca433d05e16b
Size is 256, 256
Coordinate System is:
PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",
    GEOGCS["NZGD2000",
        DATUM["New_Zealand_Geodetic_Datum_2000",
            SPHEROID["GRS 1980",6378137,298.2572221010002,
                AUTHORITY["EPSG","7019"]],
            AUTHORITY["EPSG","6167"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4167"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",173],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",1600000],
    PARAMETER["false_northing",10000000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","2193"]]
Origin = (1744650.000000000000000,5432650.000000000000000)
Pixel Size = (56.250000000000000,-58.496093750000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 1744650.000, 5432650.000) (174d43'34.71"E, 41d14'40.64"S)
Lower Left  ( 1744650.000, 5417675.000) (174d43'47.53"E, 41d22'46.03"S)
Upper Right ( 1759050.000, 5432650.000) (174d53'53.08"E, 41d14'30.91"S)
Lower Right ( 1759050.000, 5417675.000) (174d54' 7.18"E, 41d22'36.25"S)
Center      ( 1751850.000, 5425162.500) (174d48'50.62"E, 41d18'38.57"S)
Band 1 Block=256x32 Type=Byte, ColorInterp=Gray
  NoData Value=0
  Metadata:
    LAYER_TYPE=athematic

gdaldem hillshade works but not slope or any of the other modes:

$ gdaldem slope /tmp/silverstripe-cache-php7.2.15-1+ubuntu16.04.1+deb.sury.org+1-vagrant/www-data/5ca433d05e16b /dev/stdout -q -of PNG

returns the error:

ERROR 6: PNG driver doesn't support data type Float32. Only eight bit (Byte) and sixteen bit (UInt16) bands supported.

How do I translate the original raster so that conforms with what gdaldem slope and co expect?

One Answer

I found my answer in the fine print: slope will output a 32-bit float and so will aspect, so no PNG without post processing.

No idea what type TRI and TPI spit out.

Color-relief however returns RGB or RGBA. I had initially missed the color map file, so this is working now.

gdaldem color-relief /tmp/silverstripe-cache-php7.2.15-1+ubuntu16.04.1+deb.sury.org+1-vagrant/www-data/5ca433d05e16b color_relief.txt /dev/stdout -q -of PNG -alpha

Answered by adminopasswordo on March 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP