Re: [R-sig-Geo] Clearing the area outside of a polygon defined on a grid.

2012-11-15 Thread Roger Bivand
On Thu, 15 Nov 2012, peleve wrote: Thanks Robert, I was able to do it with the following using the 'gpclib" package: For completeness, please use rgeos rather than gpclib, which we are advising against strongly, because of the unclear and very restrictive licence of its included C code. rgeo

Re: [R-sig-Geo] Clearing the area outside of a polygon defined on a grid.

2012-11-15 Thread peleve
Thanks Robert, I was able to do it with the following using the 'gpclib" package: p2 <- as(xy, "gpc.poly") p1 <- as(maparea, "gpc.poly") plot(setdiff(p1, p2), poly.args = list(col = 3), add = TRUE) Did exactly what I was looking for. Pretty simple, actually. Thanks for inspiring me. Pete -

Re: [R-sig-Geo] Clearing the area outside of a polygon defined on a grid.

2012-11-15 Thread Robert J. Hijmans
If you have a polygon for the entire area and one for the area of interest within it; then I think you could use rgeos::gDifference to create the polygon you need. Robert On Thu, Nov 15, 2012 at 6:19 AM, peleve wrote: > Thank you very much. That worked, mostly!?! But I see the methodology > n

Re: [R-sig-Geo] Clearing the area outside of a polygon defined on a grid.

2012-11-15 Thread peleve
Thank you very much. That worked, mostly!?! But I see the methodology now. I had been thinking about masks, but I was asking the wrong question I now realize. In my real application, using your approach, I still have some unwanted bits left outside of the polygon. I traced it as a left over piec

Re: [R-sig-Geo] Clearing the area outside of a polygon defined on a grid.

2012-11-14 Thread Robert J. Hijmans
I think you can do: x <- raster(akima) y <- mask( x, SpP[2] ) plot(y) On Wed, Nov 14, 2012 at 10:45 AM, peleve wrote: > I have a result from Akima or Loesss interpolation using irregular data > defined inside a polygon. I only want the results inside the polygon. > Akima interpolates correc

[R-sig-Geo] Clearing the area outside of a polygon defined on a grid.

2012-11-14 Thread peleve
I have a result from Akima or Loesss interpolation using irregular data defined inside a polygon. I only want the results inside the polygon. Akima interpolates correctly inside the polygon but leaves a blue residue outside the polygon (a result of Akima using a convex hull) that I want to get rid