-
Notifications
You must be signed in to change notification settings - Fork 189
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
GeoDataFrame to MF-JSON #325
Conversation
Some tests would be needed, but I prefer to wait for your opinions concerning which data I should use as a comparison for these tests. |
Mind sending some links to MF JSON? I'm curious what it is, why you would use it and what problems it solves. I'm mostly curious as I'm not familiar. I don't see any reason why this shouldn't go in. Thanks for the PR |
Here is the description of the standard on the Open Geospatial Consortium website: https://docs.ogc.org/is/19-045r3/19-045r3.html It is a relatively new standard which provides a unified approach to storing and transmitting data using an extended version of GeoJSON. This is quite useful in the case of having to distribute trajectories to users in a quickly usable format. In fact, this package movingpandas already has a decoder (which appears to be a work in progress). This is described in this blog: https://anitagraser.com/2022/04/16/new-ogc-moving-features-json-support-in-movingpandas/ This means that with this additional GDF to MF-JSON encoder, the package will be able to encode/decode MF-JSON/GDF without much friction. |
Thank you for this excellent contribution. For Tests, it would be good to use some of the official samples. I think this may be the most up to date repo: https://github.com/opengeospatial/mf-json |
I added a test which first loads the file already present in the test folder, and which then encodes it using the method proposed in this PR. I then verify that both the encoded and original json file are equivalent. |
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #325 +/- ##
==========================================
- Coverage 95.53% 95.44% -0.09%
==========================================
Files 33 33
Lines 3517 3580 +63
==========================================
+ Hits 3360 3417 +57
- Misses 157 163 +6
☔ View full report in Codecov by Sentry. |
movingpandas/io.py
Outdated
from pandas import DataFrame | ||
|
||
from movingpandas import Trajectory | ||
|
||
|
||
def gdf_to_mf_json( | ||
gdf: GeoDataFrame, | ||
traj_id_property: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use "column" instead of "property" to make it clear that these are referring to columns of the GeoDataFrame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
I solved the last failing GitHub action which was due to some comment lines being longer than 88 (following the default 120). This has now been solved. |
Thank you again for this contribution. |
It is my pleasure to contribute to this excellent package! |
Add gdf_to_mf_json Method
This pull request adds the gdf_to_mf_json method to the codebase. The gdf_to_mf_json method converts a GeoDataFrame to a dictionary compatible with the Moving Features JSON (MF-JSON) specification.
More precisely, the method transforms a GeoDataFrame made of Point geometries into a Feature Collection object. It can handle multiple trips with different timestamps. The name of the columns that should be considered temporal properties can also be provided in order to include them as such in the resulting dictionary.
Example