Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About LineString format and example loading GPS points in python api #164

Closed
xingminw opened this issue Jan 14, 2021 · 6 comments
Closed

Comments

@xingminw
Copy link

I am trying to use the Python API to match the trajectory in GPS coordinates (with time step). However, I am not that familiar with the LineString input. Almost all the examples provided in python API use the LineString as the input but I do not know how to convert the GPS coordinates to this format.

Therefore, I am wondering how can I convert the GPS coordinates to the LineString wkt format.
Also in the wiki, it is stated that loading the GPS points in csv file is supported. Could the author please provide an example matching the trajectory data in the format of GPS coordinates or give me some hints on how can I convert the GPS coordinates to the LineString format?

Thank you!

@xingminw
Copy link
Author

I have tried using shapely to covert a geojson LineString object to the wkt format but unfortunately, this does not work.

@cyang-kth
Copy link
Owner

You can check this link for example

https://github.com/cyang-kth/fmm/blob/master/example/notebook/fmm_example.ipynb

For GPS CSV you can do

  • convert GPS point to WKT trajectory in Python
  • Supply input directly as fmm input in GPS format
from fmm import GPSConfig,ResultConfig
input_config = GPSConfig()
input_config.file = "../data/gps.csv"
input_config.id = "id"
input_config.gps_point = true

@xingminw
Copy link
Author

Thanks for your reply. I have run through the code successfully according to your instruction. This is what I get for the output status:

Status: success
Time takes 0.002 seconds
Total points 8 matched 8
Total trajectories 1 matched 1
Map match percentage 1
Map match speed 4000 points/s 

However, when I look into the output file, all the opath and cpath are 0. I am not sure whether I get the correct results. I am also wondering when I use OSM data, how can I convert the opath or cpath id to get the OSM way id. I can open another issue to ask this question if necessary.

@xingminw
Copy link
Author

When I convert my input shapefile (obtained from osmnx) to geojson, I found almost all the "key" value are 0. I am wondering how can I somehow set the key the same as the osmid when I output the shapefile from osmnx. I guess this will fix my problem.

image

Thanks for your patience and help.

@cyang-kth
Copy link
Owner

cyang-kth commented Jan 15, 2021

Please check the issue #138 (comment) for summary of common problems.

You need to refer to this https://github.com/cyang-kth/osm_mapmatching for downloading road network. The one downloaded from osmnx does not have the ID field (osmid could be a tuple and it should not be used as ID).
This tutorial will save OSMNX network into a format compatible with fmm.

@xingminw
Copy link
Author

Thanks for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants