Bonjour,
je suis confronté à un truc qui me dépasse ...

Ce code me permet de convertir un png en tiff en lui attribuant un géoréférencement et une projection. (je passe le découpage en plusieurs script)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
ficlist = open("fic-list.py", "w") # Ouvre un fichier.
for column in range(1024):
	fname = "fic_" + str(column) + ".py"
	fichier = open(fname, "w") # Ouvre un fichier.
	for line in range(512): 
		ulx = (360 * (column / 1024)) - 180
		uly = 90 - (180 * (line / 512))
		lrx = ulx + 0.3515625
		lry = uly - 0.3515625
		posits = str(ulx) + ' ' + str(uly) + ' ' + str(lrx) + ' ' + str(lry)
		fic_in = ' map_11_' + str(column) + '_' + str(line) + '.png'
		fic_out = ' map_11_' + str(column) + '_' + str(line) + '.tiff'
		ligne = 'gdal_translate -a_srs EPSG:4326 -a_ullr ' + posits + fic_in + fic_out + '\n'
		fichier.write(ligne) # Ecris la ligne.
	fichier.close() # Ferme le fichier 
	ficlist.write(fname + '\n') # Ecris la ligne.
ficlist.close() # Ferme le fichier
Si je lance fic_0.py qui contient :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
gdal_translate -a_srs EPSG:4326 -a_ullr -180.0 90.0 -179.6484375 89.6484375 map_11_0_0.png map_11_0_0.tiff
gdal_translate -a_srs EPSG:4326 -a_ullr -180.0 89.6484375 -179.6484375 89.296875 map_11_0_1.png map_11_0_1.tiff
gdal_translate -a_srs EPSG:4326 -a_ullr -180.0 89.296875 -179.6484375 88.9453125 map_11_0_2.png map_11_0_2.tiff
[...]
gdal_translate -a_srs EPSG:4326 -a_ullr -180.0 -89.6484375 -179.6484375 -90.0 map_11_0_511.png map_11_0_511.tiff
j'obtiens
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
  File "fic_0.py", line 1
    gdal_translate -a_srs EPSG:4326 -a_ullr -180.0 90.0 -179.6484375 89.6484375 map_11_0_0.png map_11_0_0.tiff
                             ^
SyntaxError: invalid syntax
Si je rentre à la main, sur le terminal, cette même instruction, ça fonctionne ... 🤔
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
gdal_translate -a_srs EPSG:4326 -a_ullr -180.0 90.0 -179.6484375 89.6484375 map_11_0_0.png map_11_0_0.tiff
Input file size is 256, 256
0...10...20...30...40...50...60...70...80...90...100 - done.
Je comprends pas mon erreur ...
Merci