[R-sig-Geo] New sp add-on packages on sourceforge repository

Roger Bivand Roger.Bivand at nhh.no
Mon Oct 24 18:04:45 CEST 2005


On Mon, 24 Oct 2005, Denis Chabot wrote:

> Hi Roger,
> 
> Many thanks for Rgshhs. I am very glad to have this additional source  
> of coastlines.
> 
> A few comments.
> 
> I am impressed with axis label handling when using the "plot" command  
> on the spatial polygons imported by Rghhs. I like the suffix given to  
> each number, e.g. "300°E". How do you do this? Setting some kind of  
> "unit" attribute to the longitudes and latitudes? I don't know how to  
> do this, otherwise I'd implement it in the maps I produce with  
> PBSmapping.

It is sp parsing the projection slot of the object and finding "longlat", 
inserted here automatically because we know the coordinate reference 
system of the data. The actual code is in sp, and was written by Edzer 
Pebesma, it is rather neat; look at sp:::degreeLabelsNS, 
sp:::degreeLabelsEW, and sp:::plot.Spatial - something similar should work 
in PBSmapping with a test on LL.

> 
> Second surprise: I reimported the same area but using the option  
> "shift=TRUE" to get longitudes West. I'm used to these numbers being  
> negative, and indeed they still are here as I must select negative  
> longitudes to define xlim. But when issuing the plot command, they  
> are labelled properly, i.e. -70 becomes "70°W". In PBSmapping I must  
> turn automatic xaxis labelling off and relabel myself. I may switch  
> to your classes and methods yet!

The next release of sp will label 300°E as 60°W, but the underlying 
coordinates will stay in the GSHHS format, so you'll still need shift. The 
shift argument works badly for polygons crossing 180°, but maybe that 
isn't a practical problem, because people working there probably want to 
stay in the 150-210 range anyway.

> 
> However in my first test, I got the lakes to be coloured "azure2" but  
> not the ocean, which was white:
> 
> NWA.i <- Rgshhs("gshhs_i.b", shift=TRUE, xlim = c(280,340), ylim = c 
> (35,75), verbose = TRUE)
> plot(NWA.i$SP, xlim=c(-70, -55), ylim=c(45, 51), col="khaki",  
> pbg="lightblue", axes=T)
> 
> So I read the html doc on sp and discovered pbg was the color of  
> "holes", which lakes are but not the ocean, which is just the absence  
> of polygons. So I added a bg color to the above plot command, which  
> should have taken care of that, but it did not. Do you know why?

The next release of sp will pass the bg= argument through plot.Spatial 
properly, thanks for reminding me.

> 
> Another question: the help on Rgshhs says we can import only land,  
> for instance, instead of the 4 hierarchic types in gshhs files, by  
> adding "level=1". But if I import everything, can I decide later to  
> make a plot with land only? Or to create a layer with only lakes (no  
> coastline)? I consulted the help for sp as well as the documentation  
> for sp but could not figure out how to do this. When I print the list  
> created by Rgshhs or even just the SP part of it, I see that SP is  
> made of "slots", one of which contains the level. This information is  
> also available in the spatialdata part. But I don't know how to  
> select just the polygons with "level==2".

The sp polygons do not know about levels, so once things are inside a 
Polygons object, there is no way back out. I think this means separate 
imports for levels 1, 1:2, 1:3 or 1:4. 

I'm running several jobs now to pre-can the inclusion data of which GSHHS 
polygons at levels 4:2 belong to which at level 1, which should make 
importing shorelines much faster, so a revision will be along before too 
many days have gone, I hope.

Best wishes,

Roger

> 
> Cheers,
> 
> Denis
> Le 05-10-22 à 06:00, r-sig-geo-request at stat.math.ethz.ch a écrit :
> 
> > Send R-sig-Geo mailing list submissions to
> >     r-sig-geo at stat.math.ethz.ch
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > or, via email, send a message with subject or body 'help' to
> >     r-sig-geo-request at stat.math.ethz.ch
> >
> > You can reach the person managing the list at
> >     r-sig-geo-owner at stat.math.ethz.ch
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of R-sig-Geo digest..."
> >
> >
> > Today's Topics:
> >
> >    1. New sp add-on packages on sourceforge repository (Roger Bivand)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Fri, 21 Oct 2005 15:10:43 +0200 (CEST)
> > From: Roger Bivand <Roger.Bivand at nhh.no>
> > Subject: [R-sig-Geo] New sp add-on packages on sourceforge repository
> > To: r-sig-geo at stat.math.ethz.ch
> > Message-ID: <Pine.LNX.4.44.0510211454280.19619-100000 at reclus.nhh.no>
> > Content-Type: TEXT/PLAIN; charset=US-ASCII
> >
> > I have released two new sp add-on packages on the r-spatial  
> > repository.
> >
> > Rgshhs converts GSHHS shorelines (as closed polygons) to sp class
> > SpatialPolygons, which can then be written out as shapefiles for the
> > chosen region. It's now very slow for full resolution, because  
> > clipping
> > the largest land polygons takes a lot of time, but hopefully people  
> > don't
> > do that every time they need data. It is provided with the coarse  
> > dataset,
> > but works with the full and the others. It leaves the longitude
> > coordinates in the -20 to 360 range like the data source. Details  
> > of the
> > Global Self-consistent, Hierarchical, High-resolution Shoreline  
> > Database
> > are avialable from:
> >
> > http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html
> >
> > where the low, intermediate, high, and full resolution data may be
> > downloaded from. I'd be grateful for ideas for making it faster,  
> > and am
> > looking at providing indices of which level polygons are included in
> > next-level polygons preprocessed in the package rather than  
> > computing them
> > each time for chosen polygons.
> >
> > A second package is spspatstat, providing interfaces between some sp
> > classes and the well-supported point pattern analysis package  
> > spatstat.
> > The spatstat ppp and owin classes are matched with sp equivalents.
> >
> > To get a feel for where sp is going, (and after installing sp and
> > spatstat from CRAN with their dependencies, and the new packages from
> > http://r-spatial.sourceforge.net/R), try:
> >
> > library(Rgshhs)
> > library(spspatstat)
> > gshhs.c.b <- system.file("share/gshhs_c.b", package = "Rgshhs")
> > NZx <- c(160, 180)
> > NZy <- c(-50, -30)
> > NZ <- Rgshhs(gshhs.c.b, xlim = NZx, ylim = NZy)
> > plot(runifpoint(500, as(NZ$SP, "owin")))
> >
> > Hoping for feedback,
> >
> > Roger
> >
> > -- 
> > 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
> >
> >
> > End of R-sig-Geo Digest, Vol 26, Issue 12
> > *****************************************
> >
> 
> _______________________________________________
> 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