首页 > 解决方案 > 使用 Geopandas 返回多边形上的数据点

问题描述

我正在尝试获取纽约市每个行政区的出行次数,我正在使用 NYC Taxi Fare 数据集,并且已检索到 1'500,000 个数据点。问题是该程序非常缓慢,是否有其他程序来计算这些值,计算每个行政区的旅行次数。谢谢您,我将不胜感激任何评论或想法。

块引用

count=0
results=[]
for index_boro, row_boro in boroughs_gpd.iterrows():
  count=0
  print(row_boro.boro_name)
  geom_boro = row_boro.geometry
  for index_points, row_points in gdf.iterrows():
    if (row_points.geometry.within(geom_boro)):
      count=count+1
  results.append((row_boro.boro_code,count))
  break
a = tuple(results)   
a

标签: data-sciencegeospatialdata-miningspatialgeopandas

解决方案


推荐阅读