Skip to content

R-sig-Geo Digest, Vol 26, Issue 12

2 messages · Denis Chabot, Roger Bivand

#
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.

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!

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?

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".

Cheers,

Denis
Le 05-10-22 ? 06:00, r-sig-geo-request at stat.math.ethz.ch a ?crit :
#
On Mon, 24 Oct 2005, Denis Chabot wrote:

            
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.
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.
The next release of sp will pass the bg= argument through plot.Spatial 
properly, thanks for reminding me.
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