0

Following my problem described here:

Georeferencing PNG image by GDAL in QGIS

I would like to make some batch image georeference in GDAL. Unfortunately I couldn't find the reasonable solution for it. The problems, which were undertaken in the links below:

https://stackoverflow.com/questions/58532501/batch-command-for-a-gdal-script Georeferencing multiple images as GeoTIFF (same size and extents) in QGIS Georeference multiple jpg through GDAL

was applied for the same size and extensions.

I need this solution for various sizes and extensions, as I deal with the big area including even 20 files such as described in the problem before.

My code so far looks like this:

  gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co 
  ZLEVEL=9 -co TILED=YES -a_srs EPSG:4326 -a_ullr 21 51 22 50 C:\my\GDAL\cloakpN50E021.png 
  C:\my\GDAL\cloakpN50E021.tif -a_ullr 22 48 23 49 C:\my\GDAL\cloakpN49E022.png 
  C:\my\GDAL\cloakpN49E022.tif -a_ullr 23 48 24 49 C:\my\GDAL\cloakpN49E023.png 
  C:\my\GDAL\cloakpN49E023.tif

but I got an error:

   **ERROR 6: Too many command options**

https://stackoverflow.com/questions/41560506/gdal-translate-error-6-too-many-command-options-ot

My second approach was:

  gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co 
  ZLEVEL=9 -co TILED=YES -a_srs EPSG:4326 -a_ullr 22 48 23 49 C:\my\GDAL\cloakpN49E022.png 
  C:\my\GDAL\cloakpN49E022.tif
  gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co 
  ZLEVEL=9 -co TILED=YES -a_srs EPSG:4326 -a_ullr 23 48 24 49 C:\my\GDAL\cloakpN49E023.png 
  C:\my\GDAL\cloakpN49E023.tif

but only the first file came trhough.

What is the option for bulk georeferencing when the extension and size remains different?

ffollett
  • 53
  • 10
Geographos
  • 4,087
  • 2
  • 27
  • 88

1 Answers1

1

This is a batch file "bat_test.bat" with one line for each gdal_translate command:

gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co ZLEVEL=9 -co TILED=YES -a_srs EPSG:4326 test.png   test_out1.tif
gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co ZLEVEL=9 -co TILED=YES -a_srs EPSG:4326 test.png   test_out2.tif

Running it performs two GDAL commands

>bat_test

gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co ZLEVEL=9 -co TILED=YES -a_srs EPSG:4326 test.png test_out1.tif Input file size is 256, 256 0...10...20...30...40...50...60...70...80...90...100 - done.

gdal_translate --config GDAL_CACHEMAX 1024 -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co ZLEVEL=9 -co TILED=YES -a_srs EPSG:4326 test.png test_out2.tif Input file size is 256, 256 0...10...20...30...40...50...60...70...80...90...100 - done.

user30184
  • 65,331
  • 4
  • 65
  • 118
  • OK I will put them in one line and back to you – Geographos Aug 11 '22 at 10:53
  • I hope you do not plan to write everything on one line. You will need one line for each command just like in my example. – user30184 Aug 11 '22 at 13:36
  • This is what I've done and the result was, that just the first one was executed – Geographos Aug 12 '22 at 13:57
  • 'ZLEVEL' is not recognized as an internal or external command, operable program or batch file. this is the error I am getting right now – Geographos Aug 12 '22 at 14:21
  • It is really amazing. That error indicates that the command on a single line breaks for some reason so that ZLEVEL is not recognized to be a parameter for gdal_translate but a new command. And that only one line was executed may indicates that there is something odd add the end of the line, not just the normal CRLF end-of-line character. It may be that your text editor inserts some non-ascii characters into the batch file. – user30184 Aug 12 '22 at 15:13
  • I've already sorted this issue. Thank you for your help. When I applied 3 items instead of two I saw, that the first 2 are executed in one go and for the third one, I have to hit Enter. – Geographos Aug 12 '22 at 15:15