我正在尝试用Google s2细胞覆盖区域,并使用大叶草在地图上显示它们:
1)覆盖区域
def return_polygons(covering):
geoms = []
for cellid in covering:
new_cell = Cell(cellid)
vertices = []
for i in range(0, 4):
vertex = new_cell.get_vertex(i)
latlng = LatLng.from_point(vertex)
vertices = vertices + [[latlng.lat().degrees, latlng.lng().degrees]]
geo = Polygon(vertices)
geoms.append(geo)
return geoms
polygons = return_polygons(covering)
2)接收:
geopandas.GeoSeries(polygons[0]).to_json()
'{“ type”:“ FeatureCollection”,“ features”:[{“ id”:“ 0”,“ type”:“ Feature”,“ properties”:{},“ geometry”:{“ type” :“多边形”,“坐标”:[[[51.25717221746951、29.99451832039972],[51.265801691038455、30.004725462921563],[51.270012753116234、29.98978000882574],[51.26138096289235、29.97957594186747],[51.25717221746951] [box] ,29.97957594186747,51.270012753116234,30.004725462921563]}],“ bbox”:[51.25717221746951,29.97957594186747,51.270012753116234,30.004725462921563]}'
3)在地图上显示它,但不显示任何内容:
m = folium.Map([55.75, 37.61], zoom_start=10)
style_function = lambda x: {'weight': 1, 'fillColor':'#eea500'}
folium.GeoJson(geopandas.GeoSeries(polygons[0]).to_json(),
style_function=style_function).add_to(m)
folium.LayerControl().add_to(m)
m