I am not familiar with GDAL so far. Thereby I don't know how to start. By knowing the problem from the question below:
Georeferencing PNG image in QGIS when the coordinates of image corners are known
I would like to georeference the image by using the GDAL library. I don't want to play with .pgw files, because they are don't accurate enough I am afraid. Therefore I decided to use the GDAL option only for this purpose. I found similar problem here:
but it didn't work for me
I found something better, which calls the GDAL library by Python code in pyQGIS
How to call gdal_translate from Python code?
and after applying the following code:
from osgeo import gdal
ds = gdal.Open('C:\my\Desktop current\Hey\cloakpN50E021.png')
ds = gdal.Translate('C:\my\Desktop current\Hey\cloakpN50E021.tiff', ds, projWin = [-75.3,
5.5, -73.5, 3.7])
ds = None
I have only the following command:
>>>exec(open('C:/Users/k/AppData/Local/Temp/tmpxoz9p370.py'.encode('utf-8')).read())
which means, that the code is executed properly, but unfortunately I can see neither file transformed to .tiff nor the layer produced in QGIS.
What is missing here? Is it a chance to georeference the .png image this way?
I tried also the other method, by using the code below:
gdal_translate --config GDAL_PDF_BANDS 4 --config GDAL_CACHEMAX 1024 -
co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co ZLEVEL=9 -co
PREDICTOR=2 -co TILED=YES -a_srs EPSG:31255 -a_ullr 9623.23 326346.38
9933.23 326090.63 C:\my\GDAL\cloakpN50E021.png
C:\my\GDAL\cloakpN50E021.tif
but i got the bunch of errors like this:
ERROR 1: PredictorSetup:Horizontal differencing "Predictor" not supported with 2-bit samples
-co PREDICTOR=2from the command. See if some other errors remain.--config GDAL_PDF_BANDS 4does not make sense with TIFF output, configuration option is for PDF. – user30184 Jan 21 '22 at 09:52- co NUM_THREADS. Remove the space that truncates the command. – user30184 Jan 21 '22 at 14:34gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co ZLEVEL=9 -co TILED=YES -a_srs EPSG:31255 -a_ullr 9623.23 326346.38 9933.23 326090.63 test1.tif test2.tifand it works for me. – user30184 Jan 21 '22 at 14:48