Help _TypeError_rasterise2Image() got an unexpected keyword argument 'gdalFormat'

57 views
Skip to first unread message

Beatriz Pierri Daunt

unread,
Aug 24, 2017, 5:38:52 PM8/24/17
to RSGISLib Support
Dear all

I am having a problem using a script that I have already used it in another 3 computers:

Started .0..10..20..30..40..50..60..70..80..90..100. Complete.
Started .0..10..20..30..40..50..60..70..80..90..100. Complete.
Writing Stats (Mean, ) to Output RAT
Traceback (most recent call last):
  File "classificaobjetorf.py", line 44, in <module>
    ratutils.populateClumpsWithClassTraining(clumpsImg, classesDict, tmpPath, classesIntCol, classesNameCol)
  File "/home/beatriz/anaconda3/envs/osgeo/lib/python3.5/site-packages/rsgislib/rastergis/ratutils.py", line 1171, in populateClumpsWithClassTraining
    vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat="KEA", burnVal=classIntVal)
TypeError: rasterise2Image() got an unexpected keyword argument 'gdalFormat'

The gdalFormat is ok, is "KEA".

Initially, I thought that it could be an installation problem, but I've removed the osgeo, installed all packages again and the error has continued.

Best wishes
Thank you very much
Beatriz


Nathan Thomas

unread,
Aug 24, 2017, 5:43:03 PM8/24/17
to Beatriz Pierri Daunt, RSGISLib Support
Hi Beatriz,

What if you just try:

vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, ‘KEA', ‘classIntVal’)


Nathan

Daniel Clewley

unread,
Aug 25, 2017, 1:18:07 AM8/25/17
to Nathan Thomas, Beatriz Pierri Daunt, RSGISLib Support
Hi Beatriz,

This looks like a bug, will fix for the next release. I’ve opened an issue about it: https://bitbucket.org/petebunting/rsgislib/issues/45/consistency-of-name-for-gdal-format

Until the next release, a quick fix would be to edit the file /home/beatriz/anaconda3/envs/osgeo/lib/python3.5/site-packages/rsgislib/rastergis/ratutils.py on line 1171 and change from:

vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat=“KEA", burnVal=classIntVal)

to:

vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, “KEA”, burnVal=classIntVal)

As Nathan suggested.

Thanks,

Dan

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.

Beatriz Pierri Daunt

unread,
Sep 5, 2017, 3:18:25 AM9/5/17
to Daniel Clewley, Nathan Thomas, RSGISLib Support
Dear Dr. Daniel and Dr. Nathan,

Thank you very much, it has perfectly correct the problem.

I am sorry for taking so long to aswer.

Best wishes
Beatriz

2017-08-25 7:18 GMT+02:00 Daniel Clewley <daniel....@gmail.com>:
Hi Beatriz,

This looks like a bug, will fix for the next release. I’ve opened an issue about it: https://bitbucket.org/petebunting/rsgislib/issues/45/consistency-of-name-for-gdal-format

Until the next release, a quick fix would be to edit the file /home/beatriz/anaconda3/envs/osgeo/lib/python3.5/site-packages/rsgislib/rastergis/ratutils.py on line 1171 and change from:

vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat=“KEA", burnVal=classIntVal)

to:

vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, “KEA”, burnVal=classIntVal)

As Nathan suggested.

Thanks,

Dan
On 24 Aug 2017, at 22:42, Nathan Thomas <nmtho...@gmail.com> wrote:

Hi Beatriz,

What if you just try:

vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, ‘KEA', ‘classIntVal’)


Nathan





On Aug 24, 2017, at 2:38 PM, Beatriz Pierri Daunt <beat...@gmail.com> wrote:

vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat="KEA", burnVal=classIntVal)


--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsubscribe@googlegroups.com.
To post to this group, send email to rsgislib-support@googlegroups.com.

Felipe Dantas

unread,
Dec 2, 2017, 5:41:30 PM12/2/17
to RSGISLib Support
Hello dear
How to get around this bug?

Nathan Thomas

