【问题标题】:how to tell if a point is within a certain radius from a polygon using geopandas?如何判断一个点是否在使用 geopandas 的多边形的某个半径内?
【发布时间】:2022-06-11 10:04:24
【问题描述】:

我有两个文件(.shp):第一个包含城市作为多边形,第二个包含公园作为点。我必须找出距城市给定距离内有多少个公园。 我正在考虑使用缓冲区将多边形的区域扩展一定距离,然后遍历多边形并检查该区域中的公园(点)。请问我应该如何进行?

import geopandas as gpd
import matplotlib.pyplot as plt
from shapely.geometry import Polygon, Point

cities_shape = gpd.read_file('geo_cities_f.shp')
parks_shape = gpd.read_file('geo_parks_f.shp')

fig, ax = plt.subplots(figsize=(14,14))
cities_shape.buffer(0.002).plot(ax = ax, color='blue', edgecolor='black')
parks_shape.plot(ax = ax, color='red', edgecolor='black')

cities_shape['geometry'].buffer(0.0004).plot(figsize=(14,14))

**parks(points)**
    SRID    geometry
    0   SRID=4326   POINT (34.79473 32.07580)
    1   SRID=4326   POINT (34.80149 32.12502)
    2   SRID=4326   POINT (34.76660 32.07581)
    3   SRID=4326   POINT (34.78834 32.06583)
    4   SRID=4326   POINT (34.78338 32.06643)

**polygons**
SRID    geometry
0   SRID=4326   POLYGON ((34.80707 32.05355, 34.80704 32.05350...
1   SRID=4326   POLYGON ((34.80707 32.05355, 34.80704 32.05350...
2   SRID=4326   POLYGON ((34.80712 32.05342, 34.80713 32.05341...
3   SRID=4326   POLYGON ((34.80712 32.05342, 34.80713 32.05341...
4   SRID=4326   POLYGON ((34.80712 32.05337, 34.80715 32.05336...

【问题讨论】:

  • 你眼中的成功是什么样的?

标签: python pandas geopandas


猜你喜欢
  • 2017-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-11
  • 2011-04-06
  • 1970-01-01
相关资源
最近更新 更多