Tuesday, March 21, 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

Easy methods to Show Knowledge From GeoJSON Recordsdata Utilizing the Folium Python Library | by Andy McDonald | Feb, 2023

February 24, 2023
149 1
Home Data science
Share on FacebookShare on Twitter


Creating Interactive Maps of UKCS Oil and Fuel Subject Outlines

Photograph by Aksonsat Uanthoeng, downloaded from Pexels.

Folium is a superb python library that makes it straightforward to visualise geospatial knowledge on interactive maps utilizing the facility of Leaflet.js. In my earlier article, I coated learn how to show particular person markers on a folium map, however we are able to use folium additionally show knowledge that has been saved inside a GeoJSON file.

GeoJSON is a generally used file format for storing geospatial knowledge and makes use of JavaScript Object Notation. These information can retailer location knowledge, shapes, factors, surfaces, and so forth.

Inside this text, we are going to see learn how to show polygons of UK North Sea oil and gasoline fields which have been saved inside a GeoJSON file format.

The info for this text is sourced from knowledge.gov.uk and is licenced beneath the Open Authorities Licence. The info will be seen and downloaded from the next web site.

Putting in Folium

For those who don’t have already got folium put in, you’ll be able to set up it through pip:

pip set up folium

Or Anaconda:

conda set up folium

After you have the library put in, step one is to import the folium library into our Jupyter Pocket book:

import folium

To maintain issues easy, we are going to assign the placement of the GeoJSON file to a variable. This makes issues easier once we need to name upon it later or change it for an additional file with out altering the remainder of the code instantly.

field_locations = ‘geodata/NSTA_Offshore_Fields_WGS84.geojson’

Subsequent, we have to initialise a folium map with some primary parameters.

The created map might be centred round a latitude of 58 levels N and a longitude of 5 levels E. We may even set the zoom_start to six to permit us to view a lot of the UK North Sea.

There are a number of different parameters we are able to use when making a folium map. If you wish to be taught extra, try the assistance documentation on the folium.map class.

m = folium.Map(location=[58, 5], zoom_start=6, control_scale=True)m

After we name upon the folium map object utilizing the variable m we are going to get the next map displayed:

Base folium map centred over the North Sea. Picture by the creator.

This generated map seems naked, so the subsequent step is so as to add some shapes to establish the UK offshore oil and gasoline fields.

To show the info from a GeoJSON file, we have to name upon folium.geojson and go in just a few parameters.

The primary parameter is the placement of the GeoJSON file, which we assigned to the variable field_locations. That is then adopted by the tooltip parameter, which permits us to show data within the tooltip when any of the shapes are hovered over. On this instance, we are going to set the fields to be exhibited to the identify of the oil or gasoline discipline (FIELDNAME).

Lastly, to make the objects seem, we have to add the extension add_to(m) on the finish.

folium.GeoJson(field_locations,tooltip=folium.GeoJsonTooltip(fields=[‘FIELDNAME’])).add_to(m)

We’re offered with the next map once we name upon the folium map object: m.

From the generated map, we are able to see the areas of the entire UK North Sea oil and gasoline fields.

Folium map exhibiting the outlines of the UK North Sea oil and Fuel fields. Picture by the creator.

If we need to add some styling to the shapes on the map, we are able to accomplish that by first making a perform which might be used to regulate the color of the form.

From this dataset, we might be utilizing the kind of discipline to decide on the colors that we need to show. Any oil fields might be displayed in inexperienced, gasoline fields proven in crimson, and condensate fields might be displayed in orange.

The next code was derived from this StackOverflow put up.

def field_type_colour(function):if function[‘properties’][‘FIELDTYPE’] == ‘COND’:return ‘orange’elif function[‘properties’][‘FIELDTYPE’] == ‘OIL’:return ‘inexperienced’elif function[‘properties’][‘FIELDTYPE’] == ‘GAS’:return ‘crimson’

Now that we’ve the conditional perform arrange, we have to add a brand new parameter to our name to folium.GeoJson referred to as style_function. Inside this parameter, we go in a lambda perform containing a dictionary for the styling properties.

On the subject of the fillColor property, we name upon the perform we created above and go in our function.

We will additionally go further styling properties to the dictionary. For this instance, we are going to set the fillOpacity to 0.9 and the burden, which controls the road across the shapes, to 0.

If we don’t need to embrace the shapes from the earlier part, we have to recreate the folium map once more.

m = folium.Map(location=[58, 5], zoom_start=6, control_scale=True)

folium.GeoJson(field_locations, identify=’geojson’, tooltip=folium.GeoJsonTooltip(fields=[‘FIELDNAME’]),style_function= lambda function: {‘fillColor’:field_type_colour(function), ‘fillOpacity’:0.9, ‘weight’:0}).add_to(m)m

After we name upon m, we’re offered with the next map.

Folium map of the UK North Sea oil and gasoline fields, colored by discipline kind. Picture by the creator.

We will now see that every form/discipline that’s on the map is colored primarily based on the first kind of hydrocarbon that’s contained inside the reservoir part.

Inside the GeoJSON file, we’ve a number of further properties for every form. These can simply be added to the prevailing tooltip by together with them inside the record for the fields parameter.

m = folium.Map(location=[58, 5], zoom_start=6, control_scale=True)

folium.GeoJson(field_locations, identify=’geojson’, tooltip=folium.GeoJsonTooltip(fields=[‘FIELDNAME’, ‘PROD_DATE’,’CURR_OPER’]),style_function= lambda function: {‘fillColor’:field_type_colour(function), ‘fillOpacity’:0.9, ‘weight’:0}).add_to(m)m

After we rerun the code, we are able to now see that we get the additional properties once we hover over every of the shapes. On this case, we are able to see the sphere identify, the date manufacturing began, and the present operator of the sphere.

Folium map exhibiting the outlines of the UK Oil and Fuel fields with further properties showing when every space is hovered over—picture by the creator.

Inside this quick article, we’ve seen how straightforward it’s to show knowledge saved inside a GeoJSON file on an interactive folium map. This enables us to shortly show shapes and descriptions that could be saved inside the sort of file.



Source link

Tags: AndyDataDisplayFebFilesFoliumGeoJSONLibraryMcDonaldPython
Next Post

A vision-language method for foundational UI understanding – Google AI Weblog

CMU Researchers Create AI Robotic That Paints

Leave a Reply Cancel reply

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

Recent News

Modernización, un impulsor del cambio y la innovación en las empresas

March 21, 2023

How pure language processing transformers can present BERT-based sentiment classification on March Insanity

March 21, 2023

Google simply launched Bard, its reply to ChatGPT—and it needs you to make it higher

March 21, 2023

Automated Machine Studying with Python: A Comparability of Completely different Approaches

March 21, 2023

Why Blockchain Is The Lacking Piece To IoT Safety Puzzle

March 21, 2023

Dataquest : How Does ChatGPT Work?

March 21, 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

  • Modernización, un impulsor del cambio y la innovación en las empresas
  • How pure language processing transformers can present BERT-based sentiment classification on March Insanity
  • Google simply launched Bard, its reply to ChatGPT—and it needs you to make it higher
  • 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