mapillary / mapillary-python-sdk

A Python 3 library built on the Mapillary API v4 to facilitate retrieving and working with Mapillary data.
MIT License
39 stars 15 forks source link

[Requirements] 12. Save To File #23

Closed Rubix982 closed 3 years ago

Rubix982 commented 3 years ago

Is your feature request related to a problem? Please describe. This issue deals with the 2nd requirement from the PRD for saving the data retrieved from the API

Describe the solution you'd like The base requirements are,

  1. Takes a JSON or GeoJSON object as an argument
  2. Takes path as an argument, default is current working directory
  3. Takes format as argument: GeoJSON, shapefile

Describe alternatives you've considered NA

Additional context Relies on Fiona to get the proper driver for saving to shapefile format

cbeddow commented 3 years ago

We should not save as shapefile for now. It will require a special solution that relies on GDAL or Fiona libraries, and because these are strange on Windows it could lead to too many user errors.

We should consider allowing a CSV format, so could create two util functions:

1) save to geojson 2) save to csv

A CSV should have a column called geometry which stores the geometry in Well-Known Text (WKT) format, like the examples table here: https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry

A key thing: in geospatial data, x is always longitude, y is always latitude, for example in POINT( x, y) in WKT format. Sometimes some system reverse them and consume a y,x format which is strange but how it is. Usually Esri ArcGIS consumes it backwards, but we do not need to think about that much right now.

Rubix982 commented 3 years ago

This is interesting. Since we are consuming the data from the APIs, and the data is in a GeoJSON/JSON format, that would be easy to store. The challenge can be for CSV files since it maps data as we do in an RDBMS. We can use the CSV python package for that.

@cbeddow What should the file extension of the save to geojson be? Should it be .geojson, or .json?

cbeddow commented 3 years ago

@Rubix982 for GeoJSON it should be .geojson. For CSV, if there are challenges now we can leave this for later as a wish list item. Often we end up having very long fields with a JSON-like object in the field in this case, though, if the mapping is a problem, so we can experiment with it when we get GeoJSON saving solved first.