0

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:

Georeferencing using GDAL?

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

Geographos
  • 4,087
  • 2
  • 27
  • 88
  • Believe the error message and remove -co PREDICTOR=2 from the command. See if some other errors remain. --config GDAL_PDF_BANDS 4 does not make sense with TIFF output, configuration option is for PDF. – user30184 Jan 21 '22 at 09:52
  • Now I get: 'co' is not recognized as an internal or external command, operable program or batch file. – Geographos Jan 21 '22 at 14:09
  • Show your current command. – user30184 Jan 21 '22 at 14:21
  • gdal_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 C:\my\GDAL\cloakpN50E021.png C:\my\GDAL\cloakpN50E021.tif – Geographos Jan 21 '22 at 14:30
  • You have a typo - co NUM_THREADS . Remove the space that truncates the command. – user30184 Jan 21 '22 at 14:34
  • Ok I did and now: ERROR 6: Unknown option name '-a_ullr' – Geographos Jan 21 '22 at 14:36
  • Copy-pasted your command gdal_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.tif and it works for me. – user30184 Jan 21 '22 at 14:48
  • Yesh! Now it works perfectly! Could you explain how to learn the GDAL commands? – Geographos Jan 21 '22 at 14:54
  • Use the GDAL site https://gdal.org/, study old questions and answers in gis.stackexchange, read tutorials from the web, and experiment. – user30184 Jan 21 '22 at 16:01

0 Answers0