Automating Geo-processing tasks with GeoPandas and Python Scripting (Thiessen Weights Computation)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome to another tutorial into this tutorial you will learn how to fully automate the calculation process of TC and polygons dision polygons waits for extremely complex cases now if you can recall this previous video which i did quite some time back where i show you how to calculate the decent polygon weights for an extremely simple case in this case as you can see we have used one catchment area and there are some rainfall stations and we and I showed you how to calculate the contribution from each of these stations in terms of its in terms of average for this entire catchment now if you haven't checked this video out I highly recommend you to go through this video first especially if you are completely new to understanding the concept of these in weights and coming back to today's tutorial I'm going to show you how to fully automate the calculation process of TC and polygon weights for extremely complex cases and for this tutorial we'll have a look at the districts of nappa and what is the contribution from each of these meteorological stations to each of this district let's say for this case our variable can be something like a rainfall which gets recorded in these precipitation stations and by now you'll be able to guess that if you were to do the calculation process following the method which I explained to you in the previous video it's going to take quite a lot of time so from this tutorial let's learn how to fully automate this process using Python now first of all in order to do this I'm going to require three shape files the first shape file that I will need is actually the meteorological stations in this case you can see that I have already loaded up the shapefile and if I open the attributes table you can see that we have about 281 stations and each station has its name latitude and longitude so that's one shapefile that we are going to be [Music] using for today's tutorial and the next shapefile that I will need is actually the boundaries of the districts which is this share file so if I open the attributes table you can see that we have each of the districts and then its corresponding area in terms of square kilometers so we will need this shapefile as well and in addition to these two I'm going to create one more shapefile so in order to create a new shapefile I'm going to right click on my folder and go to new shapefile I'm going to name this as my boundary and it's going to be a polygon I'm going to use this projected coordinate system for this case click okay and we go to editor start editing go to editor again and go to editing windows and create features so basically what I'm going to do is I'm going to draw one polygon just around the boundaries of Nepal so click over here and select rectangle so just click somewhere over here all right now you can go and save your edits and stop editing okay by the way let me get rid of the basemap as well that'll make things a little bit faster and now what I'm going to do is I'm going to open this search panel and basically search for the TC and polygon command because I'm going to create a TC and polygon using my input features which are going to be the the meteorological stations and go to the environments and make sure that you set your processing extent to be your boundary which you've just created this is basically the reason why we created this new shapefile called boundary so click OK and click OK as well all right after a while you'll be able to see that we successfully created the TC n polygons and and if I were to move this neighbor district shapefile above these Thiessen polygons you can see actually which ball which station is corresponding to which district and you can basically see graphically how much of a contribution each of these stations will have for each of these districts now you can imagine that it's going to be a very tedious task if we were to just do the calculation in sort of a manual way that's why I'm going to write this script so even in the future case let's say if you did some changes to any of the boundaries or even if you get if you get rid of some of the stations you have to in case if you have to repeat the same process you can basically use the same script and then just at a click of a button you'll be able to calculate all the T's in weights for each of these districts in in a matter of seconds basically so that's what we are going to learn today so we created these three poly so we created these three shape files let me export this Thiessen polygon shape files with a with the proper name I'm going to call that ass dision Bali all right let's get rid of the others even the boundary we won't need it anymore alright so basically these are the three shape files that we will be using today for our tutorial now let's get started so the first thing that you need to do is open your code editor now in my case I'm using Spyder now if you would like to know how to install Spyder incase if you haven't installed it yet and how to configure Spyder using the anaconda distribution I have done a step-by-step tutorial and I suggest you to check that out before starting this tutorial I'll put the link down in the description below for your reference alright now let's get started now over here you can see that I'm already in my in the fault that I'm supposed to be in and indite in and inside that folder using this file explorer tab you can actually see what kind of files you can see over there so you can see that we we have the T sin polygon shapefile that we created and we also have the boundary of Nepal and we have the Nepali District shapefile as well as we have the meteorological stations alright first to get started let's import the Geo pandas library and if you haven't configured the Geo pandas library yet I suggest you to check the link down in the description below I have created a tutorial for that as well so let's get started by importing the Geo pandas library and now what I'm going to do is I'm going to actually import the shape files which are going to be relevant for the analysis so first let's put a come in and this is going to be we are going to import the shape files of districts and meteorological stations as well as the the TC and polygon okay so in order to if you want to import a shapefile to your Python interface you can basically use the Geo pandas library for that so I'm going to create a variable called districts and that is going to be equal to Jo pandas dot read file and within brackets you can simply just copy and paste the location of your shape file and make sure you have the slash inverted like this and the name of my districts is going to be over here which is Nepal underscore districts it's going to be easy to just copy and paste it from here just paste it over here alright now to run the command you can press press f5 and after pressing f5 you can see that we ran the code without any trouble so let's type districts over here and see how it looks like so you can see we basically see the same information that we saw previously if you go back to your shapefile and open the attributes table you see that you have one column called district and another column called area so if you would like to see what are the columns of this district shapefile you can simply type districts are not columns and you'll be able to see that we have the column called district the corresponding area and we have an additional column which is called geometry which is actually a very unique type of column where that's how basically geo pandas identified identifies the spatial properties of each shapefile so for example if you would like to even visualize the district's shapefile you can simply do that by using a simple plot command for example you can say districts dot plot and within brackets you can specify the size of the figure using fixed size and I'm going to specify the size to be let's say 12 by 12 all right now you can see that we were able to actually see the shapefile over here now since since we already know how it looks like I'm just going to get rid of that District shapefile as well and let's import the other two shapefile which are going to be the meteorological stations I'm going to call that as rainfall stations which is going to be basically the same command you can just copy it and paste it from here and the name of my shapefile is going to be this one just copy it and paste it over here and if you run the command now you can see that we do not have any errors if you would like to see how this rainfall stations shapefile looks you can just type maybe head and if you put 10 over here you will see only the first 10 entries we basically have the name of each of the stations so that's good enough and now let's import the final shape file which is also which is the TC and polygons so similarly I can just copy this and paste it over here and the name I'm going to change that to be this Ian's polygons and the name of the polygon is going to be kitchen poly just going to copy the name and paste it over here all right now let's run this these three commands and see and let's have a look at how these Thiessen polygons shapefile looks okay so let's do a quick visualization of these TC and polygons we can even type it over here directly this in polygons dot plot figure size specify to be twelve by twelve all right now you can see that we also have the TC in polygons so what you should understand by now is that we have successfully imported three shape files and you can also have a look at how the attributes table of the TC and polygon looks now you can visually see how the Thiessen polygons actually look but I'm also interested in seeing how the attributes table look so I'm just going to type over here this in polygons dot head and I would like to see the first ten entries all right you can see that there is not much actually we have one column called object ID and we have this special special properties column which is called geometry now even if I go back to RJ's and then have a look at how the Thiessen polygons attributes table look you can see that we basically have one column called object ID which correspond to each of the polygons basically but now I'm interested in adding the name of each of these stations into each of these polygons for example for a populated area like this you can see that these polygons got drawn based on the position of of the points so right now if I open the net open the attributes table of the polygons you can see that we see each polygon but we don't really know which station belongs to each each of the polygons so I would like to actually sort of extract the name of each of the stations for example if I try to put the labels of the names of each station let's say let's put it to be eight okay now you can see each of the station has its own name but those names are actually in this point shape file but I want to transfer each of these names based on its geographical location to its corresponding Thiessen polygon and we are going to do that using Python later on so right now since we don't have a dedicated column over here so right now in the TC in polygon shapefile you see that we do not have a dedicated column for the names of the stations so now what I'm going to do is actually I'm going to create a new column in this Thiessen polygon shapefile which I'm going to fill in later using a simple Python command so let's create an empty column so this one I'm going to commit it out as adding a new column - the Thiessen polygons attributes table so in geo pandas it's quite easy to add a new column you basically type the name of the name of your shapefile which is this in polygons and within square brackets you specify the name of the name of the column that you would like to actually add so in this one I'm going to name that as station name and that's going to be equal to basically anything and I'm going to just fill that basically by a random string let's say I'm going to type this as to be filled later and then just run it and now if you check your this in polygons dot columns you can see that we have three columns object ID geometry and we have added a new column called station names now if you would like to see how this station name column looks you can even do that very easily instead of typing columns over here within brackets you just put the name of the column in our case it's going to be station name all right now you can see that it got populated with this to be filled in later which actually we are going to be filling in later on after we after we write the script for that alright so now let's go to the next step and in this step I'm going to extract I'm going to do the process which I explained to you just a couple of minutes ago where I I will be writing a small script to let's say where I will be writing a small script and what that script is going to do for us is that let's say for a specified polygon for example let's imagine that we selected for example let's think that we selected this polygon and what it's going to do is that based on the spatial location of this polygon it's going to scan all these other points and check which point actually is inside this particular polygon and it's going to take this name of the corresponding station and it's going to copy that name into the corresponding polygon using using Python similarly if you look at another polygon based on the spatial location of this polygon it's going to again scan through all the points and then it's going to identify that this particular station is going to this particular station is lying in this polygon and screen it's just basically going to extract this name and then copy it to the to the attributes table off of Thiessen polygons file so that's what we are going to do right now and instead of doing that process one by one we are going to do the whole process iteratively for all of these polygons using a for loop so basically once we once we are done with the script we just have to run the program and then it will run that script for all of these polygons and basically extract all the names of the stations and then put it into the correct polygon where that point belongs to okay now let's see how to do that so I'm going to do that using a for loop so we write for index tomorrow in now we are going to eat right through this Thiessen polygon shapefile basically what we are going to do is we are going to iterate through each row of the T's in polygons attributes table and the command that we use to iterate through each of the row is basically called as it arose now as soon as I type this command what this command basically refers to is something like this for example if you again have a look at the Thiessen polygons attributes table all right so now only looking at this command what it does is that it's actually going to read all of these rows one by one and it's going to have two outputs and our two outputs are going to be the index value and the raw value for example if you would like to see how it looks at something like print give me the index and when I run the command you can see that it basically typed out all the index values starting from zero up to 279 all the rows all the rows of the Thiessen polygon shape file now instead of writing index over here if I could row and then run the command and you can see that all the 279 rows got printed out but the way that it got printed out is a little bit different now if you inspect this maybe one by one for example yeah this see this corresponds to one row and then this correspond to another row and similarly this corresponds to another row you can see how it works now right all right now I hope you have an idea about how how this four index kymaro in Thiessen polygons dot it arose these command line works so it's actually very useful command in selecting iterating over the rows of an attributes table or basically iterating over the rows of a Geo data frame if we call it in terms of Joe pandas terminology now as the second row I'm going to write another for loop and that's going to be again index but now I just put an underscore over here just so that we won't confuse this index with with this index row underscore in and now I'm going to iterate over the rainfall stations all right now what this does is now let's have a look at the rainfall stations attributes table you can see we have maybe let's go to the ArcGIS over here and then have a look at the rainfall stations attributes table you can see that each of these rows have the name the latitude longitude but we are basically interested in extracting the corresponding name so as you saw there if I go to this decian polygons attributes table what it's going to do is it's going to select the first row that's what this command line refers to and without jumping into the second row it's actually going to go to this line which correspond to the attributes table of the rainfall stations and it's going to scan through all of these rows so after it scans 280 rows what it's going to do is again it's going to jump back to the Thiessen polygons attributes table geo data frame come back again over here and now it's going to jump to the second polygon which is basically going to be second polygon which is basically going to be this polygon and before jumping onto the third row it's again going to go through all of these stations and it's going to scan again all of these stations all the 281 stations that's this line and after that again it's going to jump back to this row well what it's going to do is it's going to go to the third row and for the third row which correspond to race that polygon yeah it's this polygon so for the third row it's going to jump back again to the rainfall stations and it's going to again run through all of the stations basically starting from zero all the way up to 280 all right so I hope you get the basic idea now what's going to happen basically is that it's going to check one polygon one Thiessen polygon after that it's going to run through all of these rainfall stations and check and what it's going to check is that it's going to check geometrically whether any of these points are physically located within that polygon and how do you make that check and we can do that by using a simple if statement and I'm saying if if the row so basically this row corresponds to any of these so you check whether this row but then not the entire row only the element which is called the geometry all right check if for each row whether the geometry now just try to understand properly this row within brackets geometry comes from here this row is this row and that basically refers to the TC in polygons for example if I go back over here and type please in poly polygons dot columns we can see that we have object ID geometry station name okay now let's have a look at the attributes table now if I want to select this first row coming out from these four loops just think in a separate way just think separately if you want to just select either of these rows you can basically use this command this in polygon dot I lock basically this I lock command refers to the location of the index let's say I want to have a look at the location of the index 0 you can just put it over here 0 and you can get the corresponding information of that particular look at the particular row but now if you want visually see actually how this geometry column looks what you can do is you can basically use the same same line and now within brackets just specify that you don't want to see all of these columns you only want to see the geometry column okay now you can see that you were physically able to see the the object which is represented by this this geometry column which the one that actually looks a bit strange to us this is how it looks physically so if you want to go to a different row let's say you go to the let's say tenth row or something like that I mean the tenth index each index has its own row which consists of the station name geometry and object ID and I'm going to ask okay show me how the geometry column looks for that particular row you can see now each of these pieces are actually the polygon pieces that you can see over here so each of these polygon pieces are actually recorded in Geo pandas using this manner that's what we see over here so coming back to our for loop what I'm going to see over here is that I'm going to say that while you iterate through the decian polygons that means while you are iterating through each of these polygons while you're iterating through each of these polygons if the polygon dot contains switchback the meteorological stations again if the polygon contains any of these stations within that polygon so how do you write that in Python now I understand it can be a bit confusing but I suggest you to take your time in understanding this code and after you get it once it's going to be really easy to understand what's going on so I hope you understand this part clearly if Rho within brackets geometry refers to these Thiessen polygons and if any of these polygons contain the points so now I have to select the point now I have to specify the points over here so let's say that let's have a look at how those points look so I'm just going to type rainfall stations over here all right let's say that if you are if you are iterating through index 0 1 2 3 4 5 s and so on if you want to select a particular row of the rainfall stations the way that you would do is that you go dot index location and now since we are going to iterate automatically using the for loop instead of putting a number over here I'm just going to say that just use this index underscore value over here let's say that you want to see the index of let's say that you wanted to see the index of 0 you see that you have three columns the name latitude basically have four columns the name latitude longitude and the geometry so again you can see should how this geometry looks by basically typing geometry over here and you can see that it looks like a point basically what you would expect because it's a it's a point shapefile so what I'm going to do now is I'm going to copy this same command and put it within brackets over here and instead of putting zero over here now we since we are iterating through the indexes I'm just going to copy this index and put it over here now what do you need to understand over here is that this index is going running from zero up to a certain number and whenever this index is let's say ten you will have the number ten over here as well and whenever these index jumps to eleven it will be living over here so basically what we are doing over here from this row I'll comment that out is basically we are acquiring the name of rainfall station so what you are doing basically over here is actually acquiring the name of the corresponding rainfall station into the attributes table of the polygon and now let's say you do this check whether it contains any of these points you finish this line by putting putting a colon over here and if that statement is like that and if any of the polygons can any of the points fall within that polygons just pick that point if I see over here you can see this there's this new column which we created called station name which is to be filled in later so I'm just going to ask that just copy just find the name of the rainfall station just replace this to be filled in later statement from that station name so the way that you are going to do that is by saying that go to dision polygons dot location and the way to specify these entries in a Geo data frame is basically using this command you first specify the index and then specify the column that you need to fill in in this case the column name is going to be station name and make that equal to make that equal to the to the to the name of the of the rainfall station so the name of the rainfall stations actually are given using this row just copy and paste it over here that row on this code but we don't own the whole row we only want the name of the station so let's see how how the column name of the rainfall stations looks you see the column name of the rainfall station is actually by the heading name alright so I think we are most almost done with the most complex part of this of this process that is actually understanding this this code now it's not it's normal to find it a bit more confusing if you are basically new to this this for loops and the concepts of programming but I encourage you to actually take some time and then try to understand the process that's happening through this code and after that things will get much easier so what we can do now is basically just run the code by pressing f5 as you can see it's going to take it's still reading it's going to take some time for the process to happen and if you were to do this process manually definitely you can imagine how much time it would take so that's why this after we compile this code which come it's going to come in very handy even in our future uses all right now you can see that the process is completed already now let's have a look at the T seen this in polygons geodata frame the shape file dot head let's see the first 15 entries all right now you can see that the station name which was something called to be filled in later that we assigned before got filled in by the corresponding station name now that's that was pretty cool you can even see the whole geo data frame for example if you go to this first row let's go back to our chaise and check what is this first row the the polygon which is represented by the first row which is this one and if you zoom in you can see the station called Gauss is the station that's supposed to be in this polygon and if you go over here you can see that this the corresponding station name actually just got recorded over here so that's what happens from this basically this this piece of code and then but now we are not done yet completely alright now let's quickly have a look at how these Thiessen polygons shapefile looks all right now you can see that if we if you can recall how this how the the the shapefile of the district's looks this is actually extending all the way up to the boundary that we specified so now I'm going to run a basic intersect command using geo pandas and just sort of clip this whole Thiessen polygons into the boundaries basically the boundaries of the of the country of Nepal so let's do it over here now intersecting Thiessen polygons with in the districts and the intersected product I'm going to call that as intersect underscore polygon and that's going to be equal to Japan does dot overlay and now we have to specify over here which two polygons that I'm going to overlay so the first polygon that I'm going to overlay is this one these in polygons copied over here and I'm going to overlay that with the district's polygon and you just specify how you're going to do that with the method of intersection all right and then now you can run right now let's have a look at how this intersect Poli looks all right now you can even see that the intersection happens quite successfully and all right now let's also have a look at how the how the attributes table of this intersect underscore poly Lewis yeah actually I want to know the the column so basically you just type columns over here and you can see that now we have different columns which are station name district area and geometry just a quick tip if you would like to color your figure let's say based on the based on the locations based on the districts you can simply add a new command called sea map and specify that to be a color scheme and you specify the column that you would like to do the coloring based which is going to be based on let's say in this case it's going to be based on the district so you just specify that column over here and now you can see that despite of despite this intersect poly being having contained all the information of the intersected polygons still the coloring it's still the coloring happens based on the based on the locations of the district based on the boundaries of the district so that's a pretty cool trick that we can do to to visualize data now coming back to our main objective now in this intersect poly I'm just going to create a new new column in this intersect policy or data frame now I think you can recall how how to create a new column so we're going to create a new column called shape area and the way to do that is you basically select the name of your variable within square brackets you put the name of the column that you would like to like to have and now what I'm going to do is actually I'm going to calculate the areas of each of these small segments you can see after it got intersected it's not the previous polygons anymore now we have like intersected so many small intersected polygons so I'm just going to calculate the area of each of those polygons and it's going to get calculated in square meters so I'm just going to divide it by a 10 to the power 6 so that it will get recorded in square kilometres instead of square meters so basically what you do is you just take the name of this variable and type dot area but then divide the whole thing by 10 to the power 6 all right now let's run that command all right now let's have a look how this intersect Poli looks you can see that we added a new column called shape area which basically is the area in square kilometers of each of these small polygon elements of the whole of the wall figure so you can see that we have six hundred six hundred ninety nine small polygons after we did the intersection okay next what I'm going to do is actually now let's go back to the original district's shapefile this is how it looked I will look at the number of columns three which is actually the district and the area and geometry so let's say I don't want to see this geometric column so I only want to see the name of the district and the corresponding area of the district okay so what I'm going to do now is I'm going to save this particular table into a new pandas dataframe now if you check the type of the districts over here because districts by itself contains this geometric column as well so it's actually a geometric object right now which you can check from here if you if you check the type of districts now it says that it's geo data frame but I'm just going to only extract these two columns and then put that into a panda's data frame and as soon as I do that it loses its ability to visualize anymore because it's just going to be a simple table simple data frame so the way how I would do that is what I just did over here so if I press enter you know here it shows me the district and the area so I'm just going to basically copy this one and put it here and I'm going to create a new variable called district areas and that district areas is going to be a panda's data frame now in order to create a panda's data frame you have to import the library called pandas so I'm just going to import it and us and after that I'm just going to create a pandas dot data frame and basically take put this whole table using this command and put it into a panda's data frame so basically you just cut this one and then put the whole thing into a panda's data frame so that's it let's run the command and see what happens all right now let's see how this district Arius looks as we expected now even if you check the type of the district here yes it's going to be a panda's data frame now instead of being a Geo data frame right now you can see that still in this panda's data frame my index is actually an index which was specified by pandas itself which is 0 1 2 3 but now I'm just going to change this index to be the district so I don't want to have my index at 0 1 2 3 I want to have my index as the name of the district district areas dot set index and the new index column that you would like to have is district over here and in place is going to be true right now let's run again and in the meantime I'll just comment this out just to not confuse you guys this one we can say that extracting the district and area columns from the geo to a new data frame new panda's data frame though we can now check how this district areas looks all right now you can see that for the index of let's say Kathmandu what is the area in that manner we can see that our index got changed to actually the name of the district instead of having run having a number over here all right so that's also done so now let's go back to the intersected this intersect poly geo data frame now you can see that it has this shape new shape area column so the way that you would calculate the area would be for let's say each of these small polygons element you will have to check you see that this intersect poly has this columns such as station name district area and geometry so what what the program needs to is that for each of this row that means each of this small polygons element for example if we check the first row that small polygon element you have to find out which district it belongs to because you can see that there is a column called district so you can see actually which district it belongs to I think if I just type something like this would be easy to do easy to visualize district and and the shape area all right you can see that this first row belongs to this particular district and this is this the area of that small piece of polygon now this district as a whole is actually a collection of all of these small polygons and the real area of this district you can actually get it from here these are the areas of each of those districts as a whole so what so next we are going to write a small piece of code where for each row it's going to iterate through each row similar to the previous one and for each row it's going to do that let's say 699 times so for each row it's going to divide this value by the real area of this district so it's going to also refer to this this pandas dataframe in order to extract the real area of that particular district so let's see how that happens just so just to make it clear to you what it's going to do is it's going to iterate through each of these rows it's going to divide the area of this small shape by the area of this district and where do we get the area and where do we get the real area of this district this each district we are going to refer back to this district areas pandas dataframe which we just created alright so let's see how to do that so first I'm going to create a new column called weights into this intersect poly and let's specify these weights to be zero for the time being so let's run the code right now let's have a look at this intersected poly geodata frame you can see that we got a new column called weights which is specified to be zero now and then from the next step we are going to iterate through each of these rows and then we are going to be are going to fill this entry by the value that we get by dividing this corresponding to the the correct area of the district let me put a comment over here adding a new column all right then now what we are going to do is we are going to actually assign the TC and weights and the way that we are going to assign the t's in red is also using an iterative procedure and we are going to iterate over the rows of this intersect poly so similar to the previous step we are going to write a for loop let's say now we specify this as index a and Rho okay specifying the name is basically up to you in intersect poly I think you might remember each time when it iterates over the Rose how do we select each of these entries we can basically say intersecting poly and we are going to select it by the location and the index is going to click index a this value and the column that I'm going to select it's called weights so each time when it iterates this weights entry it's going to be equal to as you might guess it's going to be equal to this value and that value is selected by row a name of the column which is shape area / now we refer to this pandas dataframe that we created before which is which is this one district areas so how do you select that you can again write our district areas selected by location and let's quickly have a look at how this intersect Poli what kind of columns that we have in this intersect Poli so you have the name of the district as column as a separate column called district so what I'm going to do is i'm going i'm going to select type row a which is this one and pick the name of that district all right so that's picking the name of that district is basically going to be the index for my district areas location search so after you search the location of that index because right now you remember we converted the the district column to be my index so now we are searching by the index let's say after it runs through this row a value row a district value which means it's going to find the district's it's going it's going to find the name of each district and then but now we are referring to the district underscore area that means now we are referring to the pandas dataframe so once it finds the name so once it manages to find the name of the district we are going to assign that as the index so based on that index it's going to find the corresponding area and that's going to be the heading the heading of this column which is area all right maybe you can put a bracket to cover this whole thing just to not confuse the code right now let's run this code and see what happens now let's have a look what we have over here all right now you can see that each of the weights got recorded over here before it was a column of zeros but now we have the corresponding records now this whole thing is actually in the form of a geode a Geo data frame so what we would like to do is now to save this into let's say a CSV or something like that and first I'm going to convert this whole geo data frame into a panda's data frame so just with the just with the columns that you would that you would like to have so let's have an look at the names of the columns so I'm going to so I'm just going to create a new new data frame a new parent panda's data frame [Music] creating a panda's never from this one I'm going to call as weights it's going to be equal to lambda dot data frame and that data frame is going to be only a certain number of columns of this intersect Polly let's see I would like to have two column which is the station name also let's have the district as well as the weights all right now what you can also do is actually once we create this pandas dataframe we can save this data frame into a into a CSV file so that we can open it separately visualize it or do whatever we want later on so I'm just going to convert this into a CSV and you can specify the CSVs name let's see we can give a name like dot CSV something like that and now we can run the code again seems like can you take a while but after the process is done we will be able to actually open this CSV file using Microsoft Excel and see how it looks yeah I think it's done so let's navigate back to our main folder the main working folder I'm trying to find if there's a CSV file called TC and Bates calc it's over there right here and when I open that one and from here we can see for each district what are the contributing stations let's say for this station call let's say for this district called Salahi if I highlight this one so for this district based on our calculation there should be 1 2 3 4 5 6 7 8 stations which are the contributing station and for these stations the contribution is based on these wait ages so if I actually put it into let's say only a couple of decimal points all right so from here that we can see that the highest contribution is actually going to come from this station and the second highest is going to come from this station and basically there's going to be very minimal contribution from this station to this particular district so that's how you you that's how you read this table and if you look at another district of naval alcohol Muslim from here you can see that out of the stations which are contributing let's say in terms of rainfall to this Mustang district we can see that the highest contribution is actually coming from this rainfall station and subsequently we can see that what are the corresponding weightages that are there are of relevance for this particular district based on the rainfall stations so I think you got the basic idea of this exercise and I hope you enjoyed this tutorial if you if you got to learn something new just come in them down below let me know and if you have any questions do comment them down below as well and if you would like to try this out by yourself you can definitely do that I'll put the link to download all this data including the including the script as well down in the description below so you can either type it out or you can even just simply copy and paste and see whether you can you are able to just run this code by yourself and then do the analyst is probably by yourself so that's about it for this tutorial I hope you enjoyed and thank you very much and I'll see you in the next one
Info
Channel: GeoDelta Labs
Views: 4,857
Rating: undefined out of 5
Keywords: geopandas, pandas, python, programming, objectoriented, Anaconda, Python, GIS, Installing, GeoPandas, Pandas, gis, geospatial, arcGIS, QGIS, processing, overlay, intersect, shapefile, Json, Thiessen, Polygons, Weights, ArcMap, ArcGIS, geoprocessing, automate, thiessen polygon, weights, calculation
Id: b4BUt-spmFA
Channel Id: undefined
Length: 65min 25sec (3925 seconds)
Published: Fri Jun 14 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.