[GRASS-user] Change value of cells in raster map

   I have two raster maps both of which have the value of all cells as 2,
with the label 'Category 2.' I want to change the value of all cells in each
map, one map to 0.0 the other map to 12.5. r.category allows me to change
categories but not values and r.mapcalc allows me to create new maps with
cells having a value based on the expression.

   What I fail to see is the appropriate module to modify an existing map by
changing the value in each cell. Please point me in the right direction.

Rich

Hi.

What I fail to see is the appropriate module to modify an existing map by
changing the value in each cell. Please point me in the right direction.

Maybe if-then statements with mapcalc are applicable to the situation.

outputRaster=if(EXPRESSION,true,false)

Mark

On Thu, 8 Jun 2017, Mark Seibel wrote:

Maybe if-then statements with mapcalc are applicable to the situation.
outputRaster=if(EXPRESSION,true,false)

Mark,

   I'll try writing an expression that tests for a map name. I can use any
output map name because if it contains the appropriate cell values a simple
g.rename will work.

   Perhaps this will work:

   r.mapcalc 'output1 = if (mapname@mapset,value=0.0)'

I'll try it tomorrow morning and post the results.

Thanks,

Rich

Hi Rich,

When I want to modify a raster, I usually draw a vector and use
v.to.rast, then r.mapcalc if necessary.

Regards,
Laurent

2017-06-08 18:57 GMT-05:00 Rich Shepard <rshepard@appl-ecosys.com>:

On Thu, 8 Jun 2017, Mark Seibel wrote:

Maybe if-then statements with mapcalc are applicable to the situation.
outputRaster=if(EXPRESSION,true,false)

Mark,

  I'll try writing an expression that tests for a map name. I can use any
output map name because if it contains the appropriate cell values a simple
g.rename will work.

  Perhaps this will work:

  r.mapcalc 'output1 = if (mapname@mapset,value=0.0)'

I'll try it tomorrow morning and post the results.

Thanks,

Rich
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

On Thu, 8 Jun 2017, Laurent C. wrote:

When I want to modify a raster, I usually draw a vector and use v.to.rast,
then r.mapcalc if necessary.

Laurent,

   That's what I've done. Since I did not enter category values for the
vector maps I need to use r.mapcalc on the raster maps.

Rich

On Thu, 8 Jun 2017, Rich Shepard wrote:

r.mapcalc 'output1 = if (mapname@mapset,value = 0.0)'

   Tried it this evening: r.mapcalc does not like this syntax.

   I can create a map with values specified, but they are the size of the
mask. How can I specify a specific map name to r.mapcalc?

Rich

Rich Shepard wrote

On Thu, 8 Jun 2017, Rich Shepard wrote:

r.mapcalc 'output1 = if (mapname@mapset,value = 0.0)'

   Tried it this evening: r.mapcalc does not like this syntax.

   I can create a map with values specified, but they are the size of the
mask. How can I specify a specific map name to r.mapcalc?

Rich
_______________________________________________
grass-user mailing list

grass-user@.osgeo

https://lists.osgeo.org/mailman/listinfo/grass-user

See

https://grass.osgeo.org/grass73/manuals/r.mapcalc.html

raster A:
raster B: raster eg with values 1 and 2

in R.mapcalc :

if(B==1, A, A/B)

which means in the resulting map: if the cell value in B is equal to 1, then
take the raster cell value of raster A, otherwise divide the raster cell
value of A by the raster cell value of B.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Change-value-of-cells-in-raster-map-tp5323575p5323594.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On Thu, 8 Jun 2017, Helmut Kudrnovsky wrote:

raster A:
raster B: raster eg with values 1 and 2

in R.mapcalc :

if(B==1, A, A/B)

which means in the resulting map: if the cell value in B is equal to 1, then
take the raster cell value of raster A, otherwise divide the raster cell
value of A by the raster cell value of B.

Helmut,

   I understand this produces a new map from two maps with different values.
My two raster maps have the same value (2) because they come from dividing a
single vector map whose area has a single value.

   I'm trying various v.db.* modules to change values in the two vector maps,
then I can recreate the vector maps from these and each will have the
desired value. So far no success, but I'll keep trying.

Thanks,

Rich

Hi.

  I'm trying various v.db.* modules to change values in the two vector maps,

then I can recreate the vector maps from these and each will have the
desired value. So far no success, but I'll keep trying.

Start editing the vector, then click "update/display attributes" button,
then click the appropriate centroid and change the value in the vector
table.

Mark

Rich Shepard wrote

On Thu, 8 Jun 2017, Helmut Kudrnovsky wrote:

raster A:
raster B: raster eg with values 1 and 2

in R.mapcalc :

if(B==1, A, A/B)

which means in the resulting map: if the cell value in B is equal to 1,
then
take the raster cell value of raster A, otherwise divide the raster cell
value of A by the raster cell value of B.

Helmut,

   I understand this produces a new map from two maps with different
values.
My two raster maps have the same value (2) because they come from dividing
a
single vector map whose area has a single value.

   I'm trying various v.db.* modules to change values in the two vector
maps,
then I can recreate the vector maps from these and each will have the
desired value. So far no success, but I'll keep trying.

Thanks,

Rich

_______________________________________________
grass-user mailing list

grass-user@.osgeo

https://lists.osgeo.org/mailman/listinfo/grass-user

https://grass.osgeo.org/grass73/manuals/v.db.update.html

?

-Add e.g. a integer column to the vector
- Insert 1 and 2 for the polygons in this column by v.db.update
- V.to.rast by attributes
- R.mapcalc

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Change-value-of-cells-in-raster-map-tp5323575p5323656.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On Fri, 9 Jun 2017, Mark Seibel wrote:

Start editing the vector, then click "update/display attributes" button,
then click the appropriate centroid and change the value in the vector
table.

Mark,

   Thank you. It did not occur to me to change the centroid value. I was
looking to add a column to the sqlite table and then apply a value to it.
Didn't work well.

Regards,

Rich

On Fri, 9 Jun 2017, Mark Seibel wrote:

Start editing the vector, then click "update/display attributes" button,
then click the appropriate centroid and change the value in the vector
table.

Mark,

   For one of the two maps created from the overall area this worked fine.
For the other map there is no table where I can change the centroid's value.
The othe map displays an 'Update attributes' dialog box with the layer and
category tab, but the area beneath that is blank. Perhaps I need to replace
the centroid in that map?

Rich

On Fri, 9 Jun 2017, Rich Shepard wrote:

For one of the two maps created from the overall area this worked fine.
For the other map there is no table where I can change the centroid's
value. The othe map displays an 'Update attributes' dialog box with the
layer and category tab, but the area beneath that is blank. Perhaps I need
to replace the centroid in that map?

   Found a work-around. In the layer management window I selected the problem
map and chose 'Show attribute data'. In the manage tables tab I added a
second column of type float, then entered the value in the browse data tab.
Now both tables have an attribute column with appropriate values.

   On to v.to.rast ...

Rich