Нарисуйте клетки S2, используя фолиум

Я пытаюсь охватить регион ячейками 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": "Polygon ", "координаты": [[[51.25717221746951, +29,99451832039972], [51.265801691038455, +30,004725462921563], [51.270012753116234, +29,98978000882574], [51.26138096289235, 29,97957594186747], [51.25717221746951, 29,99451832039972]]]}, "BBOX": [51,25717221746951, +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

0 ответов

Другие вопросы по тегам