Skip to first unread message

Sam Alaee

unread,
Mar 2, 2017, 10:49:09 AM3/2/17
to RSGISLib Support
Hi all,

I've been trying to find a way to do object-based classification by RSGISLib but I wasn't successful. Here is what I want to do:
We all know that in object-based, as opposed to pixel-based, we can/should use spectral, spatial, and contextual attributes of our objects(segments) and the same attributes on the training shape file we got and use them both while we are doing our classification.

This article is the closest thing I could find on the internet:
In this article, we don't use our training shape file (which we should manually define our classes over some areas of the image) and we are not looking forward to seeing the resemblance between the training classes and our objects(segments) we got from segmentation part.

The other thing which I found is this:
In this pdf file, it was explained how to do rule-based classification which is very useful but that's not what I have in mind right now.

What I have as my inputs and what I want to do:

1) I have 5+ band images which I need to segment it.
2) I need to do Object-based classification. Here I want to use the output of my segmentation as "objects" instead of "pixels" and my input image. I also have a training shape file (*.shp file which I created by a GIS software with some classes defined inside).
3) I want to use RandomForest as my algorithm to calculate the resemblance and generate the classified map.

I would really appreciate it if someone could give a hint on this or whether I'm on the right track or not.

I'm looking forward to hearing from you.

Best,
Ghassem

Pete Bunting [pfb]

unread,
Mar 2, 2017, 11:33:37 AM3/2/17
to Sam Alaee, RSGISLib Support
Hi Sam, 

The introductory worksheet (http://www.rsgislib.org/documentation.html#rsgislib-introduction-training) has an example of doing that in the classification chapter. 

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”

--
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.



--------------------------------------------------------------------
Un o’r 4 prifysgol uchaf yn y DU a’r orau yng Nghymru am fodlonrwydd myfyrwyr.
(Arolwg Cenedlaethol y Myfyrwyr 2016)
www.aber.ac.uk

Top 4 UK university and best in Wales for student satisfaction
(National Student Survey 2016)
www.aber.ac.uk

Sam Alaee

unread,
Mar 3, 2017, 3:05:06 PM3/3/17
to RSGISLib Support, ghasse...@gmail.com, p...@aber.ac.uk
Hi Pete,

I followed the instructions mentioned on that file. Unofortunately, I ended with an error from this function:
imageutils.combineImages2Band(inputImages, outputImage, format, datatype, 0.0)
this function was called in this function:
ratutils.populateClumpsWithClassTraining(clumpsImg, classesDict, tmpPath, classesIntColIn, classesNameCol)
and this function was called in the sample code from the introductory guide you provided.

The error I get is this:
Traceback (most recent call last):
  File "C:/exercises/performObjClass.py", line 51, in <module>
    ratutils.populateClumpsWithClassTraining(clumpsImg, classesDict, tmpPath, classesIntColIn, classesNameCol)
  File "C:\Users\Sam\AppData\Local\Continuum\Anaconda3\lib\site-packages\rsgislib\rastergis\ratutils.py", line 1177, in populateClumpsWithClassTraining
    imageutils.combineImages2Band(tmpClassImgLayers, combinedClassesImage, 'KEA', rsgislib.TYPE_8UINT, 0.0)
RuntimeError: More keyword list entries (8) than format specifiers (5)

For making sure that the function combineImages2Band  is not behaving as it should, I tested this piece of code:

from rsgislib import imageutils
import rsgislib

inputImages = ['RSGISLib_output/Avalon_ndvi.kea', 'RSGISLib_output/Avalon_wbi.kea']
outputImage = 'tmp/classes.kea'

datatype = rsgislib.TYPE_8UINT
format = 'KEA'
imageutils.combineImages2Band(inputImages, outputImage, format, datatype, 0.0)

I ended up with the same error:

C:\Users\Sam\AppData\Local\Continuum\Anaconda3\python.exe C:/exercises/combineImages.py
Traceback (most recent call last):
  File "C:/exercises/combineImages.py", line 9, in <module>
    imageutils.combineImages2Band(inputImages, outputImage, format, datatype, 0.0)
RuntimeError: More keyword list entries (8) than format specifiers (5)

Process finished with exit code 1

I know the windows version is currently under test and it's Beta but I wanted to check if anyone else had the same experience.

Do you know how to fix this?

I use windows 7 and Anaconda 3.


To post to this group, send email to rsgisli...@googlegroups.com.

Pete Bunting [pfb]

unread,
Mar 4, 2017, 4:28:20 AM3/4/17
to Sam Alaee, RSGISLib Support
Hi Sam, 

The issue there is that the windows build is a out of date, compared to those notes. We’re going to be making new stable releases in the coming weeks so we’ll update the windows build then. 

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 post to this group, send email to rsgislib...@googlegroups.com.

Sam Alaee

unread,
Mar 6, 2017, 8:23:59 AM3/6/17
to RSGISLib Support, ghasse...@gmail.com, p...@aber.ac.uk
Hi Pete,

That'd be awesome. Do you think the windows build will be released any time in the March? I'm desperately waiting for the update.
I also wanted to mention that there are also some incompatibilities between the GDAL functionalities which are designed in the RSGISLib and the programs in the gdal package it self.
Thanks 

Best,
Ghassem

Pete Bunting [pfb]

unread,
Mar 6, 2017, 8:25:59 AM3/6/17
to Sam Alaee, RSGISLib Support
Hi Sam, 

Can you provide a list of issues you are aware of with the Windows builds and we will try to address them before the next release. 

Yes, intension is for the next release to be before the end of March. 

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”

Sam Alaee

unread,
Mar 6, 2017, 11:35:21 AM3/6/17
to RSGISLib Support, ghasse...@gmail.com, p...@aber.ac.uk
Hi Pete,

I haven't tried all the functionalities yet but these 2 errors I have got so far:

1)
rsgislib.vectorutils.polygoniseRaster(inputImg, outShp, imgBandNo=1, maskImg=None, imgMaskBandNo=1)

