当前位置:   article > 正文

python地图可视化应用场景,python地图可视化缩放_python 地图

python 地图

大家好,小编来为大家解答以下问题,python地图可视化分析情绪占比,python地图可视化各种店铺分布,现在让我们一起来看看吧!

大家好,我是欧K。

本期给大家介绍一下如何使用Python制作炫酷的3D可视化地图,包括全国地图、省级地图以及市级地图,希望对你有所帮助python如何画九朵花

在这里插入图片描述

1. 环境安装

1.1 安装 pyecharts
  1. # 方法一 直接安装
  2. pip install pyecharts
  3. # 方法二 清华镜像安装
  4. pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ pyecharts
1.2 安装地图扩展包
  1. pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-countries-pypkg # 全球国家地图
  2. pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-china-provinces-pypkg # 中国省级地图
  3. pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-china-cities-pypkg # 中国市级地图
  4. pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-china-counties-pypkg # 中国县区级地图

2. 广东省3D地图

  1. 代码:
  2. from pyecharts import options as opts
  3. from pyecharts.charts import Map3D
  4. from pyecharts.globals import ChartType
  5. example_data = [
  6. [[119.107078, 36.70925, 1000], [116.587245, 35.415393, 1000]],
  7. [[117.000923, 36.675807], [120.355173, 36.082982]],
  8. [[118.047648, 36.814939], [118.66471, 37.434564]],
  9. [[121.391382, 37.539297], [119.107078, 36.70925]],
  10. [[116.587245, 35.415393], [122.116394, 37.509691]],
  11. [[119.461208, 35.428588], [118.326443, 35.065282]],
  12. [[116.307428, 37.453968], [115.469381, 35.246531]],
  13. ]
  14. c = (
  15. Map3D()
  16. .add_schema(
  17. maptype="广东",
  18. itemstyle_opts=opts.ItemStyleOpts(
  19. color="rgb(5,101,123)",
  20. opacity=1,
  21. border_width=0.8,
  22. border_color="rgb(62,215,213)",
  23. ),
  24. light_opts=opts.Map3DLightOpts(
  25. main_color="#fff",
  26. main_intensity=1.2,
  27. is_main_shadow=False,
  28. main_alpha=55,
  29. main_beta=10,
  30. ambient_intensity=0.3,
  31. ),
  32. view_control_opts=opts.Map3DViewControlOpts(center=[-10, 0, 10]),
  33. post_effect_opts=opts.Map3DPostEffectOpts(is_enable=False),
  34. )
  35. .add(
  36. series_name="",
  37. data_pair=example_data,
  38. type_=ChartType.LINES3D,
  39. effect=opts.Lines3DEffectOpts(
  40. is_show=True,
  41. period=4,
  42. trail_width=3,
  43. trail_length=0.5,
  44. trail_color="#f00",
  45. trail_opacity=1,
  46. ),
  47. linestyle_opts=opts.LineStyleOpts(is_show=False, color="#fff", opacity=0),
  48. )
  49. .set_global_opts(title_opts=opts.TitleOpts(title="Map3D-Lines3D"))
  50. .render("map3d_with_lines3d.html")
  51. )

示例:

在这里插入图片描述

3. 北京市3D地图

示例:

在这里插入图片描述

将广东省地图中的“maptype参数设置为"北京",即可制作北京市3D地图,感兴趣的小伙伴也可以尝试制作其他省市的3D地图。

4. 中国3D地图-行政区

代码:

  1. from pyecharts import options as opts
  2. from pyecharts.charts import Map3D
  3. from pyecharts.globals import ChartType
  4. c = (
  5. Map3D()
  6. .add_schema(
  7. itemstyle_opts=opts.ItemStyleOpts(
  8. color="rgb(5,101,123)",
  9. opacity=1,
  10. border_width=0.8,
  11. border_color="rgb(62,215,213)",
  12. ),
  13. map3d_label=opts.Map3DLabelOpts(
  14. is_show=True,
  15. text_style=opts.TextStyleOpts(
  16. color="#fff", font_size=16, background_color="rgba(0,0,0,0)"
  17. ),
  18. ),
  19. emphasis_label_opts=opts.LabelOpts(is_show=True),
  20. light_opts=opts.Map3DLightOpts(
  21. main_color="#fff",
  22. main_intensity=1.2,
  23. is_main_shadow=False,
  24. main_alpha=55,
  25. main_beta=10,
  26. ambient_intensity=0.3,
  27. ),
  28. )
  29. .add(series_name="", data_pair="", maptype=ChartType.MAP3D)
  30. .set_global_opts(
  31. title_opts=opts.TitleOpts(title="中国3D地图-1"),
  32. visualmap_opts=opts.VisualMapOpts(is_show=False),
  33. tooltip_opts=opts.TooltipOpts(is_show=True),
  34. )
  35. .render("中国3D地图-1.html")
  36. )

