我有一个大学和学院的形状档案,可以在这里找到:
目标是通过各个经纬度坐标数据集运行shapefile,以查看哪些坐标属于大学shapefile的范围.因此,这些坐标将存储在名为id_coordinates
的数据集中
id_coordinates <- st_as_sf(id_coordinates, coords = c("id_longitude", "id_latitude"), crs = 4326)
然后我们打开shapefile本身:
# Set the file paths for the shapefiles
college_fp <- "Colleges_and_Universities_Campuses/CollegeUniversityCampuses.shp"
# Read in the shapefiles
college_sf <- st_read(college_fp) %>% filter(STATE == 'VA')
然后我们将id_coordinates
转换为与college_sf
一致
id_coordinates_transform <- st_transform(pa_vf, st_crs(college_sf))
然后,我们将它们连接在一起,以查看哪些ID具有落入shapefile边界内的经度/长度:
results_join <- st_join(id_coordinates_transform, college_sf, join = st_within)
但是,如果我想在college_sf
中找到的shapefile周围再创建一个半径为1英里的"缓冲区",我该怎么办呢?那会是什么样子?
编辑:使用st_buffer
函数,但这似乎让它变得太大了?
buffer_radius <- 1609.34
college_sf_buffer <- st_buffer(college_sf, dist = buffer_radius)