Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick approximation for map projections #922

Merged
merged 4 commits into from
Mar 25, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix coding style and spelling for new coord_quickmap
  • Loading branch information
jiho committed Mar 17, 2014
commit f64ed7e3687efa0361b1b0aaa51f83058f591b91
10 changes: 5 additions & 5 deletions R/coord-quickmap.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Cartesian coordinates with an aspect ratio approximating mercator projection.
#' Cartesian coordinates with an aspect ratio approximating Mercator projection.
#'
#' The represenation of a portion of the earth, wich is approximately spherical,
#' onto a flat 2D plane requires a projection. This is what
Expand Down Expand Up @@ -26,8 +26,8 @@
#' # Create a lat-long dataframe from the maps package
#' nz <- map_data("nz")
#' # Prepare a plot of the map
#' nzmap <- ggplot(nz, aes(x=long, y=lat, group=group)) +
#' geom_polygon(fill="white", colour="black")
#' nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) +
#' geom_polygon(fill = "white", colour = "black")
#'
#' # Plot it in cartesian coordinates
#' nzmap
Expand All @@ -51,8 +51,8 @@ coord_aspect.quickmap <- function(coord, ranges) {

# compute distance corresponding to 1 degree in either direction
# from the center
x.dist <- dist_central_angle(x.center+c(-0.5,0.5), rep(y.center,2))
y.dist <- dist_central_angle(rep(x.center,2), y.center+c(-0.5,0.5))
x.dist <- dist_central_angle(x.center + c(-0.5, 0.5), rep(y.center, 2))
y.dist <- dist_central_angle(rep(x.center, 2), y.center+c(-0.5, 0.5))
# NB: this makes the projection correct in the center of the plot and
# increasingly less correct towards the edges. For regions of reasonnable
# size, this seems to give better results than computing this ratio from
Expand Down
6 changes: 3 additions & 3 deletions man/coord_quickmap.Rd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{coord_quickmap}
\alias{coord_quickmap}
\title{Cartesian coordinates with an aspect ratio approximating mercator projection.}
\title{Cartesian coordinates with an aspect ratio approximating Mercator projection.}
\usage{
coord_quickmap(xlim = NULL, ylim = NULL)
}
Expand Down Expand Up @@ -35,8 +35,8 @@ if (require("maps")) {
# Create a lat-long dataframe from the maps package
nz <- map_data("nz")
# Prepare a plot of the map
nzmap <- ggplot(nz, aes(x=long, y=lat, group=group)) +
geom_polygon(fill="white", colour="black")
nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black")

# Plot it in cartesian coordinates
nzmap
Expand Down