Plotting magnetic declination contours on ortho projection #1873
-
Hello, A couple of related questions:
Is this simple for me to correct? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Thanks for raising this. You are not alone! Map projections are difficult. First, regarding whether more recent versions act differently -- the simplest answer is to try installing the github version and seeing for yourself. Or, provide a reproducible example so someone else can try it. (The first option is best because it will only take you 5 minutes to try the latest version.) Second, regarding problems with projections: we have had these for years. It is a tough problem to crack because we want a general solution that will work across a range of projections. Some of the oldest issues in this project relate to projections. Since it is tricky, there is really very little chance that a repair can be done for your own particular case. Third, regarding the error, please open an issue and provide a reproducible example, using the Finally, there is a way to get any projection to sort of work. That is, draw topography, instead of coastlines. Oce comes with a coarse topography, but you can always download a much finer dataset and use that. (There are hints about doing all this in the oce docs.) Below is a reprex that shows a way to escape the projection-of-coastline problem: draw bathymetry instead! In my own field, this is more relevant anyway: national boundaries have no importance to oceanography, and the coastline is only slightly relevant: depth is what matters. PS. I hope you can see how this is nice, because it shows code that certainly works, along with the output ... so please use a reprex if you make an issue, which I recommend. Also, in your issue, include the output from library(oce)
#> Loading required package: gsw
data(coastlineWorld)
data(topoWorld) # download and read your own data for finer resolution
latHalifax <- 44.6
lonHalifax <- -63.6
par(mar=rep(1, 4))
proj <- paste0("+proj=ortho +lon_0=", lonHalifax, " +lat_0=", latHalifax)
mapPlot(coastlineWorld, proj=proj, type="n",
col=2, pch=20, cex=0.5, axes=FALSE,
grid=FALSE, longitudelim=lonHalifax+c(-180,180), latitudelim=c(45,135))
mapImage(topoWorld, colormap=colormap(name="gmt_globe"))
mapLines(coastlineWorld)
mapGrid(col="white", lwd=1.4, polarCircle=5)
mapGrid(col="magenta", lwd=1.4, polarCircle=5)
box()
mapPoints(lonHalifax, latHalifax, col=2, pch=20, cex=3) Created on 2021-09-30 by the reprex package (v2.0.1) |
Beta Was this translation helpful? Give feedback.
Thanks for raising this. You are not alone! Map projections are difficult.
First, regarding whether more recent versions act differently -- the simplest answer is to try installing the github version and seeing for yourself. Or, provide a reproducible example so someone else can try it. (The first option is best because it will only take you 5 minutes to try the latest version.)
Second, regarding problems with projections: we have had these for years. It is a tough problem to crack because we want a general solution that will work across a range of projections. Some of the oldest issues in this project relate to projections. Since it is tricky, there is really very little chance that a re…