1 area_to_grid
在边界或形状中生成矩形栅格
1.1 主要使用方法
transbigdata.area_to_grid(
location,
accuracy=500,
method='rect',
params='auto')
1.2 主要参数
location | (bounds(List) or shape(GeoDataFrame) 生成栅格的位置。
|
accuracy | 栅格尺寸(米) |
method | 直角、三角或六角( rect, tri or hexa) |
1.3 返回内容
grid (GeoDataFrame) | LONCOL 和 LATCOL 是栅格的索引,geometry是各栅格的中心 |
params | 栅格参数 |
1.3.1 举例(rect)
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}
'''
1.3.2 举例(tri)
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))
2 area_to_params
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}
'''
3 GPS_to_grid
将 GPS 数据与栅格匹配
transbigdata.GPS_to_grid(lon, lat, params)
3.1 主要参数
lon | 经度栏 |
lat | 纬度栏 |
params | 2 area_to_params返回的内容 |
3.2 返回内容
-
矩形栅格
-
[LONCOL,LATCOL] (list) – 两列 LONCOL 和 LATCOL 一起可以指定栅格。
-
-
三角形和六边形栅格
-
[loncol_1,loncol_2,loncol_3] (list) – 栅格纬度的索引。两列 LONCOL 和 LATCOL 一起可以指定一个栅格。
-
【这里是不是loncol_3就是LATCOL啊?】
-
3.3 举例
比如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])]
'''
4 grid_to_polygon
transbigdata.grid_to_polygon(gridid, params)
gridid |
|
params | 2 area_to_params返回的内容 |
比如dataset是
params是
params
'''
{'slon': 113.6,
'slat': 22.4,
'deltalon': 0.004872390756896538,
'deltalat': 0.004496605206422906,
'theta': 0,
'method': 'rect',
'gridsize': 500}
'''
那么我们调用grid_to_polygon,有:
dataset['geometry'] = tbd.grid_to_polygon([dataset['LONCOL'], dataset['LATCOL']], params)
dataset