MLops for beginners

Day11: Geotagging Visualization using Python

What is geotagging? How to plot geolocation on maps? Some use cases and my fun project.

This article is about how i ended up creating a web application that geo-tags any image on the map using python.

What is geotaging?

According to wikipedia,

How to plot location on map using python?

There are many ways for this, I used a python library called folium. You can start with its documentation to know how it works. There is a good article on getting started.

  1. save the image in a location
  2. fetch metadata from the images and generate the location coordinates with it.
  3. plot the location images on the map.
  • location.csv is the database file where i stored the names of uploaded files and location fetched from those.
  • main.py is the main python file used to start my flask appliaction.
  • static is the folder used to store the the uploaded files.
  • templates is the folder used to save the html template files for the web application.
Web app
index.html
  • The image will be saved and updatedb() function will be called.
  • Since the /loc is used in iframe on the main page, so loc() function will also get invoked.
  • And then create_map() function will also be called. And then loc.html will be rendered.
updatedb() function
  • open the location.csv file
  • and then for every image it will extract the name and location.
  • If there is no location in the image file then the default data is set to None.
  • and write all the extracted data to the file.(comma seperated)
create_map() function
  • reads all the data from the location.csv file (except the last line because it will always be empty).
  • create marker for every valid entry in the file and add that to the map.
  • save the map with name loc.html.
extract() function to extract location from the metadata.
This code gives me all metadata from the file.
this is to extract the location in a readable manner.
Select and share
  • we can build an app that so that we can share the live update of any location on the map.
  • This can also be used in this current COVID-19 pandemic situation to know if there are violation of social distancing in a particular neighborhood. People can click the images of those and upload it and some action can be then taken by local authority for that if needed.
Bye Bye

Connecting the dots and rest is magic. https://ayedaemon.github.io/