Message posté par : LPlante
----------------------------------------
Bonjour, D'après la doc gdal, la format de sortie est parametrable avec -ot
<type> Mais avec une codification qui n'est pas precisé, curieux ..
Force the output image bands to have a specific data type supported by the driver,
which may be one of the following: Byte, Int8, UInt16, Int16, UInt32, Int32, UInt64,
Int64, Float32, Float64, CInt16, CInt32, CFloat32 or CFloat64.
Le chat corrigerait ton script comme ca , tu retrouves bien le data_type en parametre
from qgis.core import QgsProject, QgsRasterLayer
import processing
import os
project = QgsProject.instance()
# Récupération des couches raster
raster_layers = [layer for layer in project.mapLayers().values() if isinstance(layer,
QgsRasterLayer)]
raster_paths = [layer.source() for layer in raster_layers]
print("Couches raster détectées :", [layer.name() for layer in raster_layers])
output_dir = os.path.expanduser("~/Documents")
output_path = os.path.join(output_dir, "raster_fusion.tif")
# Fusion des rasters avec type de données forcé
processing.run(
"gdal:merge",
{
"INPUT": raster_paths,
"PCT": False,
"SEPARATE": False,
"NODATA_INPUT": None,
"NODATA_OUTPUT": None,
"OPTIONS": "",
"DATA_TYPE": 5, # ⚠️ 5 = Float32
"OUTPUT": output_path
}
)
print("Raster fusionné créé :", output_path)
Pour info, la codif du type
| Code | Type GDAL | Description |
| ---- | --------- | -------------------------- |
| 0 | Byte | 8 bits entiers non signés |
| 1 | Int16 | 16 bits entiers signés |
| 2 | UInt16 | 16 bits entiers non signés |
| 3 | Int32 | 32 bits entiers signés |
| 4 | UInt32 | 32 bits entiers non signés |
| 5 | Float32 | 32 bits flottants |
| 6 | Float64 | 64 bits flottants |
----------------------------------------
Le message est situé
https://georezo.net/forum/viewtopic.php?pid=374722#p374722
Pour y répondre : qgis_fr(a)ml.georezo.net ou reply de votre messagerie
Pour vous désabonner connectez-vous sur le forum puis Profil / Abonnement
--
Association GeoRezo - le portail géomatique
https://georezo.net