On Wed, Nov 25, 2009 at 03:41, Paulo Eduardo Cardoso
<
pauloed...@gmail.com> wrote:
> This is something to think about. I don't know how ggplot2 manage to
> plot cartesian coordinates or what is happening when we set a coord_map
> ().
>
> We'd need to know how ggplot2 deals generally with the relation
> between plot region/aspect ratio.
I must admit I was never sure of what exactly coord_map() was doing.
What's sure is that the aspect ratio should indeed no change when the
size of the plotting window changes (which it currently does). I
think/hope this is what Hadley is referring to when he talks about
"integrating the functionality of coord_equal to coord_map". This
would allow for further testing of this potentially very cool
functionality.
I have been plotting quite a few lat/lon based maps, in particular
within a GIS class (so we had directly comparisons). The method that I
found to be most reliable was to use:
coord_equal(ratio=cos(mean(latitude)*pi/180))
this works with latitude in decimal degrees, on small enough maps, far
enough from the poles. So of course, it is not a complete solution.
The other method is of course to transform all distances to meters and
plot that together with
coord_equal(ratio=1)
which is the default, so
coord_equal()
is enough. The conversion to meters can be done through projections
inside some geostatistics packages in R (gstat, geoR) or, if you want
to keep things a bit simpler, using a function that takes lat and lon
as input directly. I have found rdist.earth in fields not to be very
precise and have coded one from several sources I found online. It is
attached here. I can guarantee that the results are accurate but,
since it currently uses a loop, it can also be very slow. The way I
use it is:
data$x = geod.dist(refLon, refLat, data$lon, refLat)
data$y = geod.dist(refLon, refLat, refLon, data$lat)
I hope this helps a bit, for now.
Oh and, by the way Hadley, while coord_equal() works it also has the
annoying effect of forcing the plot to be square. The fact that I want
to coordinates to be equal does not mean that the region I want to
plot cannot be a rectangle. I gave you a few illustrated examples with
the behaviour I would expect a while back (email thread "ggplot2,
coord_equal and aspect ratio" started on Fri, Jan 11, 2008 by
jo.ir...@gmail.com), but in case they got lost, look at page 5 of
this file:
http://jo.irisson.com/teaching/villefranche/mapping_and_interpolation.pdf
I would rather have the x axis go from about 7.295 to 7.34, so that I
can easily juxtapose plots such as on page 6 for example. Currently
much of space is taken by useless grid squares that contain no data.
Thanks in advance for your help,
JiHO
---
http://maururu.net