Skip to content

salpheus/gmaps2geojson

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gmaps2geojson

Super simple python utility for getting GeoJSON from Google Maps routes.

Setup

Written using Python 3.6. Install requirements with pip install -r gmaps2geojson/requirements.txt.

Get an API key for the Google Maps Directions API. Set this as an environment variable.

export GMAPS_KEY='YOUR API KEY HERE'

Usage

>>> import gmaps2geojson
>>> writer = gmaps2geojson.Writer()
>>> directions1 = writer.query("2131 7th Ave, Seattle, WA 98121", "900 Poplar Pl S, Seattle, WA 98144")
>>> directions2 = writer.query("900 Poplar Pl S, Seattle, WA 98144", "219 Broadway E, Seattle, WA 98102")
>>> directions2
[[47.59326, -122.31111], [47.59378, -122.31149], [47.59392, -122.3116], [47.59415, -122.31169], [47.59445, -122.31184], [47.59576, -122.31278], [47.59581, -122.31282], [47.59582, -122.3138], [47.59583, -122.31503], [47.59583, -122.31841], [47.59582, -122.31868], [47.59575, -122.31873], [47.59571, -122.31874], [47.59564, -122.31874], [47.59556, -122.3187], [47.59547, -122.31854], [47.59537, -122.31841], [47.59518, -122.31832], [47.59502, -122.31833], [47.59491, -122.31838], [47.59479, -122.31848], [47.59469, -122.31861], [47.59463, -122.31877], [47.59459, -122.31893], [47.59459, -122.31914], [47.59462, -122.3193], [47.5947, -122.31952], [47.59486, -122.31973], [47.59503, -122.31986], [47.5951, -122.31989], [47.59522, -122.31992], [47.59537, -122.31993], [47.59587, -122.31994], [47.59647, -122.31998], [47.59702, -122.32008], [47.59744, -122.32019], [47.59781, -122.32032], [47.59802, -122.32041], [47.59827, -122.32049], [47.59839, -122.32057], [47.59876, -122.32082], [47.59911, -122.3211], [47.59922, -122.32119], [47.59965, -122.32165], [47.60002, -122.32209], [47.60136, -122.32382], [47.6021, -122.32478], [47.60295, -122.32584], [47.60332, -122.32622], [47.60359, -122.32649], [47.60558, -122.3282], [47.6067, -122.32918], [47.60727, -122.32971], [47.60738, -122.32982], [47.60785, -122.33022], [47.60812, -122.33042], [47.60819, -122.33054], [47.60867, -122.33075], [47.60895, -122.33082], [47.60956, -122.33096], [47.61007, -122.33099], [47.61037, -122.33099], [47.61068, -122.33094], [47.61093, -122.33087], [47.61285, -122.33019], [47.61293, -122.33016], [47.61324, -122.33004], [47.61332, -122.32992], [47.61347, -122.32982], [47.61365, -122.32972], [47.61395, -122.32956], [47.61447, -122.32934], [47.61588, -122.3288], [47.61611, -122.32871], [47.61618, -122.32866], [47.61641, -122.3284], [47.61665, -122.3279], [47.61705, -122.32691], [47.61716, -122.32677], [47.61733, -122.32661], [47.61773, -122.32627], [47.6187, -122.32547], [47.61903, -122.32517], [47.61927, -122.32485], [47.61936, -122.3247], [47.61958, -122.32427], [47.61974, -122.32378], [47.61981, -122.32346], [47.61988, -122.32305], [47.61989, -122.3222], [47.6199, -122.32087], [47.62048, -122.32088], [47.62056, -122.32088]]
>>> writer.save("example.geojson")
  • query(src, dest, custom_label=None): Use the query function to get a list of coordinates -- derived from the first result on Google Maps between the provided source and destination. Returns list of (latitude, longitude) coordinates
  • write(filename): Outputs geojson of all queried routes. All routes have a name property in the format of <src> to <dest> unless a custom_label was specified when querying.

See example.py and example.geojson.

About

Convert google maps routes to geojson

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%