1

I have a routine that create a mosaic from COPDEM 30M and I need to export it passing an argument to it.

The argument: -mo AREA_OR_POINT=AREA --config GTIFF_POINT_GEO_IGNORE True

The behavior I expect is the half pixel shift to NW, according to the RFC 33: GDAL RFC 33

Running gdal_translate from QGIS is fine and works just I expect, but exporting a raster with rio.to_raster method as the following, produces a raster with the AREA_OR_POINT setted to 1 (AREA), but the pixels aren't shifted to NW.

Python command: dem.rio.to_raster("data/copdem_30m/mosaic_AREA.tif", tags = {"AREA_OR_POINT": "AREA"}, GTIFF_POINT_GEO_IGNORE = True)

What is wrong with this command, since this is just what is specified in the documentation: rioxarray rio.to_raster?

The problem can be reproduced with the following scene: https://prism-dem-open.copernicus.eu/pd-desk-open-access/prismDownload/COP-DEM_GLO-30-DGED__2022_1/Copernicus_DSM_10_S17_00_W045_00.tar

2 Answers 2

1

You can set GDAL config options inside a rasterio.Env context manager:

import rioxarray
import rasterio


dem = rioxarray.open_rasterio(
    "Copernicus_DSM_10_S17_00_W045_00/DEM/Copernicus_DSM_10_S17_00_W045_00_DEM.tif",
)
with rasterio.Env(GTIFF_POINT_GEO_IGNORE=True):
    dem.rio.to_raster("data/copdem_30m/mosaic_AREA.tif", tags = {"AREA_OR_POINT": "AREA"})
1

As you mention and as noted in the GDAL GeoTiff documentation, GTIFF_POINT_GEO_IGNORE is a GDAL configuration option, not a part of the image profile.

GDAL configuration options can be specified by setting an environment variable with that name/value before calling rio.to_raster, like this:

os.environ["GTIFF_POINT_GEO_IGNORE"] = "TRUE"
dem.rio.to_raster("data/copdem_30m/mosaic_AREA.tif", tags = {"AREA_OR_POINT": "AREA"})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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