unread,
Dec 2, 2017, 5:42:56 PM12/2/17
to Felipe Dantas, RSGISLib Support
May be a bug with the command. Instead of gdalFormat=‘KEA’ just try ‘KEA’

Nathan

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.

Felipe Dantas

unread,
Dec 2, 2017, 5:47:59 PM12/2/17
to RSGISLib Support
Sorry for my ignorance, because I am a new user. But where to modify the command (gdalFormat = 'KEA' to 'KEA'), for example in the code of page 50 of the tutorial http://www.rsgislib.org/docs/RSGISLib_IntroTraining_Jan2017.pdf

Nathan Thomas

unread,
Dec 2, 2017, 5:53:29 PM12/2/17
to RSGISLib Support


Begin forwarded message:

From: Nathan Thomas <nmtho...@gmail.com>
Subject: Re: [rsgislib-support] Help _TypeError_rasterise2Image() got an unexpected keyword argument 'gdalFormat'
Date: 2 December 2017 at 14:51:57 GMT-8
To: Felipe Dantas <felipera...@gmail.com>

sorry, I should have given a better explanation.

Change the line:

 vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat="KEA", burnVal=classIntVal)

to:

 vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, "KEA", burnVal=classIntVal)

It should be in the code “classificaobjetorf.py” on line 44.

(Its in chapter 5 on page 46.)

Nathan

Felipe Dantas

unread,
Dec 2, 2017, 6:14:03 PM12/2/17
to RSGISLib Support
Nathan, this code you refer to I performed without error. However, I am referring to the code in line 55 on page 50 of Chapter 5.2 (Object Based)

classesDict = dict()
classesDict['Agricultura'] = [1, './07_treinamento/Amostras/agricultura.shp']
classesDict['Agua'] = [2, './07_treinamento/Amostras/agua.shp']
classesDict['AreaUrbana'] = [3, './07_treinamento/Amostras/area_urbana.shp']
classesDict['Queimada'] = [4, './07_treinamento/Amostras/queimada.shp']
classesDict['Queimada'] = [5, './07_treinamento/Amostras/sombra.shp']
classesDict['Sombra'] = [6, './07_treinamento/Amostras/solo_exposto.shp']
classesDict['VegetacaoArborea'] = [7, './07_treinamento/Amostras/vegetacao_arborea.shp']
classesDict['VeetacaoMista'] = [8, './07_treinamento/Amostras/vegetacao_mista.shp']
tmpPath = './tmp'
classesIntColIn = 'ClassInt'
classesNameCol = 'ClassStr'
ratutils.populateClumpsWithClassTraining(clumpsImg, classesDict, tmpPath, classesIntColIn, classesNameCol)
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsub...@googlegroups.com.

Felipe Dantas

unread,
Dec 2, 2017, 6:30:13 PM12/2/17
to RSGISLib Support
my error

(geobia) mappa@mappapc:~/github/L590$ python PerformObjClass.py 
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Writing Stats (Mean, ) to Output RAT
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Writing Stats (Mean, ) to Output RAT
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Writing Stats (Mean, ) to Output RAT
Traceback (most recent call last):
  File "PerformObjClass.py", line 56, in <module>
    ratutils.populateClumpsWithClassTraining(clumpsImg, classesDict, tmpPath, classesIntColIn, classesNameCol)
  File "/home/mappa/.conda/envs/geobia/lib/python3.6/site-packages/rsgislib/rastergis/ratutils.py", line 1171, in populateClumpsWithClassTraining
    vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat="KEA", burnVal=classIntVal)
TypeError: rasterise2Image() got an unexpected keyword argument 'gdalFormat'

Nathan Thomas

unread,
Dec 2, 2017, 7:07:10 PM12/2/17
to Felipe Dantas, RSGISLib Support
ok, there’s something not right here.

The error says:

File "PerformObjClass.py", line 56, in <module>
    ratutils.populateClumpsWithClassTraining(clumpsImg, classesDict, tmpPath, classesIntColIn, classesNameCol)
  File "/home/mappa/.conda/envs/geobia/lib/python3.6/site-packages/rsgislib/rastergis/ratutils.py", line 1171, in populateClumpsWithClassTraining
    vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat="KEA", burnVal=classIntVal)
