cyang-kth / fmm

Fast map matching, an open source framework in C++
https://fmm-wiki.github.io/
Apache License 2.0
892 stars 215 forks source link

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

Closed xingminw closed 3 years ago

xingminw commented 3 years ago

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 commented 3 years ago

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

cyang-kth commented 3 years ago

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

from fmm import GPSConfig,ResultConfig
input_config = GPSConfig()
input_config.file = "../data/gps.csv"
input_config.id = "id"
input_config.gps_point = true
xingminw commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Please check the issue https://github.com/cyang-kth/fmm/issues/138#issue-735143262 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 commented 3 years ago

Thanks for your reply.