首先根据UTM对应表找到目标地区的编号,中国东部地区属于UTM Zone 50N
再查找UTM 50N 的EPSG标准
https://epsg.io/?q=UTM+zone+50N
得到 EPSG:32650
import transbigdata as tbd
import pandas as pd
import geopandas as gpd
#读取数据
data = pd.read_csv('TaxiData-Sample.csv',header = None)
data.columns = ['VehicleNum','time','slon','slat','OpenStatus','Speed']
#依据经纬度geohash编码,精确度选6时,栅格大小约为±0.61km
data['geohash'] = tbd.geohash_encode(data['slon'],data['slat'],precision=6)
#基于geohash编码集计
dataagg = data.groupby(['geohash'])['VehicleNum'].count().reset_index()
#geohash编码解码为经纬度
dataagg['lon_geohash'],dataagg['lat_geohash'] = tbd.geohash_decode(dataagg['geohash'])
#geohash编码生成栅格矢量图形
dataagg['geometry'] = tbd.geohash_togrid(dataagg['geohash'])
#转换为GeoDataFrame
dataagg = gpd.GeoDataFrame(dataagg)
Python实现geohash编码与解码(TransBigData)
国内的可以很方便的利用百度或者高德提供的api解决,国外的地址就需要用谷歌地图或者必应地图的api解决了。
### 通过地址获取经纬度。
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="specify_your_app_name_here")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)
#Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ...
print((location.latitude, location.longitude))
#(40.7410861, -73.9896297241625)
print(location.raw)
#{'place_id': '9167009604', 'type': 'attraction', ...}