I'm trying to recode a large GSSURGO soil raster with CSV using the Grass r.recode.attr following these instructions https://pvanb.wordpress.com/2014/12/13/recode-your-raster-file-in-grass-gis-using-a-csv-file/ but I'm getting error "name 'xrange' is not defined"

When I looked it up I found that this issue may be because "xrange" changed to "range" in the transition from from Python 2 to Python 3. The instructions for the r.recode.attr module are from 2014 and I can't find much else out there the talks about r.recode.attr. However, it seems like a very valuable tool.

My raster, instead of being classed by values has a unique key which only has meaning if you can reclassify it from a related CSV table. Does anyone know of any alternative using GRASS or QGIS?

  • Yes, the 2to3 update tool of Python suggest to replace "xrange()" with "range()" (in line 88) - can you try that? – markusN Feb 12 at 21:31
  • ok meanwhile I have submitted a fix as github.com/OSGeo/grass-addons/pull/91 (yet to be accepted) – markusN Feb 12 at 21:43

Please update your installation of the GRASS GIS addon r.recode.attr to the latest version. I have updated it to be Python 3 compliant (https://github.com/OSGeo/grass-addons/pull/91 - xrange compatibility fix).

The addon now works.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.