I have a Python script which automatically downloads a tile of DEM data. However, the TIFF seems to have incorrect geolocation data and I would like an easy way to apply my own correct CRS system and extent (bbox) to the TIFF metadata. It’s so I can calibrate the extent in pysheds correctly for context (which for some reason you cannot overwrite with sgrid
).
The extent is in the form (minlat, minlong, maxlat, maxlong)
and the crs i’d like too apply to each is epsg:4326
.
I’ve tried the likes of rasterio but it seems to get confused about the image width and height. I just want to change the metadata:
with rasterio.open(file, 'w', driver="GTiff", count=1, crs="EPSG:4326",
transform=from_origin(new_extent[0], new_extent[3], raster.res[0], raster.res[1]),
width=raster.width, height=raster.height) as dst:
dst.write(data, 1)