【发布时间】: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...
【问题讨论】:
-
你眼中的成功是什么样的?