[R-sig-Geo] conversion to polygons
Roger Bivand
Roger.Bivand at nhh.no
Mon Jun 19 12:19:48 CEST 2006
On Mon, 19 Jun 2006, Luis Ridao Cruz wrote:
>
> This gives still an error message:
>
> test2 <- SpatialPolygons(list(Polygons(list(test)),ID=1)))
>
> Error: syntax error in
> "SpatialPolygons(list(Polygons(list(Polygons(coraltest))),ID=1)))"
>
But what did you actually enter as the command before the error message,
and what is str(coraltest)?
library(sp)
coraltest <- matrix(c(0,0,0,1,1,1,1,0,0,0), ncol=2, byrow=TRUE)
plot(coraltest, type="l")
SP_coraltest <- SpatialPolygons(list(Polygons(list(Polygon(coraltest)),ID=1)))
plot(SP_coraltest, axes=TRUE)
does work (one right bracket too many, and the inner constructor is
Polygon()
Roger
>
> Luis
>
>
>
> >>> Roger Bivand <Roger.Bivand at nhh.no> 16/06/2006 09:41:54 >>>
> On Wed, 14 Jun 2006, Luis Ridao Cruz wrote:
>
> > R-Sig-Geo help,
> >
> > I have an objct of class "SpatialPointsDataFrame"
> > which I woul like to convert to polygon.
> >
> > I have used the following:
> >
> > test1<-Polygon(test)
> > test2<-SpatialPolygons(list(test),1)
>
> test2<-SpatialPolygons(list(Polygons(list(test)),ID=1)))
>
> should do it - there are two layers, because some "Polygons" objects
> with
> a single ID can have multiple "Polygon" object members.
>
> Roger
>
> > plot(test2,col=2,pbg="white")
> >
> > but I get en error message like this:
> >
> > Error in as.list(X) : cannot get a slot ("Polygons") from an object
> of
> > type "double"
> >
> > I also try ploting:
> >
> > plot(test1)
> >
> > which gives :
> >
> > Error in plot.window(xlim, ylim, log, asp, ...) :
> > need finite 'xlim' values
> > In addition: Warning messages:
> > 1: no non-missing arguments to min; returning Inf
> > 2: no non-missing arguments to max; returning -Inf
> > 3: no non-missing arguments to min; returning Inf
> > 4: no non-missing arguments to max; returning -Inf
> >
> >
> >
> >
> > Thank you in advance
> >
> > _______________________________________________
> > 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