Thursday, March 30, 2023
No Result
View All Result
Get the latest A.I News on A.I. Pulses
  • Home
  • A.I News
  • Computer Vision
  • Machine learning
  • A.I. Startups
  • Robotics
  • Data science
  • Natural Language Processing
  • Home
  • A.I News
  • Computer Vision
  • Machine learning
  • A.I. Startups
  • Robotics
  • Data science
  • Natural Language Processing
No Result
View All Result
Get the latest A.I News on A.I. Pulses
No Result
View All Result

Creating Geospatial Heatmaps With Python’s Plotly and Folium Libraries | by Andy McDonald | Mar, 2023

March 19, 2023
141 9
Home Data science
Share on FacebookShare on Twitter


Two Nice Python Choices for Visualising Geospatial Variation

Photograph by KOBU Company on Unsplash

Heatmaps, also referred to as Density Maps, are information visualizations that show the spatial distribution of a variable throughout a geographic space. They are often nice instruments for visualising and figuring out traits, supporting decision-making, detecting outliers, and creating compelling visualisations for shows.

There are a number of mapping python libraries accessible, nonetheless, two extremely popular and simple to make use of libraries are Folium and Plotly Categorical.

Folium is a superb library that makes it straightforward to visualise geospatial information. It’s powered by Leaflet.js, which is a number one javascript mapping library and is platform-independent. Plotly is a well-liked library for creating highly effective interactive information visualisations with only a few strains of code and can be utilized to create interactive maps with MapBox.

Inside this text, we’ll see how we will use these two libraries to visualise acoustic compressional slowness information on the Norwegian Continental Shelf.

For this tutorial, we’ll begin with importing pandas, which might be used to load our information from a CSV file.

import pandas as pd

The dataset we’re utilizing for this tutorial is a mix of the next:

The Xeek Pressure 2020 Machine Studying lithology competitors dataset was used to derive a median acoustic compressional slowness (DTC) worth for the Shetland GroupData from the Norwegian Petroleum Directorate web site, which was used to offer the placement informationdf = pd.read_csv(‘xeek_force_2020_dtc_mapping.csv’)df

When the information has been loaded, we will name upon the dataframe with the next:

Dataframe view of wells on the Norwegian Continental Shelf. Picture by the creator.

We will see that we have now 7 columns:

Effectively Title — Title of the WellDTC — Common acoustic compressional slowness for the Shetland GroupTemperature — Backside gap temperate for the wellWater Depth —Depth of seabed from sea levelCompletion 12 months — 12 months the effectively was completedLatitude — Latitude place of the effectively in decimal unitsLongitude — Longitude place of the effectively in decimal models

To start creating the heatmap with Plotly Categorical, we have to import the library into our pocket book like so:

import plotly_express as px

We then must create a brand new determine. That is executed by calling upon plotly categorical’s density_mapbox .

To create our map, we have to cross in a couple of parameters:

df — the title of the dataframe with the datalat — the title for the latitude columnlon — the title for the longitude columnz — the title of the column containing the information we wish to visualise on the heatmapcenter — the place the place the map might be centred upon. We will name upon the imply of the latitude and longitude columnszoom — the preliminary zoom degree of the map

The final two parameters mapbox_style and peak management the background mapping layer and the peak of the plot.

fig = px.density_mapbox(df, lat=’Latitude’, lon=’Longitude’,z=’DTC’, radius=20,heart=dict(lat=df.Latitude.imply(), lon=df.Longitude.imply()), zoom=4,mapbox_style=”open-street-map”, peak=900)fig.present()

Once we name upon fig.present() we get again the next map.

Heatmap generated utilizing density_mapbox from plotly categorical. Picture by the creator.

From this map, we will see that we have now greater values of DTC within the northern finish of the area, which may very well be attributable to a number of issues, together with decrease compaction or elevated shalieness.

The wonderful thing about the map generated by plotly categorical is that we will hover over the information and get the values for the plotted variable (DTC). That is executed routinely and doesn’t require further code to create a popup field.

Added interactivity as a part of the heatmap generated utilizing density_mapbox from plotly categorical . Picture by the creator.

