地理信息可视化

参考文献:https://www.jianshu.com/p/d78fff321005

数据存储格式:WKT VS GeoJSON

WKT是什么?

WKT(well-know text)是开放地理空间联盟OGC制定的一种文本标记语言,用于表示矢量几何对象、空间参照系统及空间参照系统之间的转换。

WKB是什么?

WKB(well-know binary)是WKT的二进制表现形式,解决WKT表达冗余的问题,便于传输和存储在数据库中。

GeoJSON是什么?

以JSON的格式输出空间数据,便于被javascript等脚本调用。

WKT与GeoJSON

  • WKT与GeoJSON分为点、线、面、几何集合四种:
线 组合
Point MultiPoint LineString MultiLineString Polygon MultiPolygon GeometryCollection
类型 WKT GeoJSON
Point POINT(10 10) { “type”: “Point”, “coordinates”: [10, 10] }
LineString LINESTRING(10 10, 20 30) { “type”: “Point”, “coordinates”:[ [10, 10], [20, 30] ] }
Polygon POLYGON(10 10, 15 16, 22 10, 30 32) { “type”: “Polygon”, “coordinates”: [ [ [10, 10], [10, 10], [10, 10], [10, 10] ] ] }
MultiPoint MULTIPOINT(*) { “type”: “MultiPoint”, “coordinates”: [*] }
MultiLineString MULTILINESTRING (*) { “type”: “MultiLineString”, “coordinates”: [*] }
MultiPolygon MULTIPOLYGON (*) { “type”: “MultiPolygon”, “coordinates”: [*] }
GEOMETRYCOLLECTION GEOMETRYCOLLECTION(POINT(2 3),LINESTRING(2 3,3 4)) -
  • WKT与GeoJSON的区别 WKT是用来单独表示空间点、线、面数据,GeoJSON还可以用来表示空间数据和属性数据的集合 (crs、bbox属性)。

使用GeoPandas 读取 wkt字符串数据

获取山东省地图土地轮廓并使用GeoPandas加载展示

  • 通过百度地图api获取数据信息
  • 将形状字符串转换为MultiPolygon类型数据
  • 通过GeoPandas加载数据
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# encoding:utf-8
# 根据您选择的AK已为您生成调用代码
# 检测到您当前的AK设置了IP白名单校验
# 您的IP白名单中的IP非公网IP,请设置为公网IP,否则将请求失败
# 请在IP地址为0.0.0.0/0 外网IP的计算发起请求,否则将请求失败
import requests 
sds =None
# 服务地址
host = "https://api.map.baidu.com"
# 接口地址
uri = "/api_region_search/v1/"

# 此处填写你在控制台-应用管理-创建应用后获取的AK
ak = ""

params = {
    "keyword":    "山东省",
    "sub_admin":    "0",
    "ak":       ak,
    "extensions_code":1,
    "boundary":1,
}

response = requests.get(url = host + uri, params = params)
sds =None
if response:
    # print(response.json())
    sds = response.json()
    print(sds['districts'])
# pd.DataFrame(sds['districts'])
使用 Hugo 构建
主题 StackJimmy 设计