How to plot a shapefile using GeoPandas

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] so what's up guys how are you doing i hope you're great so today in this tutorial i'm going to show you how you can use japandas to plot a shapefile so i have my shapefile here in this folder it is called districts as you can see it's here and then i want to use geopandas to open this shapefile and then i should be able to visualize it here in my under corner platform so what you should do first you should import your pandas and then we import geopandas import geopandas as gpd import japanese as gpd and then from there i want to read my file my my share file i'll say gpd dot dot redwatch.file and then i'll open and close brackets and then i'll i'll put in the location the file location my file is in this folder called list and then and it's called districts.shp so i'll say this and then restrict dot shp so that is the share file format and then i run it once i run it you see it returns for me what it has read and then you see these are the contents of by shape file although they are returned in the form that is similar to a pandas data frame i think you're familiar with pandas data frames if not you should check out art story on pandas data frames so what i should do first is to assign a variable to this that i have read which i'll call sh i'll call it shape file call it shape file yeah chip file should be that so as you can see you can be able to access this share file from anywhere and then the next thing we should do is to import matplot dot pi plot as plt or import mod plot leave it smart plot sleep dot pi plot as plt so the next thing we are going to create we are going to the next thing you are going to do here is to create a space where we are going to to to to draw our our shape file and then we shall use bad plot we shall first set up the axes we shall say fig and then access will be equal to prt dot subplots so uploads and then you can see this is this is where we are going to plot our shape file but it is still small so i'd like to increase on its size so i'll say fig size fig size big size 0 let me use 15 by 15 wow 15 by 15 is quite big that means by 10 10 by 10 yeah this is relatively smaller so that's the first thing we do and then the next thing we are going to do is to come and look at our data set which is shapefile and then see what it includes so here we shall see that we have a column for shape length a column for shape area and then a column for households and then let us first plot it on let us first plot our shape file to plot our shape file we shall need to call the shape file which is shapefile dot plot open brackets and then specify the axes which you are going to plot it on which is ax so this is our shapefile as you can see yeah we've plotted it but we can try to make it more beautiful and more beautiful and more beautiful actually i've just gotten a random idea why don't we just try to plot these households and then see let us visualize these households and then see how this will look so to do that i'll say shapefile.plot dot plot yes and then i'll specify the column column is going to be this column which column the household this one this household and then let me just paste it here let me see oh supposed to be a data frame something like this yeah and then i'm going to put ac map i hope you know it seem up which will be blues blues blues blues let me see yeah this is what i wanted to show you so i'm trying to create something which is like a group what i'm trying to create something is like auropleth oh i don't know that word okay that map so yeah this is what i'm trying to create and then yeah but before we continue let me just put off this title just say ax dot axis no so before i continue i just want to put off this outline it's not making sense for me so i'll just write a x dot axis and then i'll say of yeah so it's off actually let me try to put a title and then we see how it will look like so i'll say ax dot set exit set tighter or tightly single t and then this is the title a map just putting a title a map showing showing what households households oh this will be a x not a s but it is still small so let us try to increase it to increase it i'll need to create the font dictionary contradict so this this is a dictionary that that is going to include what we shall use to style our font so i'll say let me try to say font yeah so as you can see i've tried to increase this the size of the title so we can do more and more and one more i'll show you more in our next stories this is just an introductory to your pandas don't forget to subscribe to this channel see you soon
Info
Channel: Jesse Buyungo
Views: 14,666
Rating: undefined out of 5
Keywords: geopandas plot shapefile, geopandas shapefile, geopandas examples, geopandas tutorial, import geopandas
Id: xxg4Vm-Xg9g
Channel Id: undefined
Length: 8min 3sec (483 seconds)
Published: Tue Dec 29 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.