[gdal-dev] gdaldem in python doesnt recognise addAlpha = True

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] gdaldem in python doesnt recognise addAlpha = True

Corina Tudorache
Hi list,

I have been trying to use gdaldem in python to set the background color to
transparent. Unfortunately gdaldem doesnt recognise addAlpha = True, i get
this error message:
TypeError: DEMProcessingOptions() got an unexpected keyword argument
'addAlpha'

ds = gdal.DEMProcessing(infile, outfile, 'color-relief', format = 'MEM',
colorFilename = '/data/file.txt', addAlpha = True)

Is there a way to fix this behaviour?
Corina



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: gdaldem in python doesnt recognise addAlpha = True

Even Rouault-2
On mercredi 6 février 2019 08:17:03 CET Corina Tudorache wrote:

> Hi list,
>
> I have been trying to use gdaldem in python to set the background color to
> transparent. Unfortunately gdaldem doesnt recognise addAlpha = True, i get
> this error message:
> TypeError: DEMProcessingOptions() got an unexpected keyword argument
> 'addAlpha'
>
> ds = gdal.DEMProcessing(infile, outfile, 'color-relief', format = 'MEM',
> colorFilename = '/data/file.txt', addAlpha = True)
>
> Is there a way to fix this behaviour?

This was added in GDAL 2.3.0
As a workaround you can use the options= keyword and format its value with
what you would put on the gdaldem command line

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: gdaldem in python doesnt recognise addAlpha = True

Corina Tudorache
Hi Even,

I am passing something like this
ds = gdal.DEMProcessing('color-relief', file, outfile, options=[-alpha], colorFilename = 'data/file.txt')

But I get an error message too:
NameError: name 'alpha' is not defined

The bash syntax would be:
gdaldem color-relief file1.tif -alpha hramp.txt file2.tif

Thanks,
Corina

On Wednesday, 6 February 2019, 16:14:56 GMT, Even Rouault <[hidden email]> wrote:


On mercredi 6 février 2019 08:17:03 CET Corina Tudorache wrote:
> Hi list,
>
> I have been trying to use gdaldem in python to set the background color to
> transparent. Unfortunately gdaldem doesnt recognise addAlpha = True, i get
> this error message:
> TypeError: DEMProcessingOptions() got an unexpected keyword argument
> 'addAlpha'
>
> ds = gdal.DEMProcessing(infile, outfile, 'color-relief', format = 'MEM',
> colorFilename = '/data/file.txt', addAlpha = True)
>
> Is there a way to fix this behaviour?

This was added in GDAL 2.3.0
As a workaround you can use the options= keyword and format its value with
what you would put on the gdaldem command line

Even

--
Spatialys - Geospatial professional services

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: gdaldem in python doesnt recognise addAlpha = True

Even Rouault-2
On mercredi 6 février 2019 16:35:40 CET Corina Tudorache wrote:
>  Hi Even,
> I am passing something like thisds = gdal.DEMProcessing('color-relief',
> file, outfile, options=[-alpha], colorFilename = 'data/file.txt')

should be

gdal.DEMProcessing(outfile, infile, "color-relief",
                   colorFilename = 'data/file.txt',
                                          options = '-alpha')

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev