[R-sig-Geo] convert from spatstat to sp; RFC about generic behaviour

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sat Oct 30 12:24:55 CEST 2010


I like that solution; it seems intuitive, and as this seems to be a FAQ,
I would like to copy this behaviour to sp classes, such that

obj[geom,] # in case there are attribute data in obj, or

obj[geom] # in case obj has only geometry

return the items in obj that are within the geometry of geom. This would
liberate us from selecting the non-NA indexes returned from overlay (or
in case of a grid, assign NA to everything outside).

A problem occurs when obj is pixels or a grid (or raster or im), and
geom lines or polygons, I can see two difficult cases:

- the grid cell centre does not, but part of the grid cell does overlap
with geom or cross geom,
- the grid cell touches geom, but does not overlap / cross.

Robert, how does raster deal with these two cases? Does it have fixed
behaviour, or can the user choose?

Rolf, how does spatstat deal with these two cases?

On 10/30/2010 12:23 AM, Turner Rolf wrote:
> 
> ________________________________________
> From: r-sig-geo-bounces at stat.math.ethz.ch [r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Peter Larson [pslarson2 at gmail.com]
> Sent: Saturday, 30 October 2010 8:28 a.m.
> To: r-sig-geo at stat.math.ethz.ch
> Subject: [R-sig-Geo] convert from spatstat to sp
> 
> Hello all,
> 
> Is there any way to convert from spatstat to sp?
> 
> Specifically, I am looking to clip a density plot produced in spatstat
> to include only points within a polygon boundary in a shapefile. if
> there is a way to clip in spatstat, this would also be acceptable.
> 
> Clipping in spatstat is done simply using [] --- let X be your density plot (image; object of class "im")
> and let W be an object of class owin determined by the polygonal boundary that you have in mind.
> 
> Just do
> 
>     Y <- X[W]
> 
> to get X clipped to the window W.  To find out how to make ``a polygon boundary in a shapefile'' into
> a window, see the vignette on handling shapefiles in spatstat:
> 
>     vignette("shapefiles")
> 
>         cheers,
> 
>               Rolf Turner
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list