[Qgis-user] Python script for QGIS

LE LAMER Romain rlelamer at hotmail.fr
Sat Dec 28 06:13:56 PST 2019


Hi,
Thanks for the code but it doesn’t work :/
ERROR 5: map_11_0_309.tiff: GDALDataset::GetRasterBand(2) - Illegal band #

it is quite complex to understand and the help of gdal is not very provided…

this is what gdalinfo returns to me
For .tiff :
gdalinfo map_11_0_309.tiff
Driver: GTiff/GeoTIFF
Files: map_11_0_309.tiff
Size is 256, 256
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (-180.000000000000000,-18.632812500000000)
Pixel Size = (0.001373291015625,-0.001373291015625)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.0000000, -18.6328125) (180d 0' 0.00"W, 18d37'58.13"S)
Lower Left  (-180.0000000, -18.9843750) (180d 0' 0.00"W, 18d59' 3.75"S)
Upper Right (-179.6484375, -18.6328125) (179d38'54.38"W, 18d37'58.13"S)
Lower Right (-179.6484375, -18.9843750) (179d38'54.38"W, 18d59' 3.75"S)
Center      (-179.8242188, -18.8085938) (179d49'27.19"W, 18d48'30.94"S)
Band 1 Block=256x128 Type=Byte, ColorInterp=Palette
  Image Structure Metadata:
    NBITS=2
  Color Table (RGB with 4 entries)
    0: 60,89,96,255
    1: 109,178,200,255
    2: 138,193,212,255
    3: 161,205,220,255

For the original png :
gdalinfo map_11_0_309.png
Driver: PNG/Portable Network Graphics
Files: map_11_0_309.png
Size is 256, 256
Coordinate System is `'
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  256.0)
Upper Right (  256.0,    0.0)
Lower Right (  256.0,  256.0)
Center      (  128.0,  128.0)
Band 1 Block=256x1 Type=Byte, ColorInterp=Palette
  Image Structure Metadata:
    NBITS=2
  Color Table (RGB with 4 entries)
    0: 60,89,96,255
    1: 109,178,200,255
    2: 138,193,212,255
    3: 161,205,220,255

RGB 59,89,95,255 is missing in this tile

Is it possible, via gdal_calc.py, or goal_translate or other program (that I don’t know) to tell him:
If, in the color table, RGB 59,89,95,255 AND / OR RGB 60,89,96,255 are present it is necessary to replace them with RGB 255, 255, 255, 255 and all the other entries are to be replaced by RGB 0, 0, 0 , 255 ?

which would only make 2 entries in the color table on 1 band.

Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20191228/c596f324/attachment.html>


More information about the Qgis-user mailing list