Geographical Plotting with Python Part 4 - Plotting on a Map
Key Takeaways
Plots geographical data on a map using Python and Basemap, including setting up a subplot and choosing a zoom level
Full Transcript
what is going on guys welcome to the fourth geographical plotting within Python tutorial with a basem man where we left off we were making well we I showed you guys that cool blue marble and stuff but we're not actually going to be using that so I'm going to delete that um the other things that we're going to change we'll keep this we'll keep this we'll keep this and actually let's get rid to draw Rivers we don't need to be draw Rivers uh and then we'll do that so again kind of like what I was saying before this is if if you're coming from mat plot lib this is kind of like how we set up our subplot like the parameters that we want it to take as we do this so uh like I was saying I think probably it be in our best interest to focus on like one area so we can start plotting and seeing it really well so I'm going to go ahead and have us focus in on the United States so uh the first thing that we want to do is is change up our coordinates a little bit so really the lower left coordinate we really want that to be more like 20 upper right corner lat will'll do 50 lower left corner longitude 130 and upper right corner will be a60 so that run it let's make sure we did that right yeah looks good so now this is what we've got we could kind of trim this away a little bit but that's okay we'll leave it like this for now um but you know as we plot in various spaces we'll be able to see it better so let's actually make a plot so like I was saying before um first of all the things are flipped just keep in mind so again coordinates are typically given latitude then longitude and really in our scenario that's like giving us coordinates for y comma X right and so that's kind of the opposite of what we want so you want to keep in mind that and you also want to keep in mind that North southeast west so if you're getting coordinates that have uh North southeast west instead of negative and positive values you want to convert them I will say that a lot of places are actually giving the coordinates in you know positive and negative so that's actually kind of nice because uh it wasn't always like that and there's still a lot of places and sources that are going to have them with north south east west but just keep that in mind and just do like a switch uh if if you have a source from giving those kinds of uh coordinates but then don't forget at the end of the day that once you have those coordinates you have to flip uh flip the X and Y basically so keep that in mind so let's say uh you have Houston Texas um so what we're going to want to plot is a a DOT on Houston Texas and the latitude and longitude of Houston Texas is basically 2.76 and negative 95.3698 that you have to kind of convert it so what what we're going to do is not only are we going to convert it to the base map we're going to also like what a format that base map's going it's kind of like when you want to do stuff with numpy you have to first convert it like an array to a numpy array so you need to put it in a uh format that this base map will understand so because if you if you saw how we were hovering over base map it didn't give us latitude and longitude like in the corner there so you can't just do this quite yet but we'll get there so now what we're going to do is we're going to say x comma y so X and Y equals m and that is referencing you know your base mat projection all this stuff and then we want to do um long lat right X is your longitude Y is your latitude so X Y just kind of keep beating that in your head now all you have to do is m. plot XY and then here we're going to make a red dot and it's just going to be a little Dot and we better just change this we'll call this uh geop plotting so that's what we're doing now right we are geop plotting so render that and you probably can't see it in YouTube but there is a little minuscule dot over Houston and if you're following us then you should have that dot as well the other thing we could do we could say like red um think we can do this let's see if this works out for us there we go made it a little bit bigger here instead of a DOT we use this like zero marker um so any we can do that now what if we like you know maybe want to make another plot or something eventually you can just make a big array out of this like you would just instead probably do lat equals an array lawn equals an array of equal you know lengths basically and do that but just Just for kicks we'll do um let lawn equals and for Boulder Colorado 4012 and then the longitud is 104.2 4 then we're going to say XY equal m long L and then m. plot y and again we'll just we we'll plot this one green save that run it and now you can see that we've got this Red Dot and Green Dot there over Boulder over Houston pretty cool now that's cool but there are obviously a few small changes that we might want to make first of all maybe we're only plotting and dealing with major cities well in that case these dots are way too small right like no matter how much you zoom that's how big the dot is so maybe you want to have that dot a little bigger and then but what if what if you're plotting every city in the world and uh you've got dots like this and they run over each other that kind of stuff so I'm going to show you guys in the next tutorial how we can deal with that with some Alpha and also how we can change the size and that'll probably cover it in the next video and that should be enough for you guys to get started at least with geographical plotting um not too sure what else you might want to do you you know some people want to plot like wind bands and all this kind of stuff so there's obviously a lot of reasons you might do geographical plotting but this will at least get you started so anyway stay tuned to the next video as always thanks for watching
Original Description
Sample code: http://pythonprogramming.net/plotting-maps-python-basemap/
Playlist: http://www.youtube.com/watch?v=Xr6sG1QnMbw&feature=share&list=PLQVvvaa0QuDfpEcGUM6ogsbrlWtqpS5-1&index=25
In this tutorial with Basemap, you are shown how to actually plot a plot, as well as choose a zoom level on your projection. As you can see, plotting lat and long coordinates is fairly simple if you envision them as X and Y on a plane. The only confusing part is that X, Y translates to Lon, Lat... which is the reverse of how they are normally reported.
In this series, you are taught how to plot on a map and do geographical plotting with the matplotlib extension called basemap.
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
🎓
Tutor Explanation
DeepCamp AI