View source: R/st_match_geometry.R
st_match_geometry | R Documentation |
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)
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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.