So I have done some RGB-channel extraction from a .tif file, meaning I took UAV_image.tif and I have extracted R,G,B channels on three different .tif files. Next, I did some calculations such as result = ((red^2)+(blue^2))/(blue). For all the previous operations I used mainly cv2.imwrite and tiff.imread commands. The problem is that the resulted .tif does not contains coordinates.. How can I copy the coordinates from the initial UAV_image.tif to result.tif? I tried to followed this tutorial:
Use gdalsrsinfo to get the srs of the tiff that still has the projection:
gdalsrsinfo -o wkt tiffwithsrs.tiff Then copy the output and use gdal_translate to apply it to a new tiff:
gdal_translate -a_srs '...' tiffwithoutsrs.tif newfixedtif.tif just paste your projection after the -a_srs option
(source: Using GDAL command line to copy projections)
But the result was to copy both coordinates and colors...!!! Did I do something wrong?
Also, this guy here: "Copy" Image coordinates to another image that is nd.array has a an approach that does not fit my problem, because I do not do any kind of Machine Learning training (as I see to his example - correct me If I am wrong) and I do not use nd.array.
So, the question is how do I copy coordinates from a .tif image that has coordinates to a .tif image that does not have coordinates?
File "copy_coordinates.py", line 11, in <module> dtype = UAV_image.dtype) AttributeError: 'DatasetReader' object has no attribute 'dtype'– just_learning Nov 02 '21 at 13:23.dtypes, sorry spelling error. If that doesn't work you can write the datatype your new image has as a string'uint8', 'float32'etc. – DNy Nov 02 '21 at 13:28img.shape. It gives me only height, width! Shouldn't give me also1as the number of channels? – just_learning Nov 02 '21 at 14:22img.counthttps://rasterio.readthedocs.io/en/latest/quickstart.html?highlight=count#opening-a-dataset-in-writing-mode – DNy Nov 02 '21 at 14:44A.tiftoB.tif?? In other words I do not need to store anyresult. I tried some code but it does not work and I got confused...!! – just_learning Nov 08 '21 at 15:34A.tif(which is 4 band image) toB.tif(which is 3 band image). I tried configurations on count, and the band numbers on write command, but I get errors like this guy over here: link. I have read the tutorial: link2 without finding any solution to my problem...Any ideas/help what to do? – just_learning Nov 09 '21 at 12:08