Help with great circles on a recentered worldmap, in ggplot

260 views
Skip to first unread message

K P

unread,
May 26, 2012, 6:37:19 PM5/26/12
to ggp...@googlegroups.com
There is an amazing blog entry on creating great circles on a recentered worldmap, in ggplot here which is brilliant:

http://www.stanford.edu/~cengel/cgi-bin/anthrospace/great-circles-on-a-recentered-worldmap-in-ggplot/

However, I'm having a similar problem to another commenter with ggplot2 0.9:

Error: could not find function "fortify.SpatialLinesDataFrame"

I see a fix referenced here but implementation is a bit over my head (I don't quite follow): 


Do any of the smart folks here have any pointers? Do I paste the entirety of https://github.com/hadley/ggplot2/blob/master/R/fortify-spatial.r into the script. Do I have to modify it? (Sorry to cross-post if your familiar with that blog entry).

Thank you, thank you!


einar

unread,
May 28, 2012, 2:31:20 PM5/28/12
to ggplot2
I assume you are using ggplot 0.9 rather than ggplot 0.89
On the cited blogpage we have the following: "Apparently there is an
issue with ggplot 0.9 and the fortify which was not in ggplot 0.89"
The workaround, for now, is also on the webpage, although a bit
cryptic. What you need to do is to take the code at this cite:
https://github.com/hadley/ggplot2/blob/master/R/fortify-spatial.r
and run it before running the script provided on the blogpage.
Consider this as an interim fix, i am sure this will be fixed (if not
already) in updated versions of ggplot2.
regards,
einar


On May 26, 10:37 pm, K P <ken...@kentonpowell.com> wrote:
> There is an amazing blog entry on creating great circles on a recentered
> worldmap, in ggplot here which is brilliant:
>
> http://www.stanford.edu/~cengel/cgi-bin/anthrospace/great-circles-on-...
>
> However, I'm having a similar problem to another commenter with ggplot2 0.9:
>
> Error: could not find function "fortify.SpatialLinesDataFrame"
>
> I see a fix referenced here but implementation is a bit over my head (I
> don't quite follow):
>
> http://www.stanford.edu/~cengel/cgi-bin/anthrospace/great-circles-on-...

Winston Chang

unread,
May 28, 2012, 3:46:52 PM5/28/12
to K P, ggp...@googlegroups.com
An easier way to do it is to use this:
 rts.ff <- ggplot2:::fortify.SpatialLinesDataFrame(rts)

But this isn't a good long-term solution. What it should be doing is dispatching fortify() on the class of the object rts -- but in this case the class is SpatialLines, not SpatialLinesDataFrame, and so it's not calling the proper function:

> class(rts)
[1] "SpatialLines"
attr(,"package")
[1] "sp"


I'm not familiar with these kinds of objects -- are SpatialLines objects supposed to be the same as SpatialLinesDataFrame objects? If so, then it's a trivial fix in the ggplot2 code; if not, it might be more complicated.

-Winston




--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
Reply all
Reply to author
Forward
0 new messages