Greetings
I want to develop a script that crops a raster in order to only have the pixels that are located inside a vector polygon. Which functionality shall I use?
Thanks
pedro
Greetings
I want to develop a script that crops a raster in order to only have the pixels that are located inside a vector polygon. Which functionality shall I use?
Thanks
pedro
Pedro Roma:
I want to develop a script that crops a raster in order to only have the
pixels that are located inside a vector polygon.
There is probably a more elegant solution, but this will do:
g.region vect=your_vector
v.to.rast input=your_vector output=your_vector_rasterized use=val
r.mask input=your_vector_rasterized
r.mapcalc "clipped_raster=original_raster"
r.mask -r
Hope this helps,
Marcello.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/A-Script-that-only-selects-raster-inside-a-polygon-tp5567368p5567467.html
Sent from the Grass - Users mailing list archive at Nabble.com.
Pedro Roma:
>I want to develop a script that crops a raster in order to only have the
>pixels that are located inside a vector polygon.
Marcello Gorini:
There is probably a more elegant solution, but this will do:
g.region vect=your_vector
v.to.rast input=your_vector output=your_vector_rasterized use=val
(comment of minor importance I guess... the above needs "value=" to be fed
with a value of course).
r.mask input=your_vector_rasterized
r.mapcalc "clipped_raster=original_raster"
r.mask -r
Marcello,
honestly, it's very nice to see how you stepped up from 0 to 100 within almost
zero time
(...watch out for curves and steep slopes :-p)
All the best, Nikos
Cheers, Nikos
Pedro Roma:
> >I want to develop a script that crops a raster in order to only have the
> >pixels that are located inside a vector polygon.
Marcello Gorini:
> There is probably a more elegant solution, but this will do:
>
> g.region vect=your_vector
> v.to.rast input=your_vector output=your_vector_rasterized use=val
Nikos:
(comment of minor importance I guess... the above needs "value=" to be fed
with a value of course).
...forgot (that the) default (is) "value=1" which will work just fine.
Nikos
> r.mask input=your_vector_rasterized
> r.mapcalc "clipped_raster=original_raster"
> r.mask -r
Pedro Roma:
I want to develop a script that crops a raster in order to only have the
pixels that are located inside a vector polygon.
Marcello Gorini:
There is probably a more elegant solution, but this will do:
g.region vect=your_vector
v.to.rast input=your_vector output=your_vector_rasterized use=val
Nikos:
(comment of minor importance I guess... the above needs "value=" to be fed
with a value of course).
r.mask input=your_vector_rasterized
r.mapcalc "clipped_raster=original_raster"
r.mask -r
Marcello,
honestly, it's very nice to see how you stepped up from 0 to 100 within
almost
zero time
(...watch out for curves and steep slopes :-p)
Thanks a lot for your comments Nikos! I am just trying to make up for lost
time due to my "Windows point-and-click" past life
Cheers,
Marcello.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/A-Script-that-only-selects-raster-inside-a-polygon-tp5567368p5568572.html
Sent from the Grass - Users mailing list archive at Nabble.com.
Hi
I Would like to thank to Nikos and Marcello for the reply to my question.
Instead of using r.mask (I’m not a big fan of r.mask) can I cross my v.to.rast raster(composed by 1 and nulls) and my raster file?
Or this is not a good idea
Thanks
Pedro
Pedro Roma wrote:
Instead of using r.mask (I'm not a big fan of r.mask) can I cross my
v.to.rast raster(composed by 1 and nulls) and my raster file?
r.mapcalc "outrast = if(isnull(maskrast),null(),inrast)"
--
Glynn Clements <glynn@gclements.plus.com>