I’ve been teaching GeoPython recently to beginners – still places on courses in September (GeoPython for beginners and Git for beginners – early bird rates for August). We do alot of foundational work in order to open the doors to then start doing impactful things with Python. The topic that seems to get most people excited is GeoPandas and within that topic its the explore method that really switches people on.
— Andrew Cutts (@map_andrew) July 20, 2022
There are also a couple tutorials out there on explore. For example:
- The GeoPandas documentation https://geopandas.org/en/stable/docs/user_guide/interactive_mapping.html
Interactive Geographical maps with GeoPandas – https://towardsdatascience.com/interactive-geographical-maps-with-geopandas-4586a9d7cc10
These are great examples, styling especially. I found that once you have actually styled and built your map then being able to save it really switches on the lightbulb. So often with code, and especially with a simple example, a beginner needs to be shown how this makes a difference to them – and that is hard. By saving your ‘styled’ vector dataset(s) to a html file – you can share or serve the data across an organisation. Then you can go back and restyle, perform geoprocessing or add more data. What could be more impactful than that?
So how do you save?
import geopandas as gpd # import geopandas nybb = gpd.read_file(gpd.datasets.get_path('nybb')) # use the geopandas New York dataset m = nybb.explore() # create m as folium object m # call it (this will plot in Jupyter) m.save('example.html') # saves the folium object to html
It is as simple as that. Try it with your own data.
Code is here
I am a freelancer able to help you with your projects. I offer consultancy, training and writing. I’d be delighted to hear from you.
Feel free to connect or follow me; I am always keen to talk about Earth Observation.