I’m trying to read in data from the DWD opendata (in DX format) and write out a GeotTIFF format that can be understood by GDAL.
I’m following very closely the following the oficial tutorial.
I have read in the data in radial coordinates with
wrl.io.read_dx, then I have obtained the coordinates of the data points in the projected coordinates with
wrl.georef.spherical_to_xyz. This gives me also the projection used:
Finally, I have interpolated the data into a regular grid in the Azimutal Equidistant projection with
wrl.comp.togrid. So far, this is basically following the tutorial.
Now, I’d like to write this as a GeoTiff with rasterio. The idea is that I have to define the metadata, i.e. two things:
- the crs, which I already have as it was given by the
wrl.georef.spherical_to_xyzfunction of wradlib. For translating the data between wradlib and rasterio, I use
crs = rasterio.crs.CRS.from_proj4(rad.ExportToProj4()
- the affine transformation
The second one is what I don’t know. I have left this undefined in rasterio when writing the GeoTiff, which basically is filled in with an identity transformation. I have imported the result GeoTiff into QGIS and the result is that the image is correctly centered where it should be, but it is tiny. The problem, obviously, is that QGIS is interpreting the units as meters (as claimed by the WKT), therefore my image, of size 400x400 pixels, is interpreted as size 400 m x 400 m, whereas it should be 128 km x 128 km.
How can I calculate the affine transformation that informs rasterio about the actual size of the image?