[GRASS-dev] Re: [GRASS GIS] #789: g.region option to expand the
computational region of about "some" pixels?
GRASS GIS
trac at osgeo.org
Thu Oct 15 06:40:45 EDT 2009
#789: g.region option to expand the computational region of about "some" pixels?
--------------------------+-------------------------------------------------
Reporter: nikos | Owner: grass-dev at lists.osgeo.org
Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: default | Version: unspecified
Resolution: | Keywords: g.region, expand computational region
Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Comment (by nikos):
> > can you provide an example using Spearfish's bugsites + elevation.dem
or something from the NC standard dataset?
>
> Right. I'll try to re-produce this in Spearfish.
{{{
# launch grass65 in spearfish60
nik at vertical:~$ grass65 /geo/grassdb/spearfish60/user1/
}}}
copy-paste-execute everything below!
{{{
# define a region
g.region n=4921000 s=4915000 w=591000 e=598500 res=500 -pa
# create a vector grid
v.mkgrid map="tempGrid" grid=12,15 position="region" angle=0 breaks=3 --o
# extract centroids from vector grid
v.extract input="tempGrid" output="tempGrid_centroids" type="centroid"
layer=1 new=-1 --o
# draw maps
d.mon x0 && d.vect tempGrid && d.vect tempGrid_centroids col=blue
# convert centroids to points and draw
v.type in=tempGrid_centroids out=tempGrid_points type=centroid,point
d.vect tempGrid_points col=red
# add column to be updated from raster
v.db.addcol tempGrid_points column="landcover integer"
# match region with "-a" indeed, it "grows" outwards (or it just stays
like it was before!?).
g.region vect=tempGrid_points -pa
# check visually: nothing changed
d.redraw
# now try _without_ "-a"
g.region vect=tempGrid_points -p
# obviously the region has been altered (as expected): check (also) the
numbers!
d.redraw
# now try again with "-a"
g.region vect=tempGrid_points -pa
# there is no "returning back" or "growing"! (only when using res=500
again, keep reading)
d.redraw
# update points from landcover.30m raster and check table
v.what.rast tempGrid_points rast=landcover.30m column=landcover
db.select tempGrid_points
# works fine!
# assume that the raster was just about the same size of what the
(grass-)region is:
r.mapcalc landcover_cropped = landcover.30m
# add a second column and update again
v.db.addcol map=tempGrid_points col="landcover2 integer"
v.what.rast vect=tempGrid_points rast=landcover_cropped col=landcover2
# check updated table
db.select tempGrid_points
# works fine too!
# now draw raster and points
d.erase
d.rast landcover_cropped
d.vect tempGrid_points col=red
# here is where the problem begins:
# first check current region size
g.region -p
# for some reason I was using the "res" parameter with g.region while
looping over several point vector maps to get them updated from rasters
# so, let's use res=500
g.region vect=tempGrid_points -pa res=500
# note the changes in the region:
# the number of rows, cols. The region growed outwards (as expected)!
# north is now larger
# south has become smaller (!?)
# west has become smaller (!?)
# east is now larger
# now repeat v.what.rast
v.what.rast vect=tempGrid_points rast=landcover_cropped col=landcover2
# check updated column
db.select tempGrid_points
d.vect tempGrid_points col=blue where="landcover2 > 0"
# In this example I see points at east, south not being updated (actually
updated with NULL)!
# Missing values only at (some) the edges! huh??
}}}
Nikos
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/789#comment:4>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list