扣丁学堂Python培训简述Python中GeoJson和bokeh-1的使用

如今参加Python培训的小伙伴在不断的增加,大家都想要学好Python开发技术成为合格的Python开发工程师,但是想要成为专业的Python开发工程师并不是一件简单的事情,本篇文章小编给读者们分享一下Python技术问题:Python中GeoJson和bokeh-1的使用,对Python开发感兴趣的同学就随小编一起来看一下吧。

扣丁学堂Python培训简述Python中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,

],

"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,

],

"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)

以上就是扣丁学堂Python在线学习小编给大家分享的Python中GeoJson和bokeh-1的使用,希望对小伙伴们有所帮助,想要了解更多内容的小伙伴可以登录扣丁学堂官网咨询。

想要学好Python开发小编给大家推荐口碑良好的扣丁学堂,扣丁学堂有专业老师制定的Python学习路线图辅助学员学习,此外还有与时俱进的Python视频教程供大家学习,想要学好Python开发技术的小伙伴快快行动吧。

相关推荐