R/from_stplanr.R

Defines functions geo_project

geo_select_aeq.sf = function (shp) {
  #cent <- sf::st_geometry(shp)
  coords <- sf::st_coordinates(shp)
  coords_mat <- matrix(coords[, 1:2], ncol = 2)
  midpoint <- apply(coords_mat, 2, mean)
  aeqd <- sprintf("+proj=aeqd +lat_0=%s +lon_0=%s +x_0=0 +y_0=0", 
                  midpoint[2], midpoint[1])
  sf::st_crs(aeqd)
}


geo_select_aeq.sfc = function (shp) {
  #cent <- sf::st_geometry(shp)
  coords <- sf::st_coordinates(shp)
  coords_mat <- matrix(coords[, 1:2], ncol = 2)
  midpoint <- apply(coords_mat, 2, mean)
  aeqd <- sprintf("+proj=aeqd +lat_0=%s +lon_0=%s +x_0=0 +y_0=0", 
                  midpoint[2], midpoint[1])
  sf::st_crs(aeqd)
}

geo_select_aeq = function (shp) {
  UseMethod("geo_select_aeq")
}


geo_project = function(shp) {
  crs = geo_select_aeq(shp)
  st_transform(shp, crs = crs)
}

Try the zonebuilder package in your browser

Any scripts or data that you put into this service are public.

zonebuilder documentation built on July 13, 2021, 1:06 a.m.