Basics of geographic data visualization

1. Method of obtaining shp file

method one

Refer to this blog post:
Get the outline shp files of provinces, cities and counties

Method Two

Refer to the following blog posts and
use OpenStreetMap to obtain urban road network data
. How to convert OSM road network data (xml or json format) to shapefile format is
summarized as follows:
1. First search for the city name on the openstreetmap official website to get the city ID, open source website The official website of Openstreetmap is: https://www.openstreetmap.org/relation/3020001
Insert picture description here

2. Obtained via OverpassAPI, the URL is: API
Insert picture description here
select Query and Convert Forms, enter in the input box:

<osm-script timeout="1800" element-limit="100000000">
  <union>
    <area-query ref="3603020001"/>
    <recurse type="node-relation" into="rels"/>
    <recurse type="node-way"/>
    <recurse type="way-relation"/>
  </union>
  <union>
    <item/>
    <recurse type="way-node"/>
  </union>
  <print mode="body"/>
</osm-script>

Among them, the value of ref is 3600000000 + the ID number obtained in the previous step.
Click Query.
3. Visit the Geoconverter website.
Put the interpreter downloaded in the previous step into the converted file and select the output format as shp file.

2. Use OpenStreetMap to obtain city POI (points of interest) data

Need to use pandana library (Pandana has some support for creating a Network from the OpenStreetMap API), pandana's official instructions

#导入需要的库
import pandana, matplotlib.pyplot as plt
from pandana.loaders import osm
%matplotlib inline
import pandas as pd
import pandana as pdna
#利用OSM的api获取指定区域内的POI信息
# bbox = [30.66, 120.85,31.89, 122.20] #上海的经纬度范围
# amenity = 'school' #兴趣点种类
# pois = osm.node_query(bbox[0], bbox[1], bbox[2], bbox[3], tags='"amenity"="{}"'.format(amenity))
# pois.to_csv("{}.csv".format(amenity),index=False, encoding='utf-8')
# 根据给定的经纬度范围利用OSM下载区域内路网
bbox = [30.66, 120.85,31.89, 122.20] #上海的经纬度范围
network_filename='./shapefile/shanghai_net.h5'#保存路网文件路径
network = osm.network_from_bbox(bbox[0], bbox[1], bbox[2], bbox[3])
network=pandana.Network(network[0]["x"],network[0]["y"], network[1]["from"], network[1]["to"],
                 network[1][["distance"]])

Guess you like

Origin blog.csdn.net/qq_39805362/article/details/109317844