To start utilizing Folium, we might want to import it; nonetheless, so as to generate heatmaps, we additionally must import the HeatMap plugin from folium.plugins.

import foliumfrom folium.plugins import HeatMap

As soon as Folium has been imported, we have to create a base map by calling upon folium.map() . Inside that class technique, we will cross in a number of arguments. For this instance, we’ll use the next:

location — The place the place the map might be centred uponzoom_start — The preliminary zoom degree of the mapcontrol_scale — Whether or not the dimensions controls are displayed on the map

If you wish to discover out extra in regards to the parameters for the map perform, then try the assistance documentation on the folium.map class.

m = folium.Map(location=[df_combined.Latitude.mean(), df_combined.Longitude.mean()], zoom_start=6, control_scale=True)

We subsequent must create the heatmap layer.

To do that, we first must convert the latitude, longitude and values to a listing, which might then be handed into the HeatMap name.

We will set a couple of parameters to stylise how the heatmap seems, such because the min and max opacity, the radius of the colouring from the information level, and extra.

map_values = df_combined[[‘Latitude’,’Longitude’,’DTC’]]

information = map_values.values.tolist()

hm = HeatMap(information,min_opacity=0.05, max_opacity=0.9, radius=25).add_to(m)

Once we name upon our map object, we will see the same sample to the one generated by plotly categorical.

Heatmap generated utilizing Folium. Picture by the creator.

Nonetheless, there are a few downsides to this map:

There isn’t a hover performance just like what we noticed above with Plotly Categorical. We might add markers, however it requires a number of strains of further code.

If you wish to see how to do that, try my article beneath.

The opposite difficulty is that there isn’t any color gradient bar to assist readers perceive the vary of colors. However this may be resolved by creating a color map dictionary, as mentioned within the following StackOverflow submit.

Heatmaps present a good way to visualise and determine traits throughout geographical areas and might simply be created utilizing two common Python libraries: Folium and Plotly Categorical. These two libraries are easy to make use of and can be utilized to map petrophysical and well-log properties throughout giant areas. From these maps, we will derive details about traits and variations throughout fields or areas.



Source link

Tags: AndyCreatingFoliumGeospatialHeatmapsLibrariesMarMcDonaldPlotlyPythons
Next Post

a pretrained visible language mannequin for describing multi-event movies – Google AI Weblog

Alternate options to the p-value Criterion for Statistical Significance (with R code) | by Jae Kim | Mar, 2023

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent News

Heard on the Avenue – 3/30/2023

March 30, 2023

Strategies for addressing class imbalance in deep learning-based pure language processing

March 30, 2023

A Suggestion System For Educational Analysis (And Different Information Sorts)! | by Benjamin McCloskey | Mar, 2023

March 30, 2023

AI Is Altering the Automotive Trade Endlessly

March 29, 2023

Historical past of the Meeting Line

March 30, 2023

Lacking hyperlinks in AI governance – a brand new ebook launch

March 29, 2023

Categories

  • A.I News
  • A.I. Startups
  • Computer Vision
  • Data science
  • Machine learning
  • Natural Language Processing
  • Robotics
A.I. Pulses

Get The Latest A.I. News on A.I.Pulses.com.
Machine learning, Computer Vision, A.I. Startups, Robotics News and more.

Categories

  • A.I News
  • A.I. Startups
  • Computer Vision
  • Data science
  • Machine learning
  • Natural Language Processing
  • Robotics
No Result
View All Result

Recent News

  • Heard on the Avenue – 3/30/2023
  • Strategies for addressing class imbalance in deep learning-based pure language processing
  • A Suggestion System For Educational Analysis (And Different Information Sorts)! | by Benjamin McCloskey | Mar, 2023
  • Home
  • DMCA
  • Disclaimer
  • Cookie Privacy Policy
  • Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2022 A.I. Pulses.
A.I. Pulses is not responsible for the content of external sites.

No Result
View All Result
  • Home
  • A.I News
  • Computer Vision
  • Machine learning
  • A.I. Startups
  • Robotics
  • Data science
  • Natural Language Processing

Copyright © 2022 A.I. Pulses.
A.I. Pulses is not responsible for the content of external sites.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In