TypeError: rasterise2Image() got an unexpected keyword argument ‘gdalFormat'

Have you checked line 56 of “PerformObjClass.py”. What does this line say?

Nathan Thomas

unread,
Dec 2, 2017, 8:14:28 PM12/2/17
to Felipe Dantas, RSGISLib Support, Pete Bunting
Hi Pete,

We solved this by modifying ratutils.py. Felipe is running rsgislib 3.2.0. I remember this bug coming up before - can’t remember if it’s come up on the google group or if I tracked it down myself, so not sure if it’s in the most recent release. If it’s not, here is a heads up before the next release.

Cheers, Nathan

On 2 Dec 2017, at 16:28, Nathan Thomas <nmtho...@gmail.com> wrote:

Ok, I think the problem here is in the source code. I think populateClumpsWithTraining calls raserize2Image and thats where the bug is.

An immediate solution could be the following:

1) Find the source code for ratutils.py

mine is located in /Users/Nathan/miniconda3/pkgs/rsgislib-3.3.1-py35_1/lib/python3.5/site-packages/rsgislib/rastergis

in ratutils.py look for the line: vectorutils.rasterise2Image(classShpFile, clumpsImg, classImgFile, gdalFormat="KEA", burnVal=classIntVal)

it should be on line 1171. Here change gdalFormat=“KEA” to “KEA”

Nathan


On 2 Dec 2017, at 16:14, Felipe Dantas <felipera...@gmail.com> wrote:

My script is the same as the one in Chapter 5.2

It just exececuta the following command: ratutils.populateClumpsWithClassTraining (clumpsImg, classesDict, tmpPath, classesIntColIn, classesNameCol)

Anyway follow my attached script

To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsubscribe...@googlegroups.com.

To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsubscribe@googlegroups.com.
To post to this group, send email to rsgislib-support@googlegroups.com.




--
Felipe Ramos Dantas
Graduado em Tecnologia  em Geoprocessamento
Técnico de Laboratório - Geoprocessamento no IFPI
<PerformObjClass.py>


Nathan Thomas

unread,
Dec 2, 2017, 8:17:57 PM12/2/17
to RSGISLib Support
Turns out this was a duplicate. Bug has been fixed in newer versions of RSGISLib:

Dan Clewley Aug 24: "This looks like a bug, will fix for the next release. I’ve opened an issue about it: https://bitbucket.org/petebunting/rsgislib/issues/45/consistency-of-name-for-gdal-format"

Nathan

Pete Bunting [pfb]

unread,
Dec 3, 2017, 4:26:02 AM12/3/17
to Nathan Thomas, Felipe Dantas, RSGISLib Support

Hi all,

 

This bug has been fixed. I can’t remember exactly when but we have just created a new pull request for the next release so hopefully this week we’ll have that up on conda-forge.

 

Best wishes,

 

Pete

 

****************************************************
* Dr Pete Bunting
* Reader in Remote Sensing
* Earth Observation and Ecosystem Dynamics Group
* Department of Geography and Earth Sciences
* Aberystwyth University
* Aberystwyth
* Ceredigion
* SY23 3DB
* UK

* Ph: +44 (0) 1970 622615
* Mob: +44 (0) 7917 842743
* Email: p...@aber.ac.uk
* ORCID: http://orcid.org/0000-0002-7435-0148
****************************************************

"Please consider the environment before printing this email or any documents attached”

To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.

To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.

 



 

--

Felipe Ramos Dantas

Graduado em Tecnologia  em Geoprocessamento

Técnico de Laboratório - Geoprocessamento no IFPI

<PerformObjClass.py>

 

 



--------------------------------------------------------------------
Prifysgol Aberystwyth www.aber.ac.uk
Prifysgol y Flwyddyn ar gyfer Ansawdd Dysgu - The Times & The Sunday Times 2018.

Aberystwyth University www.aber.ac.uk
University of the Year for Teaching Quality - The Times & The Sunday Times 2018.
Reply all
Reply to author
Forward
0 new messages