Geographical Plotting with Python Part 1 - Your first Geo Chart!

sentdex · Beginner ·🛠️ AI Tools & Apps ·12y ago

Key Takeaways

Creates a first geo chart using Python with matplotlib and basemap

Full Transcript

hello everybody and welcome to the geographical plotting within Python tutorial or basically how to plot data onto a map using uh latitude and longitude to do this we're going to be using a module called base map which works alongside map plot livs so a lot of your map plot lib skills will be directly transferable here I'm going to assume that anybody watching this already has matplot lib and pil if you don't you should definitely get matplot lib and probably uh go back a little bit and watch some of the matplot lib tutorials since they're going to cover some stuff that I'm going to kind of glaze over here because I assume you guys already know so what I plan to cover in this video in the subsequent few videos is the basics of displaying a geographical plane how to customize it and how to begin plotting on it uh pretty much all we're going to do is is simply plot some dots maybe in the future if I get around to it we can do some stuff like heat Maps uh but you need special files to do that and then once you have the special file it's really not too difficult so it's actually harder to plot your own data so anyway let's go ahead and get started and let's get what we need in that SPAC map so what you want to do is head over to your favorite internet browser and you're going to want to go to matplot li. org basemat and once you're there click on the download button and then it'll be like go here so you'll click here and uh you'll end up on Source Forge and you'll want to pick the latest version of basem map and then you can pick whatever you've got here there's the 64-bit 32bit and there's also just like the source down here so pick whichever one you uh are using if you've got a 64-bit python you need to download 64-bit if you've got 32-bit python uh you need to download a 32-bit and once you've got that all installed uh we can begin to work with base map so what you should always do once you think you've installed it you should bring over an interpreter real quick and do import or I'm sorry from mcore toolkit. basemap import capital b a map and as long as you don't throw any errors you've done it right so as long as you haven't let's continue with the tutorial so as you could probably guess that's what we're going to import here as well so we're going to say from npl toolkit. basap import import Bap now what we need to do is import matplot Li P plot as PLT you guys should be pretty familiar with this matplot li. pyplot as PLT not period now what we want to do is we want to set up our base map logic so what you can kind of think of this as is when you were building a figure in matplot lib and you were setting up maybe a subplot that's kind of what we're doing here is setting up our subplot so here's what we're going to do we're going to say m for a really really short equals capital b as map and the projection is going to be equal we're going to use Mill now what Mill is standing for is a Miller cylindrical projection if you don't care sorry it's time to learn some stuff basically the displaying of a map is there's I let's see there's about I don't know 20 or 30 different projections that you can use within base map so just depends on what you're looking for let me drag it over these this is the list here and then I'll pull it up so you can see the whole thing um so from there all the way down here and so um basically I can open up a few so you can kind of get an idea what I'm talking about when I say that each one has its own kind of stuff right so here is our Miller this is what our map will look like right so it's squarish but as you can see uh it gets kind of distorted especially up here this is kind of a distorted area we come over this is an asmal equidistant projection so uh there's that you've got this I don't even know how to say this pneumonic full disc anyway you get the idea so depending on like what exactly you want your um your chart to look like basically you can choose between all of these but for the purposes of this tutorial just to keep it as basic as possible we're going to use this Miller one which I believe is this one so um anyway just kind of be aware of the fact that there's just a ton of other projections but each one has um different stuff like it depends on like if you're if you're making a flight map let's say you kind of want your distance between the two uh between point a and point B to be at least visually quite you know pretty close and then but at the same time if you're just interested in the countries then you want the countries to be fairly proportionate to their actual size and you don't care so much about the oceans maybe just depends so there's just there's like a you know a projection for every size so that's that uh the next thing that we want to do is is specify the corners that we want um our projections so this is you know the full earth right but if we just wanted maybe the United States we would specify you know the coordinates here here here and here like a box but for now we're going to just do the a full a full size here just to keep things as simple as possible so the way this is is llcr n r l a t so this is lower left so LL lower left crn cor or C crnr Corner latitude equals uh 90 then upper right corner lat equals 90 back slash enter Then LL Corner lawn equals uh - 180 and then upper right corner lawn = 180 so we've got a full map here next thing we need is resolution equals c and that's um we'll talk about that probably in the next next video because I don't want to spend too much time explaining everything here um but basically that's how you know the level of uh granularity basically you're going to have but we'll get to that like I said so then um next thing you want to do is do M draw coast line empty parameters that's just obviously going to draw lines over the coast then we want to fill the continents so m. fill continents continents so basically you're originally just because you did this you would just have like a blank plot and you got to draw some Coast lines now you're going to fill in the continents and then m. draw map boundary and then we'll add a title same way you've always added titles uh so quick base B map example and then PLT doow and if we haven't thrown any errors or made any errors um this should work sure enough here is our basic projection just a quick example of how we can uh put something up real quick so anyway um that's your first chart definitely just wanted to put out a a chart get you guys going in the first video but uh the next stuff we're going to continue on in the next video so if that sounds interesting to you guys and you should continue on as always thanks for watching

Original Description

Series playlist: http://www.youtube.com/watch?v=E6gvtfQHJUs&list=PLQVvvaa0QuDfpEcGUM6ogsbrlWtqpS5-1&feature=share&index=22 In this series, you are taught how to plot on a map with python and do geographical plotting with the matplotlib extension called basemap. Now that you are pretty much a pro at all other things Matplotlib, it is time to learn how to spread your wings a bit and begin working with geo-plotting on maps, using basemap. Basemap works alongside Matplotlib to allow you to plot via latitude and longitude coordinates. Once you have basemap installed, you can use the following code to quickly show a simple map. This will just render and display a map, but soon we'll be plotting, zooming, and more fun things! Sample code: http://pythonprogramming.net/geographical-plotting-basemap-tutorial/ Sentdex.com Facebook.com/sentdex Twitter.com/sentdex
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

Related Reads

📰
AI lesson planning: how Spanish teachers use ChatGPT to save 5 hours per week
Spanish teachers use ChatGPT to save 5 hours per week on lesson planning, reducing their workload and stress
Dev.to AI
📰
AI-Powered Smart Presets: Consistent Color Correction Across Venues for Freelance Event Photographers
Learn how to create AI-powered smart presets for consistent color correction across venues, saving time and improving client satisfaction for freelance event photographers
Dev.to AI
📰
AXbit - an experimental visual astrodynamics lab
Explore solar system dynamics with AXbit, a visual astrodynamics lab
Dev.to · Oleksii Trofymchuk
📰
How to build a faceless YouTube channel with AI in 30 days
Learn to create a faceless YouTube channel using AI in just 30 days, leveraging technology to streamline content creation
Dev.to · Already Here LLC
Up next
14+ Free Google AI Tools for Research & Learning You Should Know
Growth Learner
Watch →