Skip to content
Prev 15823 / 29559 Next

Extracting GSHHS global coastlines

On Thu, 9 Aug 2012, r-sig-geo.20.trevva at spamgourmet.com wrote:

            
Either of:

world <- Rgshhs(gshhs.file, level=1,checkPolygons=TRUE)

or

xlims <- c(-180,360)
world <- Rgshhs(gshhs.file, xlim=xlims, ylim=ylims, level=1,
   checkPolygons=TRUE)

work. Clipping on Greenwich seems to cause problems with a sliver, 
generating a single point (a degenerate polygon) and two polygons for Kent 
and East Anglia. I've committed a fix to R-Forge SVN, but the output is 
unattractive, with polygon splitting on 180 degrees causing trouble. A few 
islands seem to flip from +180 to -180, creating havoc. In addition, 
Antarctica is -180, 180, so looks bad. Consider using the wrld_simpl 
dataset in maptools, or similar in the rworldmaps package instead if you 
need country boundaries, or merge them out with:

all_wrld <- unionSpatialPolygons(wrld_simpl, rep("land",
   nrow(wrld_simpl)), threshold=5)

which uses threshold= to filter out boundary slivers. Maybe even easier is 
the maps package and map2SpatialPolygons() in maptools if all you need is 
a background world land map.

Roger