Skip to content

Commit 7facf60

Browse files
committed
added geoutils
1 parent bacf351 commit 7facf60

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

pymove/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
from .utils import (
2020
constants,
2121
conversions,
22+
data_augmentation,
2223
datetime,
2324
distances,
25+
geoutils,
2426
integration,
27+
log,
2528
math,
2629
mem,
2730
trajectories,

pymove/utils/geoutils.py

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -322,22 +322,21 @@ def create_geohash_df(data: DataFrame, precision: Optional[float] = 15):
322322
-------
323323
>>> from pymove.utils.geoutils import create_geohash_df, _reset_and_create_arrays_none
324324
>>> geoLife_df
325-
lat lon
326-
0 39.984094 116.319236
327-
1 39.984198 116.319322
328-
2 39.984224 116.319402
329-
3 39.984211 116.319389
330-
4 39.984217 116.319422
325+
lat lon
326+
0 39.984094 116.319236
327+
1 39.984198 116.319322
328+
2 39.984224 116.319402
329+
3 39.984211 116.319389
330+
4 39.984217 116.319422
331331
>>> print(type (create_geohash_df(geoLife_df)))
332332
>>> geoLife_df
333333
<class 'NoneType'>
334-
335-
lat lon geohash
336-
0 39.984094 116.319236 wx4eqyvh4xkg0xs
337-
1 39.984198 116.319322 wx4eqyvhudszsev
338-
2 39.984224 116.319402 wx4eqyvhyx8d9wc
339-
3 39.984211 116.319389 wx4eqyvhyjnv5m7
340-
4 39.984217 116.319422 wx4eqyvhyyr2yy8
334+
lat lon geohash
335+
0 39.984094 116.319236 wx4eqyvh4xkg0xs
336+
1 39.984198 116.319322 wx4eqyvhudszsev
337+
2 39.984224 116.319402 wx4eqyvhyx8d9wc
338+
3 39.984211 116.319389 wx4eqyvhyjnv5m7
339+
4 39.984217 116.319422 wx4eqyvhyyr2yy8
341340
"""
342341
_, _, geohash, _ = _reset_and_create_arrays_none(data)
343342

@@ -368,21 +367,21 @@ def create_bin_geohash_df(data: DataFrame, precision: Optional[float] = 15):
368367
-------
369368
>>> from pymove.utils.geoutils import create_bin_geohash_df
370369
>>> geoLife_df
371-
lat lon
372-
0 39.984094 116.319236
373-
1 39.984198 116.319322
374-
2 39.984224 116.319402
375-
3 39.984211 116.319389
376-
4 39.984217 116.319422
370+
lat lon
371+
0 39.984094 116.319236
372+
1 39.984198 116.319322
373+
2 39.984224 116.319402
374+
3 39.984211 116.319389
375+
4 39.984217 116.319422
377376
>>> print(type(create_bin_geohash_df(geoLife_df)))
378377
>>> geoLife_df
379378
<class 'NoneType'>
380-
lat lon bin_geohash
381-
0 39.984094 116.319236 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
382-
1 39.984198 116.319322 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
383-
2 39.984224 116.319402 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
384-
3 39.984211 116.319389 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
385-
4 39.984217 116.319422 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
379+
lat lon bin_geohash
380+
0 39.984094 116.319236 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
381+
1 39.984198 116.319322 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
382+
2 39.984224 116.319402 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
383+
3 39.984211 116.319389 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
384+
4 39.984217 116.319422 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, ...
386385
"""
387386
_, _, _, bin_geohash = _reset_and_create_arrays_none(data)
388387

@@ -419,21 +418,21 @@ def decode_geohash_to_latlon(
419418
-------
420419
>>> from pymove.utils.geoutils import decode_geohash_to_latlon
421420
>>> geoLife_df
422-
lat lon geohash
423-
0 39.984094 116.319236 wx4eqyvh4xkg0xs
424-
1 39.984198 116.319322 wx4eqyvhudszsev
425-
2 39.984224 116.319402 wx4eqyvhyx8d9wc
426-
3 39.984211 116.319389 wx4eqyvhyjnv5m7
427-
4 39.984217 116.319422 wx4eqyvhyyr2yy8
421+
lat lon geohash
422+
0 39.984094 116.319236 wx4eqyvh4xkg0xs
423+
1 39.984198 116.319322 wx4eqyvhudszsev
424+
2 39.984224 116.319402 wx4eqyvhyx8d9wc
425+
3 39.984211 116.319389 wx4eqyvhyjnv5m7
426+
4 39.984217 116.319422 wx4eqyvhyyr2yy8
428427
>>> print(type(decode_geohash_to_latlon(geoLife_df)))
429428
>>> geoLife_df
430429
<class 'NoneType'>
431-
lat lon geohash lat_decode lon_decode
432-
0 39.984094 116.319236 wx4eqyvh4xkg0xs 39.984094 116.319236
433-
1 39.984198 116.319322 wx4eqyvhudszsev 39.984198 116.319322
434-
2 39.984224 116.319402 wx4eqyvhyx8d9wc 39.984224 116.319402
435-
3 39.984211 116.319389 wx4eqyvhyjnv5m7 39.984211 116.319389
436-
4 39.984217 116.319422 wx4eqyvhyyr2yy8 39.984217 116.319422
430+
lat lon geohash lat_decode lon_decode
431+
0 39.984094 116.319236 wx4eqyvh4xkg0xs 39.984094 116.319236
432+
1 39.984198 116.319322 wx4eqyvhudszsev 39.984198 116.319322
433+
2 39.984224 116.319402 wx4eqyvhyx8d9wc 39.984224 116.319402
434+
3 39.984211 116.319389 wx4eqyvhyjnv5m7 39.984211 116.319389
435+
4 39.984217 116.319422 wx4eqyvhyyr2yy8 39.984217 116.319422
437436
"""
438437
if label_geohash not in data:
439438
raise ValueError('feature {} not in df'.format(label_geohash))

0 commit comments

Comments
 (0)