In addition to placing the marker, we can also add an interactive popup for each well. Next, we need to loop over each row within the dataframe and add it that row directly to the folium map using the latitude and longitude values. This will be centred around the mean latitude and longitude within our dataset. Once the libraries have been imported, we can begin to build our Folium map.įirst, we create our base map using folium.map(). import folium from streamlit_folium import st_folium, folium_static We will also need to import Folium to create our map object. This is done as follows: pip install streamlit-foliumĪfter the streamlit-folium component has been installed, we can import two modules: st_folium and folium_static. To begin using it, we first need to install it into our Python environment. When we run our Streamlit app using: streamlit run app.py longitude: ‘lon’, ‘longitude’, ‘LON’, ‘LONGITUDE’.latitude: ‘lat’, ‘latitude’, ‘LAT’, ‘LATITUDE’.In order for the latitude and longitude to be picked up, the columns need to be named appropriately: To create the map using Streamlit, all we do is call upon the following function and pass in the dataframe. The map generated by this function allows you to move around and zoom in like any other online map tool however, it does not come with any additional interactivity such as popups or the ability to colour points. This makes creating a map easy, as you do not have to install additional libraries or components to get it to work. The simplest way to generate a map in Streamlit is to use the st.map function. df = pd.read_csv('wellbore_exploration_all.csv', usecols=) df.columns = Streamlit.map() In order to make things easier with plotting, we can rename the wlbNsDecDeg and wlbEwDesDeg to latitude and longitude respectively. As this file contains many columns, we will want only to load the relevant columns. To load the data, which is contained within a CSV file, we need to call upon pd.read_csv and pass in the location and name of the file. The data is licensed under a NOLD 2.0 licence from the Norwegian Government, details of which can be found here: Norwegian Licence for Open Government Data (NLOD) 2.0. The full dataset can be downloaded here: The data we are using for this article comes from the Norwegian Petroleum Directorate website and contains the locations of all wells that have been drilled on the Norwegian Continental Shelf. import streamlit as st import pandas as pd For this article, we will be using two libraries to start with: Streamlit and Pandas. Importing Libraries and Dataīefore we start, we need to import the libraries and the data we will be working with. Within this short article, we will look at three easy ways to create interactive maps directly within a Streamlit app. Having an interactive map within our app allows us to visualise where the data points are located, and in turn, we can identify patterns or dig into the data in more depth. If we are looking to build a data analysis app within Streamlit that uses data containing location information, one of the first visualisations we may want to consider adding is a map. Streamlit provides a quick and easy way to build interactive applications and dashboards for data analysis and machine learning.
0 Comments
Leave a Reply. |