[R-sig-Geo] Positing a coord_proj for ggplot2
Roger.Bivand at nhh.no
Tue Jul 28 21:36:26 CEST 2015
On Tue, 28 Jul 2015, Hadley Wickham wrote:
>>> This won't be in ggplot2 right now as Hadley is updating/refactoring
>>> the package and "coords" are going to work a bit differently. Plus
>>> this adds a dependency I'm not sure he wants to add to it. You can
>>> stick it in your own, local copy of ggplot2 and re-collate and rebuild
>>> to use it.
>>> proj4::project (and even spTransform, to a certain degree - no pun
>>> intended) are unhappy dealing with lat/lon values outside the -90/90 :
>>> -180:180 range and even have some issues with points right at the
>>> extremes, so I did the following in the linked code:
>>> df$x <- ifelse(df$x <= -180, -179.999999999, df$x)
>>> df$x <- ifelse(df$x >= 180, 179.999999999, df$x)
>>> df$y <- ifelse(df$y <= -90, -89.999999999, df$y)
>>> df$y <- ifelse(df$y >= 90, 89.999999999, df$y)
>> This may well be unsafe, as 0 - 360 is also valid for longitudes, and in
>> many cases -180 - 360 will also be feasible. The test in sp is in
>> sp:::.ll_sanity() which uses an internal tolerance (which may be set) to do
>> similar checks.
> Is there a function to do this the "right" way? i.e. cut the
> antimeridian after rotation?
Not really, because the changes made are most often heuristics based on
use cases for places near the antimeridian needing planar plotting. The
"cleanest" solution is probably to determine either 0 to 360 or -180 to
180 for a given prime meridian, and fold back anything out of domain, so
that it can always be displayed on a sphere. -2 or 26 hours is similar in
relation to daily time (really 2200 the day before or 0200 the day after).
A question on the proj-devel list would probably elicit a principled
response; I think for example that New Zealand cartographers have a lot of
experience that many others (US, Europe) do not have.
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo