[R-sig-Geo] Accessing gshhs database of world coastlines

Roger Bivand Roger.Bivand at nhh.no
Sun Oct 16 20:09:48 CEST 2005


On Sun, 16 Oct 2005, Denis Chabot wrote:

> Hi,
> 
> Forgive me if this should be posted to another list relating to GMT  
> or the gshhs database. I do not know of any such list at the moment,  
> and my goal is to use the data in R anyway.
> 
> Until now I have made maps with the high-resolution world map that  
> comes with PBSmapping. As explained in the user guide, these are a  
> lower resolution version of the gshhs full-resolution database. But  
> it is not quite good enough for maps of my part of the world. A few  
> islands are missing that I'd like to have, and the details of the  
> coastline are not always at a sufficient resolution.
> 
> I would have like to make my own coastline database from the original  
> gshhs database, a version that would only have covered -80 to -20 in  
> longitude, and 35 to 75 in latitude. I can lower resolution and clip  
> to smaller areas with functions provided in PBSmapping so I'd be fine  
> for most maps I have to make.
> 
> The problem is that I have next to no experience with compiling  
> programs and I don't know how to install GMT (which I could use to  
> extract the coastline) or the smaller programs provided just to  
> interact with the database.
> 
> I thought I did not need to because a shapefile version of the  
> database exists, and I have managed (with help from Roger in  
> particular) to import such files in R before. But this one is huge  
> (154 MB for the shp file alone). The function read.shape refuses to  
> open it, telling me right way
> 
> Erreur dans read.shape("gshhs_land.shp") : unable to open file

This means read.shape() cannot see the file. I managed to read 
gshhs_land.shp into R with current maptools:

> try1 <- read.shape("gshhs_land.shp")
Shapefile type: PolyLine, (3), # of Shapes: 191811
> object.size(try1)
[1] 395387692

but it is a shapefile of lines, not polygons - the base GSHHS is now 
polygonal. I have 1GB under linux, so I think memory management is 
effectively the same as yours. I've put a PDF (33MB) of your area on:

http://spatial.nhh.no/misc/nw_atlantic.pdf

please save link as, and open locally, otherwise you'll be sitting looking 
at a blank screen for a long time. I did this so that you can use the 
Acroread zoom to find out if your islands are there.

read.shape() was not too slow, it seemed to go quite well.

Is there any use in writing an R function on top of the gshhs program for 
extracting polygons from the gshhs databases directly into sp class 
objects - it doesn't look too difficult, and would give direct access 
without having to use the shapefile?

Roger


> 
> I tried with function read.shapefile, which attempts to open the  
> shapefile but never finishes (I stopped it after 12 h. Thus the  
> shapefile is either a bit weird (it had more than the usual 3 files  
> on the web site, I just downloaded the shp, dbf and shx files) or it  
> is too big, though I have 1 GB of RAM on my Mac.
> 
> It appears I'll have to compile and learn to use the programs  
> provided with that database to extract the data I want to import to R.
> 
> Has anyone done this before? Can you point me to a site that explains  
> how to compile these small c programs on Mac OS X, as a first step?  
> Are there instructions, somewhere, on how you'd specify the lat long  
> you want to extract to an ascii file? I did not see any on the GMT site.
> 
> Maybe I'm doing all this for nothing and there is already a world  
> coastline (preferably with main lakes and rivers too) database at  
> high resolution available for R, beside the ones that come with maps  
> (which does not allow me enough flexibility) and PBSmapping (not  
> quite high enough resolution)?
> 
> Sincerely,
> 
> Denis Chabot
> 
> _______________________________________________
> 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