dime-worldbank / googletraffic

R package to query Google Maps traffic data and transform into data
Other
55 stars 9 forks source link

Export Data Format, GeoJSON, shp ... etc #16

Closed asoliman1984 closed 6 months ago

asoliman1984 commented 6 months ago

Is there any method that can be save the result as .shp file ? or GeoJSON or any other data format

ramarty commented 6 months ago

@asoliman1984 This is a good suggestion. As the data is being converted from an image, initially the data will come as raster. But the raster could then be converted to polygon (eg, using something like this: https://rdrr.io/cran/terra/man/as.polygons.html) -- where a separate polygon could be made for each traffic color. May not be super straightforward to convert the polygon to a polyline, but may be a good way to do that.

I'll think a bit more about the best way to incorporate this into the package. For now, though, could:

  1. Get the data as a raster
  2. Use an approach like this to convert from raster to polygon: https://rdrr.io/cran/terra/man/as.polygons.html
  3. Save the polygon as a shapefile/geojson/etc