[GRASS-user] creating two new maps from one existing raster

L. Prevett prevettl at gmail.com
Thu Aug 16 14:25:02 PDT 2012


On 8/16/12, Janet Choate <jsc.eco at gmail.com> wrote:
> Hi all,
> i have a raster that i simply want to split in two along a line designated
> by me, thereby creating two separate rasters.  i have attempted to digitize
> using v.digit, displaying the raster and drawing a line around the area of
> interest.  i go through the motions of what i think is closing the line,
> then save and exit.  but v.info shows no data attached to this new vector,
> and when i try to display, nothing shows up.
>
> can anyone tell me how to make 2 rasters out of my 1 along a user specified
> line, or how to successfully digitize this?
> thank you,
> Janet
>

Hi Janet,

I don't know of a command that just splits a raster (maybe there is one??)

But one way to do it is to use r.digit and create a file named MASK for each
of the separate rasters. Then use r.mapcalc to create new rasters.

Example:

 # remove any old MASK file
 g.remove MASK

 # set the region to the raster you want to split up
 g.region rast=old

 # display the raster you want to work on (i.e. d.mon start=x0 select=x0)
 d.rast old

 # run r.digit on the current raster (old)
 r.digit output=MASK
  ## use mouse keys to define new raster named MASK
  ## save with X

 # use r.mapcalc (not g.copy) to create a raster called 'new1'
 # that automatically applies the MASK you selected
 r.mapcalc new1=old

 # clean up and view results
 d.erase
 g.remove MASK

 # view the original raster (old)
 d.rast old

 # view the new raster
 d.rast new1

 repeat steps for the other half of the raster (new2, etc...)

note:
Use v.extract and then v.to.rast if you want to create a MASK for features
base on queries (instead of a mouse based MASK).

hth

L. Prevett


More information about the grass-user mailing list