1

The coordinate system is not specified in a GeoTiff, but I know what it is. How do I edit the file using rasterio to write in the CRS? Copying it is one way (something like the following), but it's obviously not the best way:

import rasterio
from rasterio.crs import CRS

with rasterio.open("path/to/file.tif") as src:
    src.crs = CRS.from_epsg(4326)
    with rasterio.open("path/to/file-copy.tif", "w", **src.profile) as dst:
        dst.write(src.read(1))

1 Answer 1

2

Simply open the file in "r+" mode to edit the CRS.

import rasterio
from rasterio.crs import CRS

with rasterio.open("path/to/file.tif", "r+") as src:
    src.crs = CRS.from_epsg(4326)
1

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.