resampling ndvi imagery from float to int

61 views
Skip to first unread message

Girish Kumar

unread,
Jan 23, 2017, 2:04:20 AM1/23/17
to RSGISLib Support
Dear all,

        There is a requirement to convert an NDVI imagery from 32bit Float to UINT8 bit. Is there any function available in rsgislib to do it? 
One more query-When an rsgislib function completes its execution, what code it returns if it is successful, and what are the standard error codes it return in the event of error.

Thanks and Regards
Girish
Message has been deleted

Pete Bunting [pfb]

unread,
Jan 23, 2017, 3:03:49 PM1/23/17
to Girish Kumar, RSGISLib Support
Hi Girish,

You’d need to apply and gain and offset to the ndvi (ndvi has a range of -1 to 1), the commands below will do that.

import rsgislib
from rsgislib import imagecalc
imagecalc.imageMath(InputNDVI.kea, OutputNDVI.kea, ‘(b1*100)+100', ‘KEA', rsgislib.TYPE_8UINT)

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

Nathan Thomas

unread,
Jan 23, 2017, 3:09:08 PM1/23/17
to RSGISLib Support, giris...@gmail.com, p...@aber.ac.uk
Ah, yes. I didn't account for that

Girish Kumar

unread,
Jan 24, 2017, 2:08:36 AM1/24/17
to RSGISLib Support, giris...@gmail.com, p...@aber.ac.uk
Dear Pete,

            Thanks for the suggestion. I have tried it and I was able to run the script successfully. But the created image when open using tuiview, gives the following error.
In method Band_ComputeStatistics, argument 2 of type bool(screenshot attached). I am able to open the output image in normal picture viewer. The same error came earlier also when I tried to open some other image also. What can be the problem?

Pete Bunting [pfb]

unread,
Jan 24, 2017, 2:28:06 AM1/24/17
to Girish Kumar, RSGISLib Support, Sam Gillingham
Hi Girish,

I am not sure on that one - Sam Gillingham might know (cc’d)? Can I suggest you pre-calculate your image statistics.

Either:
rsgislib.imageutils.popImageStats(image, usenodataval=True, nodataval=0, calcpyramids=True)

or

rsgiscalcimgstats.py -i ./inputimg.kea -n 255

-n is the no data value for the image.

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”

> On 24 Jan 2017, at 07:08, Girish Kumar <giris...@gmail.com> wrote:
>
> Dear Pete,
>
> Thanks for the suggestion. I have tried it and I was able to run the script successfully. But the created image when open using tuiview, gives the following error.
> In method Band_ComputeStatistics, argument 2 of type bool(screenshot attached). I am able to open the output image in normal picture viewer. The same error came earlier also when I tried to open some other image also. What can be the problem?
>
>
>
>

Girish Kumar

unread,
Jan 27, 2017, 2:05:38 AM1/27/17
to RSGISLib Support, giris...@gmail.com, gilling...@gmail.com, p...@aber.ac.uk
Dear Pete,

             Thanks for the suggestion. I have tried it. Now it is fine. After running the command, the tuiview opens the image without error.
Reply all
Reply to author
Forward
0 new messages