1

I'm reprojecting and changing the format of a vrt to GeoTIFF and can't seem to control metadata options with gdalwarp.

Other tools like gdal_translate have the -mo option to specify metadata options but gdalwarp doesn't.

In this case, the original .dem (CDED format) have a metadata option that says AREA_OR_POINT = POINT and the output GeoTIFF, using gdalwarp, defaults to AREA_OR_POINT = AREA.

To be honest, I don't know the significance or importance of the AREA_OR_POINT metadata option, but just like matching input to output as much as I can.

The command I'm using is:
gdalwarp -of GTiff \ -ot Int16 \ -s_srs "EPSG:4269" -t_srs "EPSG:3005" \ -tr 15 15 -r bilinear \ -wm 4096 -multi \ -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 \ -co NUM_THREADS=ALL_CPUS \ -srcnodata "-32767" \ mosaic_dem_cded_4269.vrt dem_3005.tiff

  • PS You may want to check whether your rasters line up correctly if you manually set AREA_OR_POINT=POINT , GDAL may (not sure, never tested) adjust the georeferencing by 1/2 a pixel when it sets AREA_OR_POINT=AREA - trac.osgeo.org/gdal/wiki/rfc33_gtiff_pixelispoint – user2856 Oct 18 '16 at 0:59
  • Ok, thanks. I was gonna post a question asking what that metadata option did and why it was important but that explains it. I noticed the output VRTs dont have it listed in the metadata or the output of the gdalinfo command so I'll be curious to see if gdalwarp ignores it from the source data and does some shifting in the output vrt's by defaulting to AREA_OR_POINT = AREA in the background silently. For reference, the source data is at pub.data.gov.bc.ca/datasets/175624 – SaultDon Oct 18 '16 at 1:04
4

You can warp to VRT then translate to your output GeoTIFF. This will also avoid issues that can arise when using gdalwarp to output compressed files.

gdalwarp -of VRT \
          -ot Int16 \
          -s_srs "EPSG:4269" -t_srs "EPSG:3005" \
          -tr 15 15 -r bilinear \
          -wm 4096 -multi \
          -co NUM_THREADS=ALL_CPUS \
          -srcnodata "-32767" \
          mosaic_dem_cded_4269.vrt dem_3005.vrt

gdal_translate -mo "your metadata" dem_3005.vrt dem_3005.tif

You could also pipe the output of gdalwarp to gdal_translate using the STREAMABLE_OUTPUT=YES creation option and the /vsistdout/ and /vsistdin/ virtual filenames (GDAL 2x):

 gdalwarp -of GTiff \
          -ot Int16 \
          -co STREAMABLE_OUTPUT=YES \
          -s_srs "EPSG:4269" -t_srs "EPSG:3005" \
          -tr 15 15 -r bilinear \
          -wm 4096 -multi \
          -co NUM_THREADS=ALL_CPUS \
          -srcnodata "-32767" \
          mosaic_dem_cded_4269.vrt /vsistdout/ | gdal_translate /vsistdin/ dem_3005.tif

Notes: you must use a trailing slash for /vsistdout/ and /vsistdin/ (i.e not /vsistdout and /vsistdin) and I have no idea if streaming is compatible with multithreaded warping...

  • Ah cool, never considered gdalwarp -of VRT. This is perfect because it avoids the creation of large intermediary/scratch datasets in this chain. – SaultDon Oct 18 '16 at 0:56
  • @SaultDon see edit for another option – user2856 Oct 18 '16 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.