Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 叶形投影_Python_Geojson_Folium_Shapely - Fatal编程技术网

Python 叶形投影

Python 叶形投影,python,geojson,folium,shapely,Python,Geojson,Folium,Shapely,我正在使用geojson数据,并试图用h3十六进制网格填充这些多边形。地面轮廓正确,但h3网格被拉伸。我假设我需要变换一些投影,但我不确定在哪里。老实说,我不知道为什么需要这个shapely调用poly=geometry.Polygon(区域['geometry']['coordinates'][0])谢谢 import folium import json from shapely import geometry import h3 gjfile=open('ne_50m_land.geoj

我正在使用geojson数据,并试图用h3十六进制网格填充这些多边形。地面轮廓正确,但h3网格被拉伸。我假设我需要变换一些投影,但我不确定在哪里。老实说,我不知道为什么需要这个shapely调用
poly=geometry.Polygon(区域['geometry']['coordinates'][0])
谢谢

import folium import json from shapely import geometry import h3

gjfile=open('ne_50m_land.geojson', 'r') gjland = json.loads(gjfile.read())

m = folium.Map([51,-102], tiles='stamentoner', zoom_start=5,control_scale=True,max_zoom=20)

style = {'fillColor': '#f5f5f5', 'lineColor': '#ffffbf'}

for area in gjland['features']:
    try:
        poly=geometry.Polygon(area['geometry']['coordinates'][0])
        folium.GeoJson(poly, style_function=lambda x: style).add_to(m)
    except: #ignore this multipolygon for now. one island in northern russia
        continue      

    poly =area
    
    hexagons = list(h3.polyfill(poly['geometry'], 3))
    polylines = []
    
    lat = []
    lng = []
    
    for hex in hexagons:
        p2=h3.h3_to_geo(hex)
    
        polygons = h3.h3_set_to_multi_polygon([hex], geo_json=False)
        # flatten polygons into loops.
        outlines = [loop for polygon in polygons for loop in polygon]
        polyline = [outline + [outline[0]] for outline in outlines][0]
        lat.extend(map(lambda v:v[0],polyline))
        lng.extend(map(lambda v:v[1],polyline))
        polylines.append(polyline)
        
    for polyline in polylines:
        my_PolyLine=folium.PolyLine(locations=polyline,weight=1,color='blue')
        m.add_child(my_PolyLine)

m.save('map.html')