1- # ' Cartesian coordinates with an aspect ratio approximating mercator projection.
1+ # ' Cartesian coordinates with an aspect ratio approximating Mercator projection.
22# '
33# ' The represenation of a portion of the earth, wich is approximately spherical,
44# ' onto a flat 2D plane requires a projection. This is what
2626# ' # Create a lat-long dataframe from the maps package
2727# ' nz <- map_data("nz")
2828# ' # Prepare a plot of the map
29- # ' nzmap <- ggplot(nz, aes(x= long, y= lat, group= group)) +
30- # ' geom_polygon(fill= "white", colour= "black")
29+ # ' nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) +
30+ # ' geom_polygon(fill = "white", colour = "black")
3131# '
3232# ' # Plot it in cartesian coordinates
3333# ' nzmap
@@ -51,8 +51,8 @@ coord_aspect.quickmap <- function(coord, ranges) {
5151
5252 # compute distance corresponding to 1 degree in either direction
5353 # from the center
54- x.dist <- dist_central_angle(x.center + c(- 0.5 ,0.5 ), rep(y.center ,2 ))
55- y.dist <- dist_central_angle(rep(x.center ,2 ), y.center + c(- 0.5 ,0.5 ))
54+ x.dist <- dist_central_angle(x.center + c(- 0.5 , 0.5 ), rep(y.center , 2 ))
55+ y.dist <- dist_central_angle(rep(x.center , 2 ), y.center + c(- 0.5 , 0.5 ))
5656 # NB: this makes the projection correct in the center of the plot and
5757 # increasingly less correct towards the edges. For regions of reasonnable
5858 # size, this seems to give better results than computing this ratio from
0 commit comments