Prompted by a recent post,  I have discovered rworldmap, which look set to
make my life much easier, apart from a wrinkle I can't get my head round.

I am writing a function to plot a map clipped to a given extent, and I'd
like to be able to do so at different resolutions. This is easy to do using
the different datasets (eg countriesCoarse, countriesHigh). I have two
problems (i) they have (slightly) different proj4strings and (ii) when I
pick up the proj4string to assign it to my clipping polygon CRS() alters
it, causing the gDifference (etc) to complain they are different. Any
thoughts on the best way to straighten this out?
many thanks
rob


Example:
library(rworldmap)
library(rworldxtra)
data(countriesCoarse)
data(countriesHigh)

proj4string(countriesCoarse)
# [1] "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
proj4string(countriesHigh)
# [1] " +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"

clip_poly <- readWKT("POLYGON((-50 40,-50 70,50 70,50 40,-50 40))")
proj4string(clip_poly) <- CRS(proj4string(countriesCoarse))
proj4string(clip_poly)
# [1] "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
# the +towgs84 tag has been added

res <- gDifference(clip_poly, countriesCoarse)
# generates Warning: spgeom1 and spgeom2 have different proj4 strings

sessionInfo:
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C

[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] ks_1.8.13          misc3d_0.8-4       rgl_0.93.960
mvtnorm_0.9-9995   KernSmooth_2.23-10
 [6] rgdal_0.8-11       raster_2.1-49      rgeos_0.2-20
rworldxtra_1.01    rworldmap_1.3-1
[11] sp_1.0-12          RMark_2.1.6-1      reshape_0.8.4      plyr_1.8


loaded via a namespace (and not attached):
 [1] coda_0.16-1         fields_6.8          foreign_0.8-53      grid_3.0.1
         lattice_0.20-23
 [6] maptools_0.8-27     matrixcalc_1.0-3    msm_1.2
OpenStreetMap_0.3.1 rJava_0.9-4
[11] snowfall_1.84-4     spam_0.40-0         splines_3.0.1
survival_2.37-4     tools_3.0.1






****** The new Bird Atlas is coming: http://www.bto.org/shop/bird-atlas
  *******

Dr Rob Robinson, Principal Ecologist
British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU
Ph: +44 (0)1842 750050     E: rob.robinson@bto.org
Fx: +44 (0)1842 750030     W: www.bto.org/about-bto/our-staff/rob-robinson

====== "How can anyone be enlightened, when truth is so poorly lit" =======

	[[alternative HTML version deleted]]

