Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use pyecharts to draw Geographic scatter Map

Shulou Source: shulou.com Published: 2022-06-01 07:05:20 10月03日 Update

Editor to share with you how to use pyecharts to draw a geographical scatter map, I hope you will gain something after reading this article, let's discuss it together!

1. Background

Make use of the Shanghai 7000+ office building project, including the project name, geographical location, daily rent, building area and the business district where the project is located, now let these projects be located on the map according to longitude and latitude, and show the rent by color, there are many things to do before operating ArcGIS software, this time, ready to try the pyecharts module, directly generate with python script.

two。 Effect picture

The effect picture is roughly as follows:

3. Complete Code import pandas as pd # Import data Analysis Module from pyecharts.charts import Geo # Import Geographic Information processing Module from pyecharts import options as opts # configure from pyecharts.render import make_snapshot # Snapshot from snapshot_selenium import snapshot from pyecharts.globals import ChartType SymbolType # Global configuration data=pd.read_excel ("D:\ gravitational\ Modu Business Circle\ office project .xlsx") # read data geo_sight_coord= {data ['project name'] [I] .strip (): [data ['longitude'] [I], data ['latitude'] [I]] for i in range (len (data))} # construct location dictionary data data_pair= [(data ['project name'] [I] .strip ()) Data ['Daily Rent'] [I]) for i in range (len (data)) # Construction Project Rent data g=Geo () # Geographic initialization g.add_schema (maptype= "Shanghai") # limit Shanghai for key, value in geo_sight_coord.items (): # cycle g.add_coordinate (key, value [0], value [1]) # add location g.add (", data_pair") Symbol_size=2) # append project name and rent g.set_series_opts (label_opts=opts.LabelOpts (is_show=False), type='scatter') # scatter plot scatterpieces = [{'max': 3,' label':'

Tags: Project data rent geography name office Shanghai map format Shanghai module latitude longitude processing code location business district building dictionary effect Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB Shulou Technology NVidia Docker