Hello everyone,
my name is Nicolas and I am currently using the DWD Radolan format to use the precipitation forecast data (WN). Wradlib is used to convert the binary data which has worked great so far.
Right now I am struggling to get the tile borders of a coordinate.
To describe my problem a little more detailed I will provide a small walkthrough of my code:
1. Create a GeoTIFF file of the converted WN data:
f = wrl.util.get_wradlib_data_file
(path
)
data_raw, meta = wrl.io.read_radolan_composite
(f
)
proj_osr = wrl.georef.create_osr
("dwd-radolan"
)
xy_raw = wrl.georef.get_radolan_grid
(1200, 1100
) # see the format description https://www.dwd.de/DE/leistungen/radarprodukte/formatbeschreibung_wndaten.pdf?__blob=publicationFile&v=6
data, xy = wrl.georef.set_raster_origin
(data_raw, xy_raw, 'upper'
)
# change no data value (-9999) to 0
data
[data < -1000
] = 0
# transform to dbz
data_dbz = np.where
(data > 0, data / 2 - 32.5, data
)
# calculate indizes for x y data of tile relative to grid
# this probably the most interesting part for my question
indizes = np.indices(data_dbz.shape)
indizes = np.fliplr(indizes)
indizes = np.flipud(indizes)
# now i have the correct order for the relative coordinates
data = np.stack((data_dbz, indizes[0], indizes[1]))
ds = wrl.georef.create_raster_dataset(data, xy, projection=proj_osr)
wrl.io.write_raster_dataset(path + '/' + tifname, ds, 'GTiff')
After running this method I have a GeoTIFF file which is used later on and my data consists of three bands (1: precipitation value, 2: x grid coordinate, 3: y grid coordinate)
Now I use another tool (PyQGIS) to retrieve the band values for a specific coordinate.
2. Get grid border
radolan_grid_ll = wrl.georef.get_radolan_grid(1200,1100, wgs84=True)
y0 = 788 #example values of grid coordinates
x0 = 775
# print(radolan_grid_ll.shape)
print("ll: {:f} {:f} ".format(radolan_grid_ll[x0][y0][0], radolan_grid_ll[x0][y0][1]))
print("lr: {:f} {:10.4f} ".format(radolan_grid_ll[x0][y0+1][0], radolan_grid_ll[x0][y0+1][1]))
print("ur: {:10.4f} {:10.4f} ".format(radolan_grid_ll[x0+1][y0+1][0], radolan_grid_ll[x0+1][y0+1][1]))
print("ul: {:10.4f} {:10.4f} ".format(radolan_grid_ll[x0+1][y0][0], radolan_grid_ll[x0+1][y0][1]))
Now to my problem. In most of the cases the coordinate is not located in the rectangle I create from the four border coordinates. For some coordinates I would have to increase the x or y tile value by one while for other coordinates its fine.
I hope my question is understandable, if not please say that and I will try to be more precise, and someone can help me.
Thanks in advance and kind regards
Nicolas