Geographical Plotting with Python Part 1 - Your first Geo Chart!
Skills:
AI Productivity Tools60%
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: AI Productivity Tools
View skill →Related Reads
📰
📰
📰
📰
AI lesson planning: how Spanish teachers use ChatGPT to save 5 hours per week
Dev.to AI
AI-Powered Smart Presets: Consistent Color Correction Across Venues for Freelance Event Photographers
Dev.to AI
AXbit - an experimental visual astrodynamics lab
Dev.to · Oleksii Trofymchuk
How to build a faceless YouTube channel with AI in 30 days
Dev.to · Already Here LLC
🎓
Tutor Explanation
DeepCamp AI