我想画一个有点的geojson圆。。。但它不会合并到其中的几何体部分

2024-04-27 01:10:15 发布

您现在位置:Python中文网/ 问答频道 /正文

geo_json = [ 
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [lon, lat] 
        },
        "properties": {}
    }
]

我希望圆坐标的格式与上述代码的格式相同

import geojson
import shapely
from shapely.geometry import Point

center = Point(lat,long) 
circle = center.buffer(0.3)  
poly = geojson.dumps(shapely.geometry.mapping(circle))

feature_col = FeatureCollection([geo_json,circle])
print(poly)

但我不可能对圆形多边形这样做。有没有其他方法可以让我们做同样的事情


Tags: importjsongeojson格式typefeaturepointgeo
1条回答
网友
1楼 · 发布于 2024-04-27 01:10:15

如果我理解正确:

import shapely, geojson
lat = long = 0
center = shapely.geometry.Point([lat, long])
poly = list(center.buffer(0.3).exterior.coords)
json_points = [geojson.Feature(geometry=shapely.geometry.Point(p)) for p in poly_points]
json_points = geojson.FeatureCollection(json_points)

由于shapely.geometry.Point和geojson.Point都存在,因此我将避免将它们作为简单的“点”导入,即使这需要一些繁琐的调用

相关问题 更多 >