示例:
在这里插入图片描述

5. 中国3D地图-数据可视化

代码:

  1. from pyecharts import options as opts
  2. from pyecharts.charts import Map3D
  3. from pyecharts.globals import ChartType
  4. from pyecharts.commons.utils import JsCode
  5. example_data = [
  6. ("黑龙江", [127.9688, 45.368, 100]),
  7. ("内蒙古", [110.3467, 41.4899, 300]),
  8. ("吉林", [125.8154, 44.2584, 300]),
  9. ("辽宁", [123.1238, 42.1216, 300]),
  10. ("河北", [114.4995, 38.1006, 300]),
  11. ("天津", [117.4219, 39.4189, 300]),
  12. ("山西", [112.3352, 37.9413, 300]),
  13. ("陕西", [109.1162, 34.2004, 300]),
  14. ("甘肃", [103.5901, 36.3043, 300]),
  15. ("宁夏", [106.3586, 38.1775, 300]),
  16. ("青海", [101.4038, 36.8207, 300]),
  17. ("新疆", [87.9236, 43.5883, 300]),
  18. ("西藏", [91.11, 29.97, 300]),
  19. ("四川", [103.9526, 30.7617, 300]),
  20. ("重庆", [108.384366, 30.439702, 300]),
  21. ("山东", [117.1582, 36.8701, 300]),
  22. ("河南", [113.4668, 34.6234, 300]),
  23. ("江苏", [118.8062, 31.9208, 300]),
  24. ("安徽", [117.29, 32.0581, 300]),
  25. ("湖北", [114.3896, 30.6628, 300]),
  26. ("浙江", [119.5313, 29.8773, 300]),
  27. ("福建", [119.4543, 25.9222, 300]),
  28. ("江西", [116.0046, 28.6633, 300]),
  29. ("湖南", [113.0823, 28.2568, 300]),
  30. ("贵州", [106.6992, 26.7682, 300]),
  31. ("广西", [108.479, 23.1152, 300]),
  32. ("海南", [110.3893, 19.8516, 300]),
  33. ("上海", [121.4648, 31.2891, 1300]),
  34. ]
  35. c = (
  36. Map3D()
  37. .add_schema(
  38. itemstyle_opts=opts.ItemStyleOpts(
  39. color="rgb(5,101,123)",
  40. opacity=1,
  41. border_width=0.8,
  42. border_color="rgb(62,215,213)",
  43. ),
  44. map3d_label=opts.Map3DLabelOpts(
  45. is_show=False,
  46. formatter=JsCode("function(data){return data.name + " " + data.value[2];}"),
  47. ),
  48. emphasis_label_opts=opts.LabelOpts(
  49. is_show=False,
  50. color="#fff",
  51. font_size=10,
  52. background_color="rgba(0,23,11,0)",
  53. ),
  54. light_opts=opts.Map3DLightOpts(
  55. main_color="#fff",
  56. main_intensity=1.2,
  57. main_shadow_quality="high",
  58. is_main_shadow=False,
  59. main_beta=10,
  60. ambient_intensity=0.3,
  61. ),
  62. )
  63. .add(
  64. series_name="bar3D",
  65. data_pair=example_data,
  66. type_=ChartType.BAR3D,
  67. bar_size=1,
  68. shading="lambert",
  69. label_opts=opts.LabelOpts(
  70. is_show=False,
  71. formatter=JsCode("function(data){return data.name + ' ' + data.value[2];}"),
  72. ),
  73. )
  74. .set_global_opts(title_opts=opts.TitleOpts(title="Map3D-Bar3D"))
  75. .render("map3d_with_bar3d.html")
  76. )

示例:
在这里插入图片描述

往期推荐

技巧 | Python 字典用法详解(超全)
技巧 | Python 列表经典使用技巧
技巧 | 20个Pycharm最实用最高效的快捷键(动态展示)
可视化 | 动起来的中国大学排名,看看你的母校在哪里
可视化 | Python时间序列化NBA球星赛季数据

以上就是本期为大家整理的全部内容了,赶快练习起来吧,喜欢的朋友可以点赞、收藏也可以分享到朋友圈让更多人知道哦

微信公众号 “Python当打之年” ,每天都有python编程技巧推送,希望大家可以喜欢
在这里插入图片描述

文章知识点与官方知识档案匹配,可进一步学习相关知识
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/975679
推荐阅读
相关标签
  

闽ICP备14008679号