TypeError: '>' not supported between instances of 'int' and 'NoneType' in task Identify urban nature areas

What is the issue or question you have?

I tried to run the model several times but the same error occurs and I don’t understand where does it come from

What do you expect to happen?

The model to run without error

What have you tried so far?

I tried to change my input data many times and looked at the inVEST forum for similar problems without success

Upload the logfile using the :outbox_tray: button

InVEST-natcap.invest.urban_nature_access-log-2024-03-12–15_09_58.txt (41.4 KB)

Hello @Francoise1, and welcome!

Thanks for including the log file. The error message includes this:

ERROR Something went wrong when adding task Identify urban nature areas (9), terminating taskgraph.

Traceback (most recent call last):
File “taskgraph\Task.py”, line 674, in add_task
File “taskgraph\Task.py”, line 1093, in _call
File “natcap\invest\urban_nature_access.py”, line 1862, in _reclassify_urban_nature_area
File “natcap\invest\utils.py”, line 731, in reclassify_raster
File “pygeoprocessing\geoprocessing.py”, line 2373, in reclassify_raster
TypeError: ‘>’ not supported between instances of ‘int’ and ‘NoneType’

This is not a very user-friendly message, but the first thing I would look at is the LULC attribute table, since that’s where we define urban_nature values. The LULC raster is then reclassified with the urban_nature values from the table. Do all of the rows have values in this column? If not, add values between 0 and 1 and see if that helps.

~ Stacie

1 Like

I agree with Stacie’s advice. @Francoise1 , even if you do resolve the problem on your own, would you mind sharing the offending LULC Attribute Table? Seeing it can help us improve the error message in the future.

Thanks,

Thank you for your responses. For sure here is my LULC attribute table. I also tried by replacing 0.5 by 1 but it does not help. In addition my raster file (lulc) contains only values 1, 2, 3, 4 and 5 and I ran the model under the uniform radius mode.
Landuse_table.csv (56 Bytes)

Thanks for sharing your table @Francoise1 . I’m not able to reproduce any error using this table. If you like, you can share your entire set of input data that you used to run the model, as it appears in the logfile you shared earlier. Thanks again,

Thank you Dave. Can I share it to your e-mail address? The files are sensitives and too big to share it here.

Thanks again for sharing your data @Francoise1 . The TypeError is being raised because of a bug in our model. In the meantime, if you assign a NoData value to the LULC raster (even if the raster does not contain any nodata pixels) this error will be avoided.

Hi Dave,

Thank you for your response. What do you mean by “if you assign a NoData value to the LULC raster (even if the raster does not contain any nodata pixels)” ?
I replaced all pixels outside the study region as NA in my landuse but unfortunately I still get a “ZeroDivisionError: division by zero” error.

The NoData value is part of a raster’s metadata. It tells any software reading the file to treat pixels with that value as “the absence of data”. Your LULC raster was missing this bit of metadata, and invest was not handling that properly.

This is a very reasonable thing to do, but then you should also set the NoData value of the raster to that same value so that invest and other software knows to ignore those pixels. Also, I don’t recommend using NA (or NAN?) as the NoData value. I suggest simply choosing a value that you know will not otherwise occur in your raster. In this case, perhaps a negative number.

Here is some more information: NoData in raster datasets—ArcMap | Documentation

Thank you ! Indeed checking the metadata is really helpful :slight_smile: Thank you again for having solved my problem !

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.