Skip to content

Instantly share code, notes, and snippets.

@geotheory
Created February 22, 2016 00:20
Show Gist options
  • Save geotheory/2e53c0a4591601a88b4b to your computer and use it in GitHub Desktop.
Save geotheory/2e53c0a4591601a88b4b to your computer and use it in GitHub Desktop.
Return proj4 CRS object defining a two-point equidistant projection fitting a spatial object
require(raster)
project_tpe = function(d, x=0, y=0){
d = data.frame(t(as.matrix(extent(d))))
dy = mean(d$y)
CRS(paste0("+proj=tpeqd +lat_1=", dy, " +lon_1=", d$x[1],
" +lat_2=", dy, " +lon_2=", d$x[2], " +x_0=", x, " +y_0=", y,
" +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment