[R-sig-Geo] Clipping raster by polygon
Carsten Neumann
carstennh at aol.com
Fri Jul 19 11:56:20 CEST 2013
Hi Joseph,
I wrote a function that you can use to clip every raster object with any
polygon within the raster package.
######################################
clip<-function(raster,shape) {
a1_crop<-crop(raster,shape)
step1<-rasterize(shape,a1_crop)
a1_crop*step1}
######################################
Much success.
Carsten
On 07/17/2013 07:02 PM, Robert J. Hijmans wrote:
> Joseph, Perhaps you can use raster function crop, perhaps followed by
> mask. Robert
>
>
> On Wed, Jul 17, 2013 at 8:31 AM, Joseph Miller <jemiller31 at gmail.com> wrote:
>
>> Hello-
>>
>> I am trying to clip a raster with a Spatial Polygons Data Frame (esri
>> shapefile). I reviewed the rgeos package documentation but could not find
>> an adequate tool to do this. Suggestions?
>>
>> Thanks,
>> Joseph
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Carsten Neumann
Telegrafenberg, A 17 01.13
14473 Potsdam
-------------------------------------------------------
Helmholtz Centre Potsdam
GFZ German Research Centre for Geosciences
Department 1 - Section 1.4 - Remote Sensing
-------------------------------------------------------
Tel.: +49 (0) 331 288 1766
e-mail: carstenn at gfz-potsdam.de
More information about the R-sig-Geo
mailing list