py-openaq icon indicating copy to clipboard operation
py-openaq copied to clipboard

Add geo-mapping functionality

Open dhhagan opened this issue 7 years ago • 4 comments

Make it easy for people to make nice geo-maps.

dhhagan avatar Nov 05 '17 15:11 dhhagan

I don't know if this has been discussed but I strongly suggest the folium library as a candidate. My running example goes like this:

import openaq
import folium

api = openaq.OpenAQ()
locs = api.locations(country='CH', df=True)

basemap = folium.Map(location=[locs['coordinates.latitude'].mean(), 
                           locs['coordinates.longitude'].mean()],
				zoom_start=8)

locs.apply(lambda row:	folium.Marker((row['coordinates.latitude'], 
			   row['coordinates.longitude']),
			   popup = row.to_json()).add_to(basemap),
			   axis=1)

basemap.save('airquality.html')

sergiolucero avatar Dec 11 '17 23:12 sergiolucero

Hey @sergiolucero I would suggest adding a few examples to the gallery if you have some time (I'm currently swamped and will be until I defend next spring...). If you need help figuring out how to do that, let me know and I can lend a hand on instructions.

dhhagan avatar Aug 21 '18 15:08 dhhagan

Hi @dhhagan I think I just created my first pull request. Does it need to pass any tests? I guess I need to modify requirements.txt as well?

sergiolucero avatar Aug 21 '18 19:08 sergiolucero

Hey @sergiolucero. There are unit tests it must pass and it looks like it's failing right now, but not because of your additions. I'll try and take a look later to see what's going on. You shouldn't need to edit the requirements.txt file as I don't think folium should be a requirement for installation - it will only be needed if geo-maps are to be built/used. Eventually, if there is a function of some sort for using folium within the library, it will be needed - but not for examples only. I will add it to the install file for travis.

dhhagan avatar Aug 22 '18 17:08 dhhagan