简体   繁体   English

找出我的数据框中有多少点与区域shapefile重叠

[英]find out how many of points in my dataframe are overlapping an area shapefile

I have a dataframe containing list of all accidents and their locations (about 10,000 location coordinates) that took place in a city in a month. 我有一个数据框,其中包含一个月内某个城市发生的所有事故及其位置(约10,000个位置坐标)的列表。

Accident ID   Name         latitudes longitudes    Intensity  time
 1           citycentre     -25.5567   +54.00087     minor    morning
 2           
 3
 4

I need to find how many of those accidents took place between a given set of longitudes and latitudes.(eg between latitudes 25'S and 27'S, lontitudes 54 E and 55 E) 我需要找出在给定的一组经度和纬度之间(例如在25'S和27'S纬度,54 E和55 E纬度之间)发生了哪些事故。

Is there a way to do such a thing on RI am new to R so any help will be much appreciated.I have to do the same process with data from a large number of months and between different pairs of coordinates.So running a loop and using a counter variable will be very time consuming. 有没有办法在RI上对RI来说是陌生的,所以任何帮助将不胜感激。我必须对来自大量月份且在不同坐标对之间的数据执行相同的处理。使用计数器变量将非常耗时。

Is there a functional available that will tell me the number of accidents if I make my study area into a polygon shape file 如果我将学习区域制成多边形形状文件,是否有可用的功能可以告诉我发生事故的次数

I'm sure there are many ways to do it. 我敢肯定有很多方法可以做到。 Here's just one using non-equi joins: 这只是使用非等额联接的一种:

library(data.table)
points <- fread("Accident_ID   Name         latitudes longitudes    Intensity  time
 1           citycentre     -28.5567   +54.50087     minor    morning
 2           citycentre     -28.5567   +54.50087     minor    morning
 3           citycentre     0   0     minor    morning
 4           citycentre     100   100     minor    morning")
extents <- data.table(
  extent_id=1:3, 
  x1=c(-30, -20, 1000), 
  x2=c(-27, 20, 1100), 
  y1=c(54, -54, 100), 
  y2=c(55, 55, 100)
)
points[extents, on=.(latitudes>=x1, latitudes<=x2, longitudes>=y1, longitudes<=y2)][
  ,.(N=sum(!is.na(Accident_ID))), by=extent_id]
#    extent_id N
# 1:         1 2
# 2:         2 1
# 3:         3 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从具有多边形/区域和点(纬度,经度)的shapefile中,找出每个点属于哪个多边形/区域? 在R中 - From a shapefile with polygons/areas, and points (lat,lon), figure out which polygon/area each point belongs to? In R R:找出每组直线上有多少点 - R: Find out how many points lay on the straight line per group 如何从大型shapefile计算多边形的面积 - How to calculate area of polygons from a large shapefile R:如何找到重叠数据点且没有缺失数据的最长周期? - R: How to find longest periods with overlapping data points and no missing data? 如何获得点(经纬度)以显示在我的 shapefile map 上? - How do I get points (Lat. & Long.) to show up on my shapefile map? 删除重叠的多边形,点太多 - Removing overlapping polygons, too many points 如何将shapefile与具有纬度/经度数据的数据框合并 - how to merge a shapefile with a dataframe with latitude/longitude data 如何将数据框几何体保存到 R 中的 shapefile - How to save dataframe geometry to a shapefile in R 如何从dataframe中提取基于shapefile的信息? - How to extract information based on shapefile from dataframe? 查找重叠圆内点的坐标 - Find coordinates of points within overlapping circles
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM