Monday, 9 May 2016

grass - Using r.mapcalculator and Python


I've been trying to write a script creating binary maps:


a=raw_input ("enter a threshold") 
b=float(a)
grass.run_command('r.mapcalculator', formula="**'base_map'>=b**", outfile='map'+str(a), overwrite=True)

When I'm trying to execute it there's an error message :


Invalid map

Parse error

Obviously, when the relevant part of the code is changed (e.g. formula="'base_map'>=**0.7**") everything is working fine. However, my goal was to write a script creating a map automatically when the "a" (the threshold) is provided.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...