Description Usage Arguments Examples
Imports a shp file and a data frame loaded into R, and does a spatial join between the points in the data frame and polygons in the shapefile
1 2 3 | spatial_join(shp, df, proj_crs, lat_var = "lat", lon_var = "lon",
df_crs = "+proj=longlat +datum=WGS84 +no_defs", binary_var = "inPolygon",
merge2shp = TRUE, plot_results = TRUE)
|
shp |
either a shapefile file location, or a spatial data frame imported using sf::st_read |
df |
data frame containing latitudes and longtitudes of the points to spatially join to 'shp'. Assumes the data are organized in a data frame containing columns lat_var and lon_var |
proj_crs |
PROJ4 string specifying the desired projection to use in spatial join. For help choosing projection see http://projectionwizard.org/ |
lat_var |
string specifying column in 'df' that contains the latitude coordinates. |
lon_var |
string specifying column in 'df' that contains the longitude coordinates. |
df_crs |
PROJ4 string specifying the coordinate reference system for 'df'. Assumed to be WGS84 if not specified. |
binary_var |
string specifiying the name of a new binary variable created in the output for whether the point is within any polygon in 'shp' or not |
merge2shp |
TRUE/FALSE if 'df' should be merged with the contents of 'shp' |
plot_results |
TRUE/FALSE if a leaflet map of the join should be plotted |
1 2 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.