Hi all, I'm trying to combine two raster using the r.mapcalc/r.mapcalculator
but am getting no where. I'm using python.
# I did this previously... so "dem" and "rain" exist as rasters
grass.run_command("r.in.gdal",input="<location>/dem.tif",output="dem")
grass.run_command("r.in.gdal",input="<location>/rain.tif",output="rain")
# Then I try this...
grass.run_command("r.mapcalculator",amap="dem",bmap="rain",formula="A *
B",outfile="test_combo")
The output from that gives me...
r.mapcalc "test_combo" = "( "dem" * "rain" )"
100%
Done.
When I try to add "test_combo" to the display in GRASS, nothing shows, even
when I try to zoom to the layer in GRASS.
r.info gives me the following:
+----------------------------------------------------------------------------+
| Layer: test_combo2 Date: Fri Feb 18 13:19:52 2011
|
| Mapset: PERMANENT Login of Creator: jay
|
| Location: newLocation
|
| DataBase: ......... |
| Title: ( test_combo )
|
| Timestamp: none
|
|----------------------------------------------------------------------------|
|
|
| Type of Map: raster Number of Categories: 255
|
| Data Type: FCELL
|
| Rows: 20
|
| Columns: 20
|
| Total Cells: 400
|
| Projection: Lambert Conformal Conic
|
| N: 707999.97864227 S: 628766.19610209 Res: 3961.68912701
|
| E: 827306.35554785 W: 607862.24148022 Res: 10972.20570338
|
| Range of data: min = 0.000000 max = 4241302.000000
|
|
|
| Data Description:
|
| generated by r.mapcalc
|
|
|
| Comments:
|
| dem * rain
|
|
|
Wow, it looks like your output raster is really, really small - only 400
cells. Is that correct? It also has values (you can tell by the min/max
values in the metadata). That means that GRASS is producing something. Have
you tried setting the regional settings to match test_combo? If you're
importing into a new location without having set the regional settings
before, it could be that your regional settings don't allow GRASS to display
the map.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalculator-r-mapcalc-not-producing-raster-tp6041018p6041044.html
Sent from the Grass - Users mailing list archive at Nabble.com.
Thanks, that did the trick. Setting g.region. Question, does that function
set the region globally for Grass? For instance, if I'm using grass in
another python console will that region be affected if I set the region in
another instance of a python session?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalculator-r-mapcalc-not-producing-raster-tp6041018p6041309.html
Sent from the Grass - Users mailing list archive at Nabble.com.
The regional settings are, as far as I know, stored in the mapset. So if you
change the regional settings in a mapset and then leave it and work in
another mapset, you'll be working with the regional settings of the current
mapset. If you come back to the old mapset, the regional settings will still
be the same until you change them again. Just depends on what mapset you're
working in.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-mapcalculator-r-mapcalc-not-producing-raster-tp6041018p6041342.html
Sent from the Grass - Users mailing list archive at Nabble.com.