在边界或形状中生成矩形栅格
transbigdata.area_to_grid(
location,
accuracy=500,
method='rect',
params='auto')
location | (bounds(List) or shape(GeoDataFrame) 生成栅格的位置。
|
accuracy | 栅格尺寸(米) |
method | 直角、三角或六角( rect, tri or hexa) |
grid (GeoDataFrame) | LONCOL 和 LATCOL 是栅格的索引,geometry是各栅格的中心 |
params | 栅格参数 |
import transbigdata as tbd
bounds = [113.6, 22.4, 114.8, 22.9]
res=tbd.area_to_grid(bounds, accuracy=500)
res[0]
res[1]
'''
{'slon': 113.6,
'slat': 22.4,
'deltalon': 0.004872390756896538,
'deltalat': 0.004496605206422906,
'theta': 0,
'method': 'rect',
'gridsize': 500}
'''
import transbigdata as tbd
bounds = [113.6, 22.4, 114.8, 22.9]
res=tbd.area_to_grid(bounds, accuracy=5000,method='tri')
res[0]
res[1]
'''
{'slon': 113.6,
'slat': 22.4,
'deltalon': 0.048723907568965386,
'deltalat': 0.044966052064229066,
'theta': 0,
'method': 'tri',
'gridsize': 5000}
'''
res[0].plot(figsize=(15,8))
transbigdata.area_to_params(
location,
accuracy=500,
method='rect')
和area_to_grids参数一样,用法上就是返回area_to_grids返回的第二个元素
bounds = [113.6, 22.4, 114.8, 22.9]
res=tbd.area_to_params(bounds, accuracy=500)
res
'''
{'slon': 113.6,
'slat': 22.4,
'deltalon': 0.004872390756896538,
'deltalat': 0.004496605206422906,
'theta': 0,
'method': 'rect',
'gridsize': 500}
'''
将 GPS 数据与栅格匹配
transbigdata.GPS_to_grid(lon, lat, params)
lon | 经度栏 |
lat | 纬度栏 |
params | 2 area_to_params返回的内容 |
矩形栅格
[LONCOL,LATCOL] (list) – 两列 LONCOL 和 LATCOL 一起可以指定栅格。
三角形和六边形栅格
[loncol_1,loncol_2,loncol_3] (list) – 栅格纬度的索引。两列 LONCOL 和 LATCOL 一起可以指定一个栅格。
【这里是不是loncol_3就是LATCOL啊?】
比如data是这样的内容:
transbigdata 笔记:官方文档案例1(出租车GPS数据处理)-CSDN博客 中清楚异常出租车记录后
data=tbd.clean_taxi_status(data)
data
params1=tbd.area_to_params([113.6, 22.4, 114.8, 22.9],accuracy=500)
params1
'''
{'slon': 113.6,
'slat': 22.4,
'deltalon': 0.004872390756896538,
'deltalat': 0.004496605206422906,
'theta': 0,
'method': 'rect',
'gridsize': 500}
'''
tbd.GPS_to_grid(data['Lng'],data['Lat'],params)
'''
[array([51, 51, 51, ..., 77, 77, 77]), array([65, 66, 66, ..., 32, 32, 32])]
'''