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)
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
conversion to polygons
4 messages · Luis Ridao Cruz, pedro at dpi.inpe.br, Roger Bivand
1 day later
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
Hi,
I also have same "problem". Sometimes I want to build a SpatialPolygons
from a set of points (a matrix) representing the border of a region,
and it has only one polygon.
SP <- SpatialPolygons(list(Polygons(list(Polygon(matrixdata))),ID=1)))
But ID in this case is not "necessary", and also the two levels of
list. At least for me, it is very common, and I can cite geoR and
splancs packages, where we have this kind of data. I think in this case
we could have a simpler code, and we could create it directly from the
matrix:
SP = SpatialPolygons(matrixdata)
or from the Polygon:
SP = SpatialPolygons(polygon)
The creation of the lists and ID could be hidden in SpatialPolygons-methods.R:
SpatialPolygons <- function(Srl, pO, proj4string=CRS(as.character(NA))) {
if( is.matrix(Srl) ) Srl <- list(Polygons(list(Polygon(Srl))),ID=1))
...
}
What do you think of it?
Pedro
Quoting Roger Bivand <Roger.Bivand at nhh.no>:
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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
On Fri, 16 Jun 2006 pedro at dpi.inpe.br wrote:
Hi,
I also have same "problem". Sometimes I want to build a SpatialPolygons
from a set of points (a matrix) representing the border of a region,
and it has only one polygon.
SP <- SpatialPolygons(list(Polygons(list(Polygon(matrixdata))),ID=1)))
But ID in this case is not "necessary", and also the two levels of
list. At least for me, it is very common, and I can cite geoR and
splancs packages, where we have this kind of data. I think in this case
we could have a simpler code, and we could create it directly from the
matrix:
SP = SpatialPolygons(matrixdata)
or from the Polygon:
SP = SpatialPolygons(polygon)
The creation of the lists and ID could be hidden in SpatialPolygons-methods.R:
SpatialPolygons <- function(Srl, pO, proj4string=CRS(as.character(NA))) {
if( is.matrix(Srl) ) Srl <- list(Polygons(list(Polygon(Srl))),ID=1))
...
}
What do you think of it?
Yes, good idea, I'll implement it once useR 2006 is over for SpatialPolygons and Spatial Lines. Thanks, Roger
Pedro Quoting Roger Bivand <Roger.Bivand at nhh.no>:
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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
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