[R-sig-Geo] Positing a coord_proj for ggplot2

Hadley Wickham h.wickham at gmail.com
Tue Jul 28 18:22:37 CEST 2015


>> 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?

Hadley

-- 
http://had.co.nz/



More information about the R-sig-Geo mailing list