Geographical Plotting with Python Part 4 - Plotting on a Map

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

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 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 AI Lessons

Up next
Salesforce Flow New Features (Summer '26) | Open Record, URL & Show Toast Messages
AITECHONE
Watch →