Python中GeoJson和bokeh-1的使用講解
更新時間:2019年01月03日 10:22:05 作者:staHuri
今天小編就為大家分享一篇關(guān)于Python中GeoJson和bokeh-1的使用講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

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": "右側(cè)正方形",
"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": "左側(cè)正方形",
"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)
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接
相關(guān)文章
Python統(tǒng)計日志中每個IP出現(xiàn)次數(shù)的方法
這篇文章主要介紹了Python統(tǒng)計日志中每個IP出現(xiàn)次數(shù)的方法,實例分析了Python基于正則表達(dá)式解析日志文件的相關(guān)技巧,需要的朋友可以參考下2015-07-07
python中subprocess批量執(zhí)行l(wèi)inux命令
本篇文章給大家詳細(xì)講述了python中使用subprocess批量執(zhí)行l(wèi)inux命令的方法,有興趣的朋友參考學(xué)習(xí)下。2018-04-04

