imageutils.maskImage command "TypeError: a float is required"

13 views
Skip to first unread message

Llion Preston

unread,
Sep 5, 2016, 9:29:50 AM9/5/16
to RSGISLib Support
Hi Pete/Dan,

I'm trying to use a binary mask to mask out pixels (re-sampled from 250 m to 30 m for sake of re-masking) using imageUtils.maskImage but am receiving the following error: 

import rsgislib
from rsgislib import imageutils

print("Converting non-Corn (2015) pixels to NoData")
imagemask = 'corn_2015_iowa.tif'
outputimage = 'NDVI_corrected_masked.kea'
gdalformat = 'KEA'
datatype = rsgislib.TYPE_32FLOAT
outvalue = '-9999'
maskvalue = '0'
rsgislib.imageutils.maskImage('NDVI_30.tif', imagemask, outputimage, gdalformat, datatype, outvalue, maskvalue)

Traceback (most recent call last): 
File "./mask_test.py", line 11, in <module>
rsgislib.imageutils.maskImage('NDVI_30.tif', imagemask, outputimage, gdalformat, datatype, outvalue, maskvalue)
TypeError: a float is required#

I've ran gdalinfo on both the imagemask and the input image and both appear to be float data types so I'm not sure what I'm doing wrong?

Thanks,
Llion
gdalinfo

Pete Bunting [pfb]

unread,
Sep 5, 2016, 9:34:10 AM9/5/16
to Llion Preston, RSGISLib Support
HI Llion, 

outvalue = ‘-9999 and maskvalue = ‘0’ should not have quotes (i.e., be a string) they should be numbers: outvalue = -9999 and maskvalue = 0

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



--------------------------------------------------------------------
Un o’r 4 prifysgol uchaf yn y DU a’r gorau 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

Llion Preston

unread,
Sep 6, 2016, 6:21:44 AM9/6/16
to RSGISLib Support, llion....@gmail.com, p...@aber.ac.uk
Hi Pete,

Thanks again for your help!

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

Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.
<gdalinfo>
Reply all
Reply to author
Forward
0 new messages