Creating Geospatial Heatmaps With Plotly Express MapBox and Folium in Python - Data Visualisation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey friends welcome back to the channel in today's video we're going to be looking at how to create simple geospatial heat maps and Python and for this we're going to be using two popular python libraries the first is plotly Express and we'll be looking at the matte box feature and the second is a popular volume Library which makes it easy to generate maps in Python we're going to be using some Well Log data that's been acquired along the Norwegian continental shelf and within that data set we're going to be looking at Acoustic compressional slowness and how it varies across that region so geospatial heat Maps allow us to visualize Trends in our data so we can look at variations across the region as well as within smaller areas of that region and we can also use it to identify outliers and measurements so perhaps we've got a series of sensor measurements across an area and maybe one of them is faulty which gives an unusually high or low reading and we'll be able to identify that in the geospatial heat map so as go over to Jupiter notebook and see how we can create some interactive geospatial heat Maps so the first thing that we're going to do is import the libraries we're going to be using so we're going to need pandas and that is important as PD and that will be used to load our data then we're going to use two different visualization libraries for viewing our data on maps first is plotly Express and the second is folium now these libraries have their own advantages and disadvantages and it's mainly down to personal preference which one you prefer to use so I'll show both ways so that you have an understanding of how to create the geospatial heat map so once these have been imported we can then load the data and we're just going to load the data from the Zeke and Force 2020 machine learning competition and it's basically a summarized version of the acoustic compression or DTC curve across all of the wells within the data set and we're going to map these values across that Norwegian continental shelf so when we run this we can see that we've got our wound name or DTC measurement which is what we're interested but we also have our latitude and longitude positions and this will allow us to plot where our data is originating from and then we've got some other columns in here if we need them temperature water depth and completion year and we'll use these as labels within our plot lay Express and fully a map so now that we've got that data loaded in we can then go on to creating a heat map within Broadway Express and this is a very simple way to do it and we just call upon fake is equal to PX Dot density map box and then we pass in our data frame and then we need to pass in a few variables so our position data which is our latitude so latitude and we'll pass in our longitude and then we pass in the variable that we're wanting to map which is Zed and we'll set this to DTC so this is what we're going to show across the the region and then we're going to set the radius to 20 and we also need to Center or map and where it's going to be located and we're going to set this over the Norwegian continental shelf or basically the North Sea region and then we'll zoom in so we're in this passenger dictionary and we need to pass in what is equal to so we're going to call upon our latitude and we'll take the mean value of that and we should have a capital l for latitude and then we're going to take the same for longitude and we'll set that to df.1 get shoot and we'll take the mean value of that so that we've got our Center Point for our map we'll set the zoom level equal to four so we can change this if we want to be a little bit more zoomed in and we'll also set the map box Style equal to open street map so it's a free map so we can use that without having to pay for our certain services to get such uh to get Ordinance survey Maps or much more detailed maps and then we can set the height of it is equal to 900 so that we're setting the height of the figure and then we call config dot show and when we run that we get back the following heat map so we can zoom in and already you can see that when we hover over this we get our latitude and longitude values as well as our DTC value and if we zoom in we can see our radius taking effect here so we can go back up and change that to let's say 60. however when you do that you'll see that you get less details so it's just a case of picking the most optimal number within here so 20 seems fine we can see a little bit more detail we've got two separations here and our DTC values so it's slightly slower and we also have our color bar on the right hand side just to help us the great thing about using plotly Express is that these values are automatically added to our tooltip however as you'll see with volume we need to add these manually so let's have a look at our Folia map and the code is slightly different so we need to create our map object so we need to call upon folium dot map and this is our basic map so we set the location and we'll set that equal to equal to these values here so we'll just steal this and put it into a list and we just take off the first two powers of that so so that we've just got the DF and then we pass in the zoom and we'll set this one equal to six and we'll add the control scale as equal to true so we want to be able to control it so we can then call it map then when we do that let me start so I just missed a start off of that so that when we start the map it starts at the zoom level of six so now we've got our basic map now we need to apply the values onto our map so we need map underscore values and we'll say DF and what we're wanting and we're just converting our data frame objects into basically lists latitude and one Gadget and what value we want out as DTC so this is the data that we're going to put onto our map or something take that space out and then data is equal to map values dot to list so we're just converting everything into a list and before we run this I need two lists and I need to add in value so that we're extracting the values from our data frame so now when we open data we then get our list of the values for our latitude and longitude for each of the wells so the next step is to then apply that and we'll say hm which is short for heat map and it will pass in our data and then we set the Min opacity is equal to 0.05 so 5 minimum opacity Max opacity and we'll set that equal to 0.0.9 and we'll set the radius equal to 25 . and then we call upon one extra bit and that is add to M so we'll add that onto our map object and then we just call upon M which is our map so when we do that we now get the Heat Map There's slightly better colors than uh portal Express but they can easily be changed and we get the similar patterns as well so we can see the higher values are our slower intervals or higher values of DTC and then the lighter colors the blues and the greens are faster in the rows so once we've done that we would need to start adding some tool tips onto the four layer map and you can find that in my earlier video looking at geojson data and how do we add those labels so there we have it we've seen how to use two different plotting libraries to view spatial variation within werewolf measurements across an area and we've done that using plotly Express and also folium so you'll see that folium takes a little bit less code in one sense compared to our density map box so you can see that the two functions are equivalent we've got we're setting the latitude and longitudes the center point and the zoom level and then we're passing our data and it's automatically doing the interpolation between the points whereas volume we need to create a base map and then we add on to that map or heat or heat map which then allows us to view those values so I'll leave the next video up here if you're interested in applying python to other geoscience applications if you've enjoyed this video give it a thumbs up and if you want to see more content from this channel click on that subscribe button and ding that notification Bell so thanks for watching and I'll see you in the next video
Info
Channel: Andy McDonald
Views: 2,174
Rating: undefined out of 5
Keywords: andy mcdonald, geoscience, data visualization, folium, folium maps, python folium, folium heatmap, heatmaps, plotly express, plotly express mapbox, python, python mapping, python folium maps, python plotly maps, folium jupyter notebooks, well log data, petrophysics, python for data science, mapping in python, heatmaps in python, plotly maps, data science, data visualization python, python maps, data science python, geospatial heatmaps, geospatial data, python for beginners
Id: vSGWmZre31A
Channel Id: undefined
Length: 9min 15sec (555 seconds)
Published: Wed Nov 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.