[R-sig-Geo] intersection of two polygons
Roger Bivand
Roger.Bivand at nhh.no
Wed Mar 21 11:30:36 CET 2007
On Wed, 21 Mar 2007, Stéphane Dray wrote:
> I just checked the code and see that my function was not optimal (too
> much loops). I think that it can be easily improve and I can try to
> write a intersectSpatialPolygons. There is a unionSpatialPolygons in
> maptools, I think that an intersect function could be also useful. For
> instance, one thing that I would like to do in R (but I never succeed):
> I have a set of points from which I construct a Voronoi mosaic, I have
> also a polygon of my whole study area, I would like to cut the mosaic
> using the polygon. I now that there is an Arcview extension to do it but
> it would be nice to have also this functionality in R. An intersect
> function would be useful in this case.
It would certainly be welcome, thanks!
>
> Here, I have another related question. My function used polylist objects
> (it was written several years ago when there was no sp). I would like to
> know what will be the future of polylist. The main use of this class was
> its relationship to nb object. Now, poly2nb also accepts SpatialPolygons
> so what about polylist ?
There are users and code around using the Map, polylist, and other legacy
S3 classes, so it seems best to leave the code there. You are right that
it may be sensible to add "deprecated" warnings to many of these, because
the S4 sp classes are the ones being developed actively. This is a bit
like Doug Bates' description of progress with lme structures, the new ones
are to be prefered, but it would not be right simply to remove the old
ones.
Roger
>
> Thanks,
>
>
> Roger Bivand wrote:
> > On Tue, 20 Mar 2007, Stéphane Dray wrote:
> >
> >
> >> I have a code that do the job for polylist objects at
> >> http://biomserv.univ-lyon1.fr/~dray/files/softwares/spatialRLQ/spatialrlq.R
> >>
> >> The function uses gpclib and only returns area or binary matrices (1
> >> intersect, 0 not). It could be easily modify to return the intersection
> >> of two polygons (remove the loops over the polylists and return interAB)
> >>
> >>
> >
> > Thanks, this will be useful, especially for users searching the archives!
> > This also relates to the question of how much vector GIS functionality
> > should be within R.
> >
> > Roger
> >
> >
> >> Roger Bivand wrote:
> >>
> >>> On Tue, 20 Mar 2007, Sebastien wrote:
> >>>
> >>>
> >>>
> >>>> Dear helpers,
> >>>>
> >>>> I need to find the intersection of two polygons. I have two overlapping
> >>>> polygons and I want to find the polygon corresponding to the common
> >>>> part. Is there a fonction, like unionSpatialPolygons which can do that.
> >>>> I have converted my polygons to "owin" and use the function
> >>>> 'intersect.owin' in the pachage spatstat but it returns a binary matrice
> >>>> of class "owin" or I would prefer a polygon.
> >>>>
> >>>>
> >>> No, there is not. I think that joinPolys() in the PBSmapping package can
> >>> do this, and you can get to the PBS PolySet representation using
> >>> SpatialPolygons2PolySet() in the maptools package, but then you'd need to
> >>> get back again to SpatialPolygons, which would involve coding. The
> >>> alternative of using gpclib like unionSpatialPolygons() would also
> >>> involve coding.
> >>>
> >>> Roger
> >>>
> >>>
> >>>
> >>>> Thanks for your help,
> >>>>
> >>>> Sébastien Ollier
> >>>>
> >>>> #### #### ####
> >>>> Sébastien Ollier
> >>>> Maître de Conférences
> >>>> Université Paris-Sud 11
> >>>> Faculté des Sciences d'Orsay
> >>>> Unité Ecologie, Systématique et Evolution
> >>>> Département Biodiversité, Systématique et Evolution
> >>>> UMR - 8079 UPS-CNRS-ENGREF
> >>>> Bât. 360, 91405 ORSAY CEDEX
> >>>> FRANCE
> >>>> Tel : 33 (0) 1 69 15 56 70
> >>>> Fax : 33 (0) 1 69 15 46 97
> >>>> http://www.ese.u-psud.fr/
> >>>> #### #### ####
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>
> >>
> >
> >
>
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list