Title: | Repair Functions for 'sf' Package Objects |
---|---|
Description: | A group of functions that support the 'sf' package, focused primarily on repairing polygons that break when re-projected. |
Authors: | Mark Ravina [aut, cre] |
Maintainer: | Mark Ravina <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.2.0 |
Built: | 2025-01-16 11:02:26 UTC |
Source: | CRAN |
This function uses the API for the World Historical Gazeteer to geolocate place names. It takes the place name and region as inputs and returns a data frame with results, primarily the longitude and latitude.
geolocate(df, place = "place", iso = "iso")
geolocate(df, place = "place", iso = "iso")
df |
A data frame with two columns, places names and two-letter ISO codes for regions |
place |
A column with toponyms in the data frame |
iso |
A column of ISO codes for regions |
A data frame of the geospatial data
# Search for Paris and Edo (now Tokyo) example.df <- data.frame("place" = c("Paris","Edo"), "iso" = c("FR","JP")) geolocate(example.df)
# Search for Paris and Edo (now Tokyo) example.df <- data.frame("place" = c("Paris","Edo"), "iso" = c("FR","JP")) geolocate(example.df)
Create and equal area grid for multiple maps
st_equal_grid(places, titles, buffer, map_theme)
st_equal_grid(places, titles, buffer, map_theme)
places |
a list of sf object |
titles |
a character vector of title for the maps |
buffer |
a numeric vector of buffer values |
map_theme |
a ggplot theme |
A list of sf objects
This function sets the geometry in a target data frame based on matching values in a source data frame
st_match_geometry(source, target, match_field)
st_match_geometry(source, target, match_field)
source |
An sf data frame with a geometry column |
target |
A data frame |
match_field |
A column name (in quotes) for matching, shared by both data frames |
A sf data frame
a <- sf::st_polygon(list(rbind(c(-90,40),c(-90,50),c(-95,50),c(-95,40),c(-90,40)))) b <- sf::st_polygon(list(rbind(c(-80,30),c(-80,20),c(-70,20),c(-70,30),c(-80,30)))) ab <- sf::st_sfc(a,b) sf::st_crs(ab) <- 4326 source.sf <- data.frame("match_field"=c("A","B")) sf::st_geometry(source.sf) <- ab target.df <- data.frame("match_field"=c("A","A","B","C"))
a <- sf::st_polygon(list(rbind(c(-90,40),c(-90,50),c(-95,50),c(-95,40),c(-90,40)))) b <- sf::st_polygon(list(rbind(c(-80,30),c(-80,20),c(-70,20),c(-70,30),c(-80,30)))) ab <- sf::st_sfc(a,b) sf::st_crs(ab) <- 4326 source.sf <- data.frame("match_field"=c("A","B")) sf::st_geometry(source.sf) <- ab target.df <- data.frame("match_field"=c("A","A","B","C"))
Create outline of sf projection
st_transform_outline(crs)
st_transform_outline(crs)
crs |
The crs for transforming the sf |
An sf object
Repair sf polygons
st_transform_repair(x, crs)
st_transform_repair(x, crs)
x |
An sf object with unprojected coordinates |
crs |
The crs for transforming the sf |
An sf object