Geographic Information Systems Asked by snookrun on June 20, 2021
I am using rasterio to convert some png files to geotiff files.
My input is a geotiff and I do some processing to output a geotiff file using the following command:
temp = cv2.imread(file)
temp = cv2.cvtColor(temp, cv2.COLOR_BGR2RGB)
src = rasterio.open(geo_file)
tmp_outpath = os.path.join(file.replace('.png', '.tif'))
with rasterio.open(tmp_outpath, 'w', driver='GTiff', height=src.height, width=src.width,
count=temp.shape[2], crs=src.crs, transform=src.transform, dtype=rasterio.uint8) as dest_tiff:
for i in range(temp.shape[2]):
dest_tiff.write(temp[:, :, i], i + 1)
where file
is my processed png file and has the same dimension as the geo_file
.
In the remote machine, the geotiff is not saved with the georeferencing I had extracted out from geo_file
. The bug is occuring in a remote VM but works perfectly fine on my machine.
Turns out I had save the wrong file as tif. I was saving png as tif hence, the resultant tif image does not have any georeferencing. The above code works perfectly fine.
Correct answer by snookrun on June 20, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP