[R-sig-Geo] spgpc package?
Roger Bivand
Roger.Bivand at nhh.no
Thu Aug 9 11:23:35 CEST 2007
On Thu, 9 Aug 2007, Felix Andrews wrote:
> e.g.
>
> # x is a gpc.poly object
> as.Polygons.gpc.poly <- function(x, ID) {
> thisPolys <- lapply(get.pts(x), function(p) {
> Polygon(rbind(as.matrix(cbind(p$x,p$y)),c(p$x[1],p$y[1])),
> hole=p$hole)
> })
> Polygons(thisPolys, ID)
> }
>
> This works except if the gpc.poly is empty. `Polygons` fails if passed
> an empty list().
As you guessed in your first mail, the off-CRAN beta spgpc was folded into
maptools.
There are no methods published in the maptools namespace for converting to
and from gpc.poly, although this is a good idea. The code is inside
unionSpatialPolygons() and checkPolygonsHoles(), but logically ought to be
exposed. I'll look at this for the next release. You can see (untidy)
solutions to your empty list problem in these two functions.
Contributions welcome, especially as patches to maptools files from the
r-spatial sourceforge repository.
Roger
>
> Felix
>
>
> On 8/9/07, Felix Andrews <felix at nfrac.org> wrote:
>> Hmm
>>
>> I'm trying to work with gpclib, converting to and from the sp classes.
>> I don't know what is/was in the package spgpc, but it is no longer
>> available:
>>> install.packages("spgpc", repos=rSpatial)
>> Warning: unable to access index for repository
>> http://r-spatial.sourceforge.net/R/bin/windows/contrib/2.5
>>
>> The page http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html says:
>> "the functionality described here has been included in packages rgdal,
>> naptools, and spgrass6, now all on CRAN. This page is maintained for
>> documentary purposes only, and most of the examples shown here are the
>> examples used in the released packages."
>>
>> where i'm guessing "naptools" should be "maptools".
>> But I can not find a method to coerce between "gpc.poly" and
>> "Polygons" classes. Not that it is difficult to manually... just
>> wondering.
>>
>> Felix
>>
>> --
>> Felix Andrews / °ÂʡΩ
>> PhD candidate
>> Integrated Catchment Assessment and Management Centre
>> The Fenner School of Environment and Society
>> The Australian National University (Building 48A), ACT 0200
>> Beijing Bag, Locked Bag 40, Kingston ACT 2604
>> http://www.neurofractal.org/felix/
>> voice:+86_1051404394 (in China)
>> mobile:+86_13522529265 (in China)
>> mobile:+61_410400963 (in Australia)
>> xmpp:foolish.android at gmail.com
>> 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8
>>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
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