error I got:

Traceback (most recent call last):
  File "C:/exercises/vector_tools.py", line 13, in <module>
    vectorutils.polygoniseRaster(outputImage, outputVector, imgBandNo=1, maskImg=None, imgMaskBandNo=1)
  File "C:\Users\Sam\AppData\Local\Continuum\Anaconda3\lib\site-packages\rsgislib\vectorutils\__init__.py", line 176, in polygoniseRaster
Polygonising...
    gdal.Polygonize(imgBand, imgMaskBand, outLayer, dstFieldIdx, [], callback=gdal.TermProgress )
  File "C:\Users\Sam\AppData\Local\Continuum\Anaconda3\lib\site-packages\osgeo\gdal.py", line 2679, in Polygonize
    return _gdal.Polygonize(*args, **kwargs)
RuntimeError: Object given is not a Python function

2)
imageutils.combineImages2Band(inputImages, outputImage, format, datatype, 0.0)

error I got:
C:\Users\Sam\AppData\Local\Continuum\Anaconda3\python.exe C:/exercises/combineImages.py
Traceback (most recent call last):
  File "C:/exercises/combineImages.py", line 9, in <module>
    imageutils.combineImages2Band(inputImages, outputImage, format, datatype, 0.0)
RuntimeError: More keyword list entries (8) than format specifiers (5)

Process finished with exit code 1

I will get back to you if I ever got any more errors.


Best,
Sam

Sam Alaee

unread,
Apr 11, 2017, 11:04:16 AM4/11/17
to RSGISLib Support, ghasse...@gmail.com, p...@aber.ac.uk
Hi Pete,

Just wanted to check if the windows build is updated. I am using Anaconda by the way. Thank you.

Best,
Ghassem

Pete Bunting [pfb]

unread,
Apr 11, 2017, 5:36:07 PM4/11/17
to Sam Alaee, RSGISLib Support
Hi Sam, 

Sorry, no we haven’t had chance yet. I’m current on an field course with our undergraduate and then on leave next week so I’m afraid it’ll be a couple of weeks until we get this release out. I am sorry for the delay but we do this between all our other duties. 

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 post to this group, send email to rsgislib...@googlegroups.com.

Sam Alaee

unread,
Apr 12, 2017, 2:21:17 PM4/12/17
to RSGISLib Support, ghasse...@gmail.com, p...@aber.ac.uk
Hi Pete,

Thanks. Looking forward to it. It would be perfect if you could post a new "Topic" in the group whenever the update was ready.

Best,
Sam
Reply all
Reply to author
Forward
0 new messages