1.数据格式:
GeoJSON、
ESRI控制格式和其他矢量文件格式的优秀工具
字段:
adcode
name
childrenNum
level
parent
subFeatureIndex
geometry: geometry列,可以通过经纬度数据Latitude和Longitude创建该列
Shapely
WKT (Well-Known Text) 是一种用于描述地理位置的数据格式。
WTK格式的数据包含点、线、多边形等地理位置信息
。WTK格式的数据可以被许多GIS软件和地理位置分析工具所读取和处理
数据处理
GeoPandas
GeoPandas的目标是使在python中使用地理空间数据更容易。它结合了Pandas和Shapely的能力
核心是 geopandas.GeoDataFrame geopandas.GeoSeries
生成关于南美城市的dataframe数据
import pandas as pd
import geopandas as gpd
df = pd.DataFrame(
{
"City": ["Buenos Aires", "Brasilia", "Santiago", "Bogota", "Caracas"],
"Country": ["Argentina", "Brazil", "Chile", "Colombia", "Venezuela"],
"Latitude": [-34.58, -15.78, -33.45, 4.60, 10.48],
"Longitude": [-58.66, -47.91, -70.66, -74.08, -66.86],
}
)
gdf = gpd.GeoDataFrame(
df, geometry=gpd.points_from_xy(df.Longitude, df.Latitude), crs="EPSG:4326"
)
数据可视化
分级统计图 Choropleth
scheme="QUANTILES", # 设置分层设色标准
比例尺可以帮助我们了解地图上的距离和大小关系。
基于matplotlib进行可视化时,可以利用matplotlib-scalebar[6]库添加比例尺。
# pip install matplotlib_scalebar安装
from matplotlib_scalebar.scalebar import ScaleBar
参考
https://zhuanlan.zhihu.com/p/554141479
https://geopandas.org/en/stable/
https://blog.csdn.net/qq_40206371/article/details/120464056
Python绘制数据地图-GeoPandas使用要点 https://blog.csdn.net/lemonbit/article/details/131447360