[R-sig-Geo] help with rgdal
Roger Bivand
Roger.Bivand at nhh.no
Tue Jun 13 08:36:59 CEST 2006
On Tue, 13 Jun 2006, FISCHER, Matthew wrote:
>
>
> Hi R-sig-geo,
>
>
>
> I'm running R under windows, and trying to get the example below to
> work, and wondering why it is not.
This isn't about rgdal, by the way, the main function called -
map2SpatialPolygons() - is in the off-CRAN spmaps package. The example
you use is currently in the help file to that function, it isn't on
http://rgdal.sourceforge.net/, nor on
http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html, which is where the
spmaps examples outside the package itself are.
Beyond that, I can't replicate it either. Which version of sp and spmaps
are you using (sessionInfo())? What does bbox(nor_coast_poly_sp) say (if
the bounding box is wrong, you may get Inf in plot.Spatial? What does
class(nor_coast_poly_sp) - is plot() dispatching on the correct class?
I get:
> bbox(nor_coast_poly_sp)
min max
r1 4.804193 31.02664
r2 58.030025 71.12916
> class(nor_coast_poly_sp)
[1] "SpatialPolygons"
attr(,"package")
[1] "sp"
Roger
>
> I've read the info at:
>
> http://rgdal.sourceforge.net/ <http://rgdal.sourceforge.net/>
>
>
>
> Example:
>
> nor_coast_poly <- map("world", "norway", fill=TRUE, col="transparent", plot=FALSE)
>
> > range(nor_coast_poly$x, na.rm=TRUE)
>
> [1] 3.354152 31.026640
>
> > range(nor_coast_poly$y, na.rm=TRUE)
>
> [1] -54.46084 71.12916
>
> > nor_coast_poly <- map("world", "norway", fill=TRUE, col="transparent", plot=FALSE, ylim=c(58,72))
>
> > nor_coast_poly$names
>
> [1] "Norway" "Norway:Tana" "Norway:Stjernoya"
>
> [4] "Norway:Karlsoy" "Norway:Seiland" "Norway:Soroya"
>
> [7] "Norway:Vega" "Norway:Hareidlandet" "Norway:Froya"
>
> [10] "Norway:Andoya" "Norway:Hitra" "Norway:Gurskoya"
>
> [13] "Norway:Langoya" "Norway:Arnoy" "Norway:Vannoy"
>
> [16] "Norway:Mageroya" "Norway:Hinnoya" "Norway:Senja"
>
> [19] "Norway:Sunnhordland" "Norway:Ringvassoy" "Norway:Vestvagoy"
>
> [22] "Norway:Austvagoy" "Norway:Nordhordland" "Norway:Bremangerland"
>
> [25] "Norway:Moskenesoya" "Norway:Kvaloy" "Norway:Kvaloya"
>
> [28] "Norway:Smola" "Norway:Karmoy" "Norway:Vikna"
>
> > IDs <- sapply(strsplit(nor_coast_poly$names, ":"), function(x) x[1])
>
> > nor_coast_poly_sp <- map2SpatialPolygons(nor_coast_poly, IDs=IDs, proj4string=CRS("+proj=longlat +datum=wgs84"))
>
> > getSpPnParts(nor_coast_poly_sp)
>
> [1] 30
>
> > plot(nor_coast_poly_sp, col="grey", axes=TRUE)
>
> 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
>
>
>
>
>
> R starts off like this:
>
> Loading required package: methods
>
> Loading required package: sp
>
> Loading required package: abind
>
> Loading required package: pixmap
>
> Geospatial Data Abstraction Library extensions to R successfully loaded
>
> Search()
>
> [1] ".GlobalEnv" "package:spmaps" "package:rgdal" "package:pixmap"
>
> [5] "package:abind" "package:sp" "package:methods" "package:akima"
>
> [9] "package:ncdf" "package:misc3d" "package:rgl" "package:tkrplot"
>
> [13] "package:tcltk" "package:mapproj" "package:mapdata" "package:maps"
>
> [17] "Autoloads" "package:base"
>
>
>
> So there is no indication that something hasn't been loaded properly?
>
>
>
> Any help appreciated,
>
>
>
> Matt.
>
>
>
>
>
> Dr Matt Fischer
>
> ANSTO - Environmental Research
>
> PMB1 Menai NSW 2234
>
> Ph: + 61 2 9717 9686
>
> Fax: +61 2 9717 3038
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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