您好,登錄后才能下訂單哦!
本篇文章為大家展示了GeoJson和bokeh-1怎么在Python中使用,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
GeoJson 文檔
{ "type": "FeatureCollection", "features": [ { "geometry": { "type": "Polygon", "coordinates": [ [ [ 3, 1 ], [ 3, 2 ], [ 4, 2 ], [ 4, 1 ], [ 3, 1 ] ] ] }, "type": "Feature", "properties": { "perimeter": 0, "vista": "mim", "provincia": "右側正方形", "objectid": 24, "prov": 0, "bounds": [ 0, 0 ], "provif3_": 27.0, "ogc_fid": 26, "provif3_id": 26.0 } }, { "geometry": { "type": "Polygon", "coordinates": [ [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ], [ 1, 1 ] ] ] }, "type": "Feature", "properties": { "perimeter": 0, "vista": "mim", "provincia": "左側正方形", "objectid": 24, "prov": 0, "bounds": [ 0, 0 ], "provif3_": 27.0, "ogc_fid": 26, "provif3_id": 26.0 } } ] }
from bokeh.io import show, output_notebook, output_file from bokeh.models import ( GeoJSONDataSource, HoverTool, LinearColorMapper ) from bokeh.plotting import figure from bokeh.palettes import Viridis6 with open(r'argentina.json', 'r', encoding='utf8') as f: geo_source = GeoJSONDataSource(geojson=f.read()) color_mapper = LinearColorMapper(palette=Viridis6) TOOLS = "pan,wheel_zoom,box_zoom,reset,hover,save" p = figure(title="正方形", tools=TOOLS, x_range=[1, 10], y_range=[1, 10], width=500, height=500) p.grid.grid_line_color = None p.patches('xs', 'ys', fill_alpha=0.7, fill_color={'field': 'objectid', 'transform': color_mapper}, line_color='white', line_width=0.5, source=geo_source) hover = p.select_one(HoverTool) hover.point_policy = "follow_mouse" hover.tooltips = [("Provincia:", "@provincia")] output_file("test.html", title="Testing Polygon in bokeh") show(p)
上述內容就是GeoJson和bokeh-1怎么在Python中使用,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。