QGIS Network Analysis with Ujaval Gandhi

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
i'm going to start three two one good morning everybody and good morning um welcome to everybody joining live i'm in the chat room this is the first session of today's qgis open day we'll be speaking with uh ujvalgandi who's going to be showing us the network analysis capabilities of qgis uh i think we won't be doing like a too much question and answer format in this one it's going to be mainly demo although feel free to correct me um and uh yeah sit back and enjoy and we're gonna have a twitter force of network analysis with route 12 welcome austral uh thanks tim and uh thanks for organizing this really excited to be here we have a lot of people watching live so hello everybody it's good afternoon here but i know people are from all over the world so uh good evening good morning wherever you're joining from uh yeah as we mentioned we have plenty of time i'll be covering a lot of topics and i'll be pausing for kind of taking questions after each topic so maybe tim can kind of moderate and you know you can if you have questions feel free to type them in the chat so we can uh answer them i also have a link to this deck that i'm presenting at the end i have a lot of resources so maybe you want to get that and follow along uh the format of the talk is i'm just going to go through a whole bunch of demos with data so uh ideally you would pay attention to the talk watch if you have questions please ask them and you can replicate all of those exercises uh at your after the tokens and you'll have all the data and everything available to you great and just one sorry one housekeeping thing before you dive in is that we may the stream may drop at around an hour i don't know if it's something to do the way that uh jitsi works um but if it does just stick around we'll reconnect what usually takes a minute or two and then we'll reconnect the stream so please um yeah stick around to the end even if it drops uh somewhere around an hour all right over to youtube all right cool so let's get uh started uh i've uh my name is uh ujwal i run a training academy called spatial thoughts the website is spatialthoughts.com i also publish a lot of material uh some of you may have seen my qgis tutorials.com a lot of the material i'm covering today is already published there and i also do training on qgis python google earth engine i'm also a certified qgis trainer so i do certification trainings as well and we can talk about those later at the end if that is interest um so today i'm going to cover uh network analysis and this is a topic that's close to my heart because my master's thesis was actually on network analysis and i did that in say 2 000 uh 3 4 time frame and there was no qgis capabilities there i ended up using arc info back then and then a little bit of arcgis and come fast forward you know you know ten years later uh after qgi is three was released uh i was finally able to replicate my master's thesis in qgis and that's when i realized that qgis has come a long way and is quite mature to handle this kind of advanced network analysis tasks and that's why i started learning more about what's possible and i have uh figured out a lot of the workflows uh uh how to do network analysis using qgs so let's uh i'll first spend 10 minutes just covering the basics uh many of you may not be aware of you know what algorithms should you use how does network analysis work so i'll just give a brief overview of 10 minutes and then we'll dive right into demos so a network uh to think about it we kind of uh you can usually visualize your road network where you have certain roads and you can travel through them uh around that and uh that's a good analogy but network is a generic term it works across different types you can imagine different types of network even kind of arbitrary non-physical networks like the social network and what network is essentially it's a set of edges and nodes and if you think about the road network the the streets are the edges and when the streets intersect that's a node and once you have those uh edges and nodes you can have a network and the edges have uh typically a direction associated with them so if it's a two-way road you have a two-directional edges you have you know which way is forward which ways backward you also have a weight like you know how much is the cost of travel typically in a road network that's a travel time but you can think of there's an associate cost with that edge as i mentioned street network is the most common one but you can imagine uh for gis analysis tasks you have things like transit networks uh so you have uh bus stops which are your nodes and the routes between those stops are your edges you have railway lines and so on you also have utility network and this is a big application of gis where your gis is used to manage a lot of this utility networks like water pipelines transmission lines fiber optic cables and all of that and the same concept that you're going to learn today can be applied to those kind of networks as well so what what are the kind of problems that fall into this space of network analysis uh the first one that you most of us are familiar with you know all of us have used some kind of navigation device where we say i want to go from path a to path b give me an optimal path and the optimal path could be um just the shortest path or the fastest path or maybe it kind of minimizes certain type of cost yeah so that's a kind of routing is the fundamental problems that we can solve using network analysis another set of problems that is where a lot of the professional use of the network analysis happens is the nearest facility and you can think of logistics companies where they want to say i want to deliver this thousand packages which package goes which warehouse will deliver to which package or vice versa i want to have some facility i want to direct my you know a patient to a hospital which is the nearest hospital you went on you know you might have searched you know pizza near me and that's a kind of nearest facility point where you have a bunch of pizza places and say give me find me the the closest phone i will learn about that we also have this problem called location allocation problem and this problem is essentially when i want a new facility what is the optimal location and the optimal location could be the one that minimizes the total travel cost for all the people or it minimizes certain other costs or it maximizes my coverage area and this is again a very useful problem where you know if you're using gis in a local government or for urban planning this is an important problem that you can solve using network analysis uh service data analysis is given a facility uh how far uh from how far people can reach that facility or how far can i deliver within a certain time period and these are typically called isochrones and you can use do network analysis to figure out those problems as well and the last one is the the route optimization where you have i want to deliver x number of packages uh i have y number of vehicles each has certain capacity which vehicle should deliver package to which place in which order and this is kind of a route optimization problem and you know this is also a network analysis problem so uh how do we find out what are the algorithms for doing this network analysis uh the most common and the the most widely used network algorithm is called this dextras algorithm and this is an algorithm that allows you to find the shortest path between certain nodes while traveling along certain edges and you can see this animation that's showing how it works uh the algorithm is works on the graph theory and you will hear this word graph a lot a graph means you take your network of physical network and turn it into this network a graph of nodes and edges and once you have that you can apply this algorithm to find from starting node which node should i travel along to reach my destination in the shortest possible path and there's a nice video i found it explains how this algorithm works basically what it does it from starting node it visits each nodes computes the cost marks those nodes visited from those nodes it computes all the other nodes till it reaches all the destination and then it you know you have the total sum of the cost that it traveled and it finds the shortest cost it's a pretty robust algorithm qgis arcgis all implement this algorithm for their tools and we'll use them in all the analysis ready to play there are other algorithms that are sometimes applied in the network analysis another commonly known is the available e-star algorithm and the extras algorithm is actually a subset of a star algorithm but when you have a large network really larger extra can be quite slow or time consuming so a star is more efficient but it can uh be exact but it can be also approximate so you if you don't want the exact the most optimal path maybe the nearest one you can actually do a very optimal fast optimization using this a star algorithm there's also another problem with dextra is that you can only have positive cost so you can see this as you're traveling along the edge here each edge has a cost so maybe it's a distance or you know the time but it can only be positive in the extra but there are certain cases where you might have a negative algorithm where you'll gain some time or you'll gain some something where you if you travel on the edge so that would be a negative weight and you know there's another algorithm called melbourne fought that can deal with negative costs uh uh interesting application of bellman ford i've seen uh nowadays is kind of uh in electric vehicle charging so if you have an electric vehicle you can get a path where if you take this part maybe there's a charging station on the when you'll gain some battery life if you pick that so you can kind of see that's the kind of a negative cost problem in that if you have the slides in the notes i put on some research which shows how to apply that so one of the things that you know you commonly have to deal with is that how do i turn my network of lines which which we typically use in a gis to a network and to turn this into network we need to build something called topology topology just means relations that means the edges have to be connected properly the nodes have to be at the right place for the network to work and if your network has a road data set or the pipeline's data set with working has some topological errors that can cause problems or give you wrong cells and there are common errors uh for example bengals imagine a t junction where you know you want to have a road that's meeting another street segment but you know it's not connected exactly just a slight gap there and or when you run your routing algorithm it will not be able to turn and you know your routing will fail so those are kind of things are called dangles uh you have duplicate nodes pseudo nodes and all of this uh our problems that can be fixed qgis has many tools to help you fix that there's a tool called topology checker that comes as a built-in plug-in there's also a geometry checker plug-in that can do this there's also a grass tool called v.clean that can clean network topology i'm not going to cover those in detail but if there are questions i'll do some demos at the end of the talk on that so you take your polyline data assuming that's called a good topology then you can start uh running your network tools on them and then you can do uh solving crisis problems so let's dive in uh i'm going to demo uh routing so we're going to take a road network uh publicly available road network do a and see how we can go out from point a to point b and what are the things that we need to do and what are the tools in futures we'll do the nearest facility analysis we'll find and take a thousand address points and for each address we'll find the nearest health facility uh we'll do a location allocation problem uh this is really exciting i'm not seeing any examples of qgs being able to do this but it can and it's uh we'll do we'll try to optimize uh figure out which is the optimal new facility for waste management for a city and this also using open data sets we'll do a service area analysis and this is uh using openstreetmap data a lot of times you say i you know i don't have my own network i you know you can just use openstreetmap network can do routing on that uh will not do route optimization because that requires a bit of coding and uh it is a little more involved but i have an example in scripts uh that i'll point you to and we'll discuss more if there are questions or interest on that and i'll tell you i'll point you to resources over that and at the end of the slide the resources i'll come back to that and show you that but uh so that's all uh for now uh tim if there are any uh quick questions we can uh take them now and otherwise i'll just dive right into daniels yeah i think you can just keep on going and then we'll gather up any questions for um a little bit there were some questions about getting the presentation as a pdf you did mention you're going to share all the resources later so um yeah if you would just um remove the the little sharing bar at the bottom um before you get going as well thanks okay all right so uh let's look at this data set so this is a data set for washington dc uh in the us uh i like the data portal i downloaded their uh data set from the open data portal uh i'm just gonna share the link just give it a second so this is the where i downloaded this data set from this is the washington dc open data portal and they have a really nice wiki which explains how this data set is structured how it's maintained and how a gis user might use it so uh there is a wiki link here which explains uh the different attributes and how data structure so you can explore that but this is a street network it comes as a shapefile all of you have seen this kind of data before and you know uh the nice thing about this data set it's a shouting data set that means the the data is organized uh as a blocked level lines you can see each road is split into segments which break at each block and that means at every intersection there's a separate segment and uh this is good for routing because typically at the intersection you have you can make turns you can uh have uh you can do all this kind of routing along that if you just had a single line which doesn't break at the the intersection you in your algorithm will not be able to so there is a structure that you if you don't have your data set in the right format you can there are tools that allow you to kind of create this kind of structure but you know this is that's why we're using this block roadway dataset and this is uh used for routing for routing uh the things that we need are you know our network but also we need some attributes we need to know in which direction can we travel on the street so if i just look at a segment here and you can see there's got a lot of attributes and there's an attribute called summary direction and that uh shows in which direction can you travel on the road uh there's attribute called bd is says both directions so it's a two-way street but if there are one-way street they have uh different attributes so the first step i want to show you is that how do we visualize uh the different directions of the street and this is something that is useful to see and validate your results and see how a network looks it's not required for doing the analysis but it helps to see your results so first let's just style this data uh set in a way that we can see how all the one-way streets uh and the directions so i'm going to open the layer styling panel from here there's already a symbology here uh so i'll just create a rule-based symbology because i want the new style that i'm doing uh will be to be applied only to the one-way streets so i'll just add new rule from here and i'll apply the filter saying that uh select all the road segments which are have the directions and if i look at this attribute you can see there are four different values bd is both directions ib and ob so if you think about a street it's got an implicit direction there's a start point and an end point so when you're digitizing the data you specif you will start at a node end at a node and that's the the default direction of the line and when what ob says is that this is a one-way street outbound and that means it's a one-way street in the direction of the line so whichever line direction is the line that is the line of travel that's the direction you can travel when you are traveling on the street and ib is the opposite it's up that you can travel along the street in the opposite direction of the the line so i can just select all the street uh which are either ob or ib and this is a sql kind of syntax here in the expression we can say uh if the summary direction field is either ob or ib select those and i can turn that from simple line to a marker line symbology and you can now see all the one-way streets have this red symbol now i can say just put this point on the center point of the streets and then instead of a circle let's just do a triangle so now you can see i have an arrow that is pointing in the direction of the line that is there so that's only there on the one-way streets because i have this rule that i've specified here and this is cool you can now visualize the direction but it's not correct because this is true only if the line that is has attribute ob if it's ib that means the direction of travel is the opposite of the default direction of the line so how do we style that and fortunately qgis has this really nice thing called data defined overrides where you can apply some expressions on different styling attributes so here i can say i have the symbol and if it's ob don't do anything just keep the rotation zero if it's the opposite direction of travel rotate the symbol by 180. so i'm going to click this data defined override here and i'm going to enter this expression so if summary direction is inbound rotate it by 180 and now you can see certain uh directions flipped and now you can see all this road uh are symbolized correctly and you can see uh if there's no symbol that means two-way street if there is a direction uh triangle that's pointing in the correct direction of travel of that so now let's do some routing let's uh see how this works on the routing so i'll just i have selected a few points you can show so let's do this one and we just make this a little bigger right so you see these two points to bullseye here so i want to go from this point here to this point and you can see from our symbology that though the shortest path might be this you can't really travel because as you come here this is a one-way street you can't turn left here and so what's the optimal path maybe it's going around here or maybe it's going like this i don't know you know we let let qg has figure that out for us but the important part is that we it needs to respect the network rules that it's uh there right so how do we do routing i'm using qgis 3.16 this also works in the current ltr 3.10 but you should start preparing to switch over to 360. it's going to be ltr in in a very short while so in 316 you have uh built-in network analysis tools and that's true for 310 as well so i'm going to use this tools under network analysis it's called shortest path point to point so let me just open up the tool the tool says where is your vector layer representing network i can say this is my roadway network what type of path to calculate shortest of fastest we'll do shortest now we'll come to fastest in just a sec we'll do a shortest path let's pick a point so i'll pick a point so this is my start point and this is my end point okay uh there are some advanced parameters we need to configure that because we need to tell what are our network constraints and the constraints are that the summary direction it says what's the value for forward detection say you can travel only around this outbound value and the backward is id and we can leave the rest of the parameters like this and i can run this as i run this you can see what's happening the algorithm says it's building graph and now you know you're familiar with what is graph it's turning are taking our line network uh ryan data set and turning it into a graph with nodes and edges based on the constraint that we have given and that graph will know if i can travel from node a to b uh based on the constraints we have done and once the network is built you have you can doubt it so the most the building of the network is the or the graph is the most time consuming part oops there is we try this again start point and point i'm not sure what was wrong this works i tested this if you can spot what's wrong do let me know while it's running it well does it does it snap to the line automatically so if you if you click the start point slightly off the line will it make a difference no i think it should snap to the points let's see yeah so this one i think i just made some mistake so there's a shortest path it that they need to figure out it's not clear because it's the line it's getting merged so let me just speak this and you can see now this was the path that was found by our tool and you can see now uh this is the shortest path on this network where it didn't pick this path though it might be shorter because it's not along the network and now it found this shortest path and this is using the extras algorithm so you saw the basic route finding technique of how do we configure this network and then now we'll start applying those in a larger scalable way to solve uh more realistic problems and uh in the step-by-step instruction i also kind of take these two points plug it into google maps and you know it's the exact same direction that google maps also keep so you have your own routing engine now at your disposal to desktop and you can do routing if you wish to based on that uh let me show you another example of just routing based on uh speed so i've picked these two points here and let's say i want to travel from here to here but before that i just want to style uh add some labels to this layer where i'm going to label them using the speed so there's a speed limit attribute and you can see now there are speed limits this is 20 miles an hour here and you can see the shortest path is probably this one but here this road has a higher speed limit so you can actually travel faster and this might be the fastest route so it might be true uh we can try that so we'll run this algorithm and see what it uh gives you uh one thing to be aware of is that the network analysis tools in qgis they work in metric units so the speeds need to be in kilometers per hour so to do it right we'll convert this miles per hours into kilometers per hour before we actually start our operations and it's typically also a good idea to uh have use a projected crs in meters so you don't you know uh all this works properly but uh here at least we'll i'll show you how to convert those speeds into uh miles from miles per hour to atomic star and there's a handy uh thing in qgi as uh many of you may not have used it uh one way to do this is just to use a field calculator and say add one more column that beats the speed limit multiplies it by 1.6 and you have your speeds in kilometer but i don't want to change my source data if i associate as a shapefile it's you know it may keep changing i'm i have maybe i'm reading from a database i don't want to change my schema so qgs has this really nice thing called virtual fields so i can add a new feed to my data source but it's not it doesn't update the data that uh it adds a new column but that's saved in your qgis project and so it's a really nice way to get leverage this you know add a new column but without changing the schema that so i'm just going to use this field calculator here and you can see there's a field you'll see create a virtual field and i'll just say speed kmph and i'll pick my field called speed limit and i'll just multiply it by 1.6 and this will create a virtual field here and now instead of and you can use that what you feel just like a regular field in all the operations so i can say style it now by kilometer per hour speed so now you can see my speed uh is getting displayed in the right phone maybe i'll increase that so you can see so now let's do routing on this points and see how that works so i'll use the same algorithm shortest path and let's do the shortest path first so i'll pick this one i'll pick the second one same thing some redirection and there's an additional parameter called speed field and that i'm going to pick at the kilometer per hour speed uh when you do shortest path it's going to ignore this field but uh we'll come back and do the fastest path so let me just run this again so again it's building that graph in a typical production scenario or when you're doing this large amount of computation you don't build graph for every query you just build the graph and run your computation and you build a graph again when your network changes and typically if you're if you see any services that provide you directions they'll typically build the graph you know once a day or once a week whenever the data changes so because this is a compute intensive operation you don't want to do this for every query so now we have the shortest path this one let me style this right so this is the shortest path and it makes sense well this is the less distance but now let's just come back to the same algorithm i'm just going to change this from shortest to fastest everything else remains the same and let's see what my algorithm finds and what's happening here is that the dextra's algorithm is setting the the weight of the edge to be the travel time not the this distance and it's going to optimize the query for reducing the total travel time and that's why we need the speeds and you know the amount of distance between the two nodes and the speed that you can travel it's going to optimize for that and it's going to give you the fastest path and you can see now this one the new one that came up this is the fastest part and you can see it makes sense you can travel faster from here to here so that's the the basic concepts around how to do routing uh maybe you can do shortest fastest and you can kind of play around with that you know the the fastest the field that you use for the fastest route will not be speed maybe some other attribute and you may want to minimize the cost and the cost could be anything so you can use that in a slightly different context as well all right so uh that's the first part i'm going to now move to showing you how to do a nearest facility analysis uh but before that i want to pause for any burning questions people may have thank you javale uh yeah we have some questions from the um from the audience and the first one is from andreas neumann you asked if the result of the graph building can be cached so that the route finding would be faster in subsequent runs of the analysis yeah i think it could be as i show you the next tool uh that's part of the plugin and that basically just builds a graph and then runs thousands of queries based on the graph for that but i think it'd be a nice option to say uh you know in a single queries like this uh right now it just builds a graph again maybe if there's an option to kind of say reuse the graph it can be done and i think the python api provides a way to kind of have the graph and so you might save it to disk and read it again but yeah i think for most of the tools that we'll use in you know we don't typically do this point-to-point direction in gis analysis this is just for a quick demo if i wanted to do it but if you are doing so it's kind of poor lasting analysis that's the tools typically take care of that thank you and then robin lovelace asked on twitter um whether it's easy for this uh analysis to be scripted so that you could for example run it from the command line later yeah of course uh so this one you know i'm sure everything i'm showing goes through processing toolbox so that means if i go to my processing history uh you can see the tools that i just ran and yeah this is the command line that you can run either through your python console or there's a now a new processing tool uh desktop command line tool which you can run uh the same command and you can if you want to write some type you just script copy paste this command you know and modify this to use it so because it's going through processing interface it's just much easier and if you want to take it one step further for example you want to build a network using some fancy constraints you can actually use the the network uh library network analysis library that you just picked you just provide so you can actually do all the low level uh network building and routing yourself instead of relying on the the tools but the tools are really great i've scripted them just in open python console paste them and just do a for loop to just hydrate uh in purchases thank you and then the last question i guess similar vein from richard stoneck um is there any possibility to save the graph in qgis on disk and use it for other calculations as far as i'm aware it's not i did play around with this uh the python api and i could get the graph and i could save it i think as a blob uh or python blog and read it i think that kind of works but there's no standard format uh that qgis says without to that's something that not explode but should be possible uh but as i said you typically don't need that and maybe it's a little clear after we do the next exercise uh that you know you typically when you run the analysis you just build the graph and do all the queries and then you're done um sorry and there was one more question a couple more questions just coming in at the last minute so the other one was uh can we take the results and uh put them on the web as geojson sure this is just a line stream that you get out so you can save it as a geojson and put them out i i think this qgis is a desktop what i'm showing is a desktop tool so i don't think you can run the same tool uh and do a live query on the web but i think if the qgs server has supports the processing plugin then through that you can possibly trigger the same tools and maybe last one for this question round um so from gps brianza uh uh brian's today i don't know uh how can we set the process if we need different costs for time or speed etc for different directions uh yeah so uh i think that is right now it's supposed to supports only a single cost per edge the built-in tools too i will show you some advanced tools that you can use uh which supports all these different costs and you know it's a good question for example what if you know even in this data set there is there are different speed limits so speed limits when school time is on and speed limit when there's no school like how do you configure that you know is it you know how do you incorporate current time in the built-in tools don't do that if you need to do it there are solutions that are open source such as pg routing there's osrm all of that tools will allow you to kind of configure this in in much more detail so we'll talk about those tools also later on okay thank you i think we can stop with the questions for now when you're ready for some more i'll i'll bring them up again thanks all right great so uh keep question coming i like to keep my talks interactive you know it helps that you've uh you know taken out this time from schedule to be live so might as well make use of the peak live and make the session interactive all right so let's move on to the second set of problems that uh i want to talk about and this is where you know i don't want to do point-to-point direction i want to find i have a whole bunch of points i want to find the nearest facility to that so this is the nearest facility analysis and just to give a context of the problem here is the same washington dc network data set and i have about a thousand addresses uh in this city and the open data portal has all the address points in the city uh but i've selected a subset of thousand points and then there are some health centers uh which are uh i select about 13 health centers across the city uh where you know people can seek um uh go and seek help so now i want to find out uh that from every address every home which is the nearest health center and again this problem can be kind of you know it could be anything could be any facility could be any place and we'll see how that kind of problem works so how do we solve this problem here we know how to calculate direction from up one point to a destination so i can compute this but it may not be the shortest path it may not be the fastest path i don't know which one which center would be closest so take this point is it closer to here while network or closer to here i don't know so i need to compute the distances to every facility and then pick the one which is the lowest cost to that so that's why this is called a distance matrix analysis where you have 1000 points 13 destinations will compute 13 000 pairs where we'll say from every point we'll compute the direction to every other point and then once we have that we can just pick the minimum so that's the distance matrix analysis if you use any of the web apis like a google maps api they provide this distance matrix api and i know that you know it's one of the widely used apis by logistics companies and you know amazon for example would use certain such services where they're trying to determine you know where they should your package go and they'll just do a distance matrix query to a web service like that and most web apis here maps or open open route service all of them provide a distance matrix api so very popular kind of analysis and qgis also has capability to do a distance matrix to do this we're going to use this uh plugin called q meet three this is a a really nice plug-in i've used it a lot this is quite a mature and robust plugin it adds a lot of new network analysis capabilities so once you install this plugin and you open your processing toolbox you'll get a new set of tools here under the q3 tree folder and these are all the processing tools so again same thing but if you use this you can continue you can use them in your model script them all of that can continue to work but before we dive into network analysis i want to show you why such analysis is very valuable and why you know this kind of analysis is very important say you want to do this in a naive way where you can say let me just find the closest facility from each point based on a straight line distance and if your problem is not to travel around the network that's fine and i've actually used this kind of thing in a you know many different analysis where you can just say i have a set of points uh from one layer give me the closest point to the second layer so i will show the tool and also you know compare the results with you know what network analysis gives i search for hub there's a store called distance to nearest hub line to hub and this is a really nice simple tool it says give me your source point layer which will say i will travel from my address points to the mental health facilities and i'll say you know give me the units in meters and if i run this it's going to for every address it's going to find the nearest facility by the straight line distance it's going to ignore the network completely and you can see this works you can see now i have visually you can see this has connected all the addresses to our nearest health facility and this works but you can see the problems here look at these points take this point it says the closest facility is here but you can see there's a big part here you can't travel through that so you'll need to go all the way here and drive here so this is much longer than just connecting to this one so again this doesn't work uh it's a simple analysis but you know it breaks down where you need to use a network cost and the the analysis that i'm going to show you will actually do the correct thing and it's going to find the shortest path to the hub to the health facility along the network so i'm going to turn this off but it's useful to have this as a comparison all right so let's do this analysis we have the q a three plugin installed and i'm going to expand this and there's a distance matrix tool there are a bunch of tools we'll use this one called od matrix ode stands for origin destination and we're going to do an od matrix from layers as lines it's going to ask if this tool is very familiar to the built-in network analysis tool it just builds on top of that and gives you some additional functionality so the network layer is the roadway block layer the from point here is the trace point so these are the thousand points so if i want from each of those thousand points uh uh directions to the all the destinations and it needs to it needs a unique id uh just so that in the output layer you'll get uh those points referenced by this unique id and so you can later join the attributes using that field if you need to and the two point also has this object id and then we're gonna do optimization using shortest path uh there's a new thing called entry cost and this is important because you can see each of your address points they are not on the network so they need to be snapped to the network or there should be a you need to travel to the nearest edge and then do the network so that is a cost so that's a distance so how do you want to compute that distance and you know you can uh the default is ellipsoidal uh uh or planar and we have our data in our geographic crs so we'll use ellipsoidal if you are using a projected crs you may you can use the the planar calculation direction field we're going to set the same direction field here so it respects the one ways while doing the routing and another important parameter that we need here is this topology tolerance and what happens is in this case there are uh certain points which uh cannot be uh because of where they are located you cannot find any route to any destination because it's not possible to do that maybe the this dataset also contains some mistakes where you know there are certain gaps in the layers so you can specify a small tolerance so uh when it encounters some topological error or there's a gap it will assume that okay if there's within the tolerance i can jump that gap and still continue routing so i'm going to do you know very small one um uh you can specify a large one what will happen is if there are real gaps in your layer where you know it'll jump from one street to the next street because it thinks that's part of the tolerance so make sure you keep it small uh ideally you start with zero see if some of the points fail and then increase the tolerance so i did a bit of challenge and this kind of works on this one so if you're using meters i typically use like 10 meters or 5 meters as a tolerance it's a good enough tolerance to overcome minor errors there and when you click run uh what is going to happen is we're going to build the graph and then it's going to run 13 000 iterations of the direction of it on uh 13 you know uh 1000 points 13 destinations going to create those uh competitions will run this i'm not going to run this now it takes about five minutes but i encourage you to go and run it to see what happens it's just building the graph once and then running 13 000 iterations on that and you get your results there so once you run this uh it takes about five minutes on a machine and you get your matrix layer like this so output of this tool is like you know you get a output like this and you can see this is a lot of the lot of edges right because it's from every point to every point it's connected let me show you the attribute table of that an attribute table looks like this from every origin id you can see this is the id the source id is one of the addresses it's computed 13 distances and this is the total cost you can see there's an entry cost snapping to the network routing our network this is in meters what is the distance and the exit cost because even the destinations are not exactly on the network so it computes the nearest the straight line distance from the network to that road and adds that so this is a total cost and now you can see from each origin which is the destination and each of them and you can visually see okay i can now see though this is the lowest cost so now for this address facility id one is the closest one and since there are 13 000 uh i can't manually do all of that so we'll filter out this layer and select only the the minimum um base on that now how do we do that you know how we have you know it is a many ways to approach this one easy way and that works in a processing toolbox is just to apply a simple sql query and uh now the processor toolbox now has a tool processing tool that can apply arbitrary sql queries on your vector layer so now you can be part of a model and you can automate that so i'm going to show you uh how to kind of select that and what we're trying to do is just say for each pair select the min the pair that is a minimum distance and that's easiest to do in sql uh settings so i'm going to just you know pick up this query and run this on this layer so if i search for sql i get this new tool called uh execute sql and i can select the input i want to run this on the distance matrix and what's the query and query is select origin destination and this is the key part where it says select the minimum total cost so select the pair which is the minimum cost group them by origin id and input one refers to the input we selected and since this is also a vector layer we say select the geometry as well and then i can say you know my output should not be just a table but it should be a line layer so now i can run this and it will filter out and give me the all the queries here so now you can see from the results here you have it is connected each point address point to the nearest hub and the distance it is the routing is along the network and how can you tell look compare it with our hub distance so this was the straight line distance and you can see the difference now these points it doesn't connect here because the nearest hub is here interestingly look at this part i was first time i saw this result so i was like this says something wrong because you can see this point here it's so close to this point but it's connected here because if you look at the network path the because there is no path here it has to go all the way like this here and that is longer than the one here so in your uh i have a step-by-step instructions here and you know if you you can get the data set and the same routing here and show that they're the end here that you can see from this path though this is so close if you have to travel all along this end this is five kilometers versus you know less than five kilometers to this facility so it connects that and that's a really useful uh analysis so this is a your exact analysis uh that you can you've done to find the nearest facility and the output is just your id of each address id of the facility and then you caught this and now you can imagine the power of this analysis in just five minutes in your desktop and open source software you are able to find the closest facility of you know thousand points and you can kind of use this for a whole bunch of interesting analysis and this is also you know called kind of a location analysis where you can say you know what is the nearest fire station what is the nearest hospital to each place and so on and so forth all right so we've finished uh the nearest facility analysis i'm going to move on to the location allocation problem and you know i'll show that next but i'm going to pause for a second and you know take questions uh yes so we have some questions um just a comment from clements raffler who is the author of the qnet 3 plugin who's busy watching and he just said i'm so excited to see cuny 3 used in a live tutorial i didn't imagine that it would ever get this far when i started the plugin as my personal pro python hacking project in 2017 thank you uchival gandhi so just an appreciation it's a wonderful plugin and you know it's a really nice and i have a few feature requests coming your way and then we have some questions uh from deepak uh gupta i don't know how to pronounce your name properly sorry um we do the same analysis can we do the same analysis for one origin to multiple destinations sure just flip the your the data you choose as your original destination i think it should work similarly because it's a distance matrix so it doesn't matter what you choose as your original destination so yeah okay and then i'm apologizing to everybody for if i mispronounce your names because some of them are quite difficult for me so this one is from tula loop esther um and once he or she wants to know what happens if the two locations defined do not fall on the road but away from it will the link be connected uh yeah so that is uh it just snaps to the nearest edge on the network so that will be a straight line distance to the nearest edge you can kind of see that in this uh screen shot if i can just show that so if you see here uh there this the nearest road is here this health facility is not connected so there is this there's a connection here and that's your exit cost or entry cost that's added to your total cost and that's what it is and if you're doing this it may also help just snapping the your original destination to the nearest edge of the road and you can snap it using whatever is appropriate for your use case and just use that so then there'll be zero entry and exit cost but right now it's just a straight line distance that it uses okay um then the next question is from andreas neumann and he wants to know what units are used for the topology tolerance i guess they're the map units so yeah so that'll be the layer units so in the next example i'm going to use a projected crs and that's in meter so that'll be meters here this data set comes in as a let along the eps34326 so that is degrees and i typically don't like to work in degrees because it's easier to imagine or have units which are in meters but i just didn't want to add an additional step on this and all the network analysis then we use this uh meters as units so uh so can you just clarify is it the layer the the layer units or the map cameras and then the next one is from again i'm going to struggle with your name erwin o mahoney um and they ask the default speed of in this tool are they preset for modes i don't completely understand the question maybe that makes sense to you yeah so uh if you looked at the two let me just open up the history and when i ran this tool i'm sorry let's go back to that and at the bottom in the advanced parameters you see there is a default default speed here and the default speed is something that if your feed direction that you specify is doesn't have any speeds what speed should you consider and uh so you can set it to whatever you want and typically you don't mix routing between different modes of travel so maybe walking or traveling uh you have a separate graphs uh and we'll see that uh when you do the last exercise that you can actually build different graphs for different kind of modes and you can set different speeds so you can say the default speed of walking is five kilometers an hour but default speed of driving might be 20 kilometers an hour and that can um you know change depending on the graph you build so a single craft can serve a single mode of travel okay thank you and then maybe the last question for this round is from stelios vitalis and he asked is there a way to penalize nodes for example to avoid many turns uh not in this uh i think the one way to i think there's no node uh node weights as of now and i can see where the question might be useful i read uh that ups the delivery company in u.s that delivers packages they have actually in the routing software they have a penalty for uh a right turn where you know they actually encourage people to take left turns because they are free and you know you you know you can save a lot of time so even if you the extension is right there they'll just say make two make three right turns and stuff for a single left turn so i can i think those kind of logic can be built into a routing algorithm the default tools here i don't think there's a way to specify that but as you know uh there are open source routing engines that i'll cover in the last part and i can you know those can be configured to have those kind of advanced constraints okay thanks so there's a lot more questions coming in i'll make a note of them all and i don't know if we'll have time to go through them all but uh as we get a chance we'll just you know cover what we can sure yeah i'll cover the the next bit and then we'll take more and if then you know if you have time we'll take all these questions right all right so moving on to uh the another analysis this is the location allocation analysis and this time we are working with the data from city of cape town and i'm just going to show the portal i uh i for all my trainings and analysis i use all open data so a big shout out to all agencies and folks who end up publishing the data open it really helps uh people like me and other citizens to use this data so this is the city of cape town in south africa they are really nice open data portal and a lot of the city data is shared and that's helped me develop this exercise uh and that is a real world exercise uh which the cities or planning ages can use so i'll show you the setup a little bit uh let me just turn off all the layers so this is the road network that the city has published in a city center line network and this is the greater cape town area and they have uh the problem they're trying to solve is that there are a bunch of waste management facilities and those facilities accept based from users and here in city of cape town they have this base collection facilities where citizens can go and drop off facilities uh so maybe not the household waste person garden waste or maybe you have large furniture you want to dump it you don't dump it on the street you go to this based management facility and drop it off and so they have a bunch of this uh facilities across the city and then they have all this uh places all where they collect ways so each of this the point represents the centroid of each small region which is a waste management unit which they call uh refuse collection beats and these are uh this is a for example this point represents the collection of group of houses here which all have a a waste pickup schedule and they are all grouped to this point so this points are the centroids of those polygons and in this analysis they represent the the demand points which is this is where citizens are and they need to access these facilities uh for this analysis i'm going to assume that each point represents equal number of people or equal number of demand but if you have data on you know how many houses are there and you want to group them or if you have a demand weight assigned to it you can use that in that right now we are assuming that each of this point is an equal weighted thing and here the stars are all the facilities uh which are the waste uh dropper facilities and this is again from the open data portal these are the current facilities you can see they are scattered throughout the city mostly you know you can see there are facilities close to a lot of areas and you can find the one that's closest to you and drop your waste there so but you can see here that there is a large region here without any facilities and maybe as a city planner you are trying to build a new facility and say where should i put a new facility uh which is gonna help citizens save time and you know this is a quite large area where should we put so i have created this two proposals so you can see there's a proposal one which is let's put a facility here and see you know if that is better or not and the proposal two is a facility here and just visually you can't tell because you know we don't know which one will result in lesser travel time collectively for all the citizens so this is the kind of analysis that is kind of choosing the optimal location that needs this network analysis and you can do this with n number of facilities you can have uh these are in the location allocation terms this is all your candidate facilities you can have a list of candidate facilities you have demand points and then you can optimize so i'm going to show you one flavor of the location allocation problem we are we are minimizing the total cumulative travel cost and we'll select the facility which is the least travel cost for all citizens there are many flavors of things you can do you can say i want to maximize you know the number of people who can travel i can maximize the area i can reach and you know there are ways to do this and once i go through the analysis you'll i'll explain where you can tweak and see what different kind of analysis you can do so uh the setup this is the setup now i have this two layers proposal one and proposal two and which facility is ideal so let's do the network analysis the analysis is very similar to the last exercise so i do my distance matrix between all my demand points to the proposal one demand points uh to proposal two and i get two distance matrices and then i filter it out to the shortest path and what i get uh which i've already done but you can kind of do this yourself it's the exact same process as the last time we did and then i have uh two allocations proposals okay so actually actually i already have those so i'm going to remove this so if i did the distance matrix from uh by using my destination as the proposed using the proposed facility one including all the other existing facilities i get this kind of graph where you can say for this point they now they can travel to this new facility you can see there is no facility two here it's just okay i'll just wait for the room to just confirm me back again um okay as i mentioned at the start we had this sort of one hour cut off um we should be back if somebody in the chat could just confirm that they can hear us again okay we're good to go again thank you for your patience everybody all right so let's pick up where we left off so here is the the network analysis the distance matrix results by considering the existing facilities and including the new facility one and now i have got the network distances from each of these demand points the facility and this is what it visually looks like but if i do the same analysis again and include only the existing facilities and the proposed facility number two this is what my allocation looks like and you can see now that people here there's no new facility one here so they need to travel to this facility and now i have these two competing proposals and i have found what is the cumulative travel time for all of that and i can select this one now how do i pick uh how do i compute the cumulative travel time so this is just a layer you can see this is just a layer where each point has a shortest distance so i can just sum up the total distance and that will be my cumulative distance so there's this nice little tool qgis has called statistical summary i can just use that and say pick the proposal one and show me the shortest distance somebody maybe i'll divide it by a thousand so i can show you the kilometers so you say the sum is 2765 kilometers so in total if you assume one person per demand point in total with the proposal one they need to travel 2765 kilometers uh if they need to travel to reach the facility once and if you have if you know the number of people per node you can just multiply that and use you know use that here so this is the the proposal one two seven six five for proposal two if you see that one it is two seven zero six so it's a lesser travel time and that means the proposal too is would save more time for citizens compared to the proposal one and that means the proposal too is where you should build this new facility if you want to cumulatively save time for people so this is uh one way to do this analysis i've seen the analysis having constraints such as oh people should not travel more than five kilometers so then you start you know you can filter out all the lengths which are less than greater than five kilometers and then you know continue analysis that way so you can kind of add this uh there are for example if you use arcgis rock pro they have the network analysis kind of packages up in a nice tool where you can configure different things and it runs this qgis doesn't have the nice packaging but all the underlying functionality is there and you can kind of build on that you can keep building a model keep applying filters and you should be able to arrive at the same kind of results in qgis and this is an example of just with two facilities you can do this with multiple facilities as well so i'm going to pause now and just take questions all right thank you so um the first question is from someone who goes by the initials rk and he wants to know can we do nearest facility analysis from any tool inside the network analysis tool without using the cuny plugin uh right now the default one doesn't have a distance matrix uh functionality so we need to use this if you were to keeping to use that you can use the built-in routing and then script that and that essentially is the same what the plugin does we're just running the same underlying analysis functionality for each of the origin destination players okay thank you and then mohammed khalid is asking he's wondering how to formulate the condition to solve for tls reaching for the shortest path with the consolidation of visiting specific points oh that's that's about optimization the traveling salesman problem i'm i'm assuming i guess so yeah yeah so i think that we're going to i'm going to show an example of that and you know that's a route optimization problem and you can't do that with qgis yet but there is a way to do this i'll show you with that okay and then tuamas vice and then i'm sorry about your name pronunciation again um it would be really nice if qgis could use networks built elsewhere for example in python tools like network x or igraph is there such a feature planned i'm not aware of able to use the external networks but i assume it will be useful to use that because there is a growing number of network analysis library on the python side and network x is great and there's things like osr and stuff and how i've used them i'll show an example of how you use the library osrm which is a really powerful routing engine uh within qgis you can do some uh just with a little bit of processing script and connect to that and use it that way so i use it that way but i can see the value in having that as importing that graph and routing of that but i don't know if that's planned maybe the developers in the chat came yeah we have some of the core developers in the in the chat stream as well so maybe they can mention anything they know about that there and then deepak gupta is asking can we differentiate the result based on the terrain conditions uh yeah so that to do this on terrain conditions there are ways to do this one way which i've done recently where you can actually uh have a dem at the bottom and you take your road network and sample dm at regular intervals every 10 meters you sample that and for every edge you assign the average change in elevation and so now you have an attribute which is say for this segment the change in elevation is x amount and that's a cost so now you can do a routing and this was a project where you know you were doing you're doing routing on bicyclic so the bicycling if you're climbing uphill it's a much harder route than a flat terrain so we would want to do an optimal bicycle routing and then the cost of the network was the elevation change so you can kind of you know take the dm incorporate that and use that as an attribute that you can now give as your cost and then it will optimize to save that cost and give you a bike optimal route another way to do this would be to do a routing on the raster side where you just say give two points on a raster and you'll find the optimal path by avoiding the finding the least path for each pixel and that's a routing on the the raster side uh we are talking about the vector side so raster tools are you know separate and we'll talk about the raster routing they're typically used for example recently i had one of the students uh she wanted to do routing along in the ocean where he said i have two points in the ocean find me the shortest path but avoiding all the land because she was striking marine animals and she ended up using the raster routing where you just have a roster with the land and say avoid all the land and find the optimal path so there are ways to do routing on the raster side but you know this is completely different from the network those are not networks those are kind of you know raster grids where you can optimize costs maybe uh there were some other questions but i'll keep them for the next session just a couple of notes as well uh just uh we had some people joining from mexico who woke up at 3am to watch your talk so just uh greetings to mauricio marquez and luca bellani and i'm going to just okay are you there still you're dropped off so okay okay i'll be back um i think we can continue so i'm going to do the the last bit of problem which is the service area analysis and this is where the network analysis becomes really exciting uh for me because now i'm going to show you a way to leverage a lot of the web services uh for doing routing and you know a lot of the problems that you know people had uh will how do i build my network how to explain the topology all of this go away so now i'm going to show uh the problem that i'm going to show you is this is a metro station network this is a city in south india called kochi and this is the kochi metro line uh this was a shout out to the team there one of the first cities to really openly share the transit data in india and you know they this is from their open data portal and they have the metro stops and the metro line here and uh what i want to show you is i want to determine the service area of this metro network how many what people in the city can access this metro and you know is that a gap if you're planning for a new station where should we put it and those kind of analysis and uh typically if you're considering a metro you want it to be walkable so we'll say in what areas from the city uh people can walk to the station within 15 minutes and use that and that will be the service area so uh just to kind of add context uh i don't have any network i'm not going to have any network data this is all it is but i want to do network analysis and this is the case in many cities where you know the cities either don't have this data don't maintain it or they don't share it so if you're in such areas uh how can you do network analysis the great thing is we all have a really nice routable open database of the world and that is the openstreetmap database so there are services that allow you to do routing on top of openstreetmap database and you know you don't need to download even download this data all of this happens as a service so first i'm just going to add my uh a base map osm uh so this is just tiles so this is this there's no data here this is the tiles just to give context to our analysis and i'm going to use another plugin here and this is if people ask me what's my favorite plugin in qgis and this has to be this plugin called ors tools uh ors stands for open route service this is a university project they offer a routing api built on openstreetmap network and they offer it as a free service they also have this nice little tool called ors tools which again gives you processing tools to do network analysis on that i want to quickly show you their website open down service and this is the service that can do a lot of this analysis they can do directions isochrones distance matrix geocoding pois they can also do optimization the traveling salesman so i will i'll tell you how to use this api for traveling salesman probably but they can do all our this problems and you know you can go sign up for a free api key and once you come to qgs you install your plugin go here go to settings put in your key and the key is required because since it's a free service they want to limit the amount of load on the server so you have certain rate limit you can't send too many queries and you have certain daily limits but uh it works quite well for even within those limits so once i install ors tools i have all these tools here and you can see all the the usual suspects i have directions i have distance matrix i have isochrones so if i wanted to do a distance matrix now for with some data i don't even need a network i can just say use open street network and openstreet network data is you know uh for the risk topology it's called turn restrictions lane restrictions all this time restrictions and the os tools will just use all of them and use the really accurate routing based on that without even downloading data so i'm going to show you this tool called isochrones isochrones the word means the areas of equal time clone is time so this is the tool where it can you know give you for each point it can give you which is the how much far you can travel in a certain time or a distance so i'll use this tool called isochrones from layer and you can see there is no network here it says i'm just going to use open route service take my stops layer get some unique id and the driving mode so here as i mentioned there are different modes of travel and there is a different graph for each of those and you know you are specifying what graph you want to use so i'm going to say i want to walking directions and in 15 minutes so the dimension is time or distance i can say show me all the areas of the city that are accessible by 15 minutes of walk from each of the stations and look at what happens when i run when i'm running it it's just sending this query to this opened out service you uh and i'm getting the results back there was no data that was downloaded there was no analysis that ran on the computer and that's why it's really fast and out comes this polygons and these are all the isochrones uh for each station and you can see they are not buffers they are not just plain buffers they are actually around the network so that's why if you can see there's a path around the river you can't go very far here if there's a road you can actually travel much faster versus there's no road here so now in just a few seconds with no data of my own i was able to run this and this analysis can be done any part of the world uh and that's a great thing about openstreetmap and services like open route service that allow you to do this analysis and if you want to do distance matrix come here and run the distance matrix no need to configure one ways and your own using your own cpu just runs on the service there are limitations if you're running this on a data there is a limit of 40 queries per second per minute so that means if your layer has a thousand points and you run it the tool will run after 40 queries it'll say uh you have exceeded a quota so don't worry don't stop your tool let it run as one minute passes it's going to send 40 more requests and you know it's going to continue so you know because because of the rate limiting the tool will have to wait for a certain time if you're sending a lot of data and same case with other things so it will still work i have done this analysis up to you know thousands of points you just have to wait for the rate limiting to comply with that if you are doing this large scale analysis you can actually run open route service in a docker environment locally there are also solutions like osrn which you can run locally and run a whole bunch of queries without this rate limit but if you just want to use this tool this is really great free tool to use this kind of analysis and there are other tools in the uh plugins there's a plugin called uh hqgis which is the here maps api and but again here maps api has a commercial term in the terms of service so you need to make sure you comply with those terms of service this one is based on openstreetmap you can actually do use it commercially without any issues so that's the last bit of analysis i want to show you next i'm going to talk about you know how what can you do with more advanced routing engines using python and how can you connect using qgis but this is the end of the demo for this part uh any quick question i can uh do this i can take and then i'll move on to the python tools [Music] um so there's just the one question from the cardinal um he says if we don't have candidate points to start but need to find one then theoretically i need to run the same with many random candidate points typically you know if you're doing this in a real world scenario you in a city you typically don't have you have a limited set of points so you can't just put random points so typically what you would do is which is the empty land and you know or select the parcels that are vacant and you know put a centroid of those parsers centroids and then run this kind of optimization analysis on that so usually start with a set of candidate points it just doesn't work without a set of those okay that's it from the questions for now for this one all right okay so now i'm going to uh show you some examples of uh traveling salesman problem we had this uh question on how to do traveling salesman problem and also um you know i'm going to show you this routing engine called osrn so project osrn is the website it's an open source routing machine it's a really uh nice uh open source routing engine that can do a whole bunch of things so it can do all the stuff we talked about you can do isochrones routing all of that and all based on openstreetmap data so this is written in c plus plus but you know you can just run it uh within your in your own system and uh done so how i've used this in the past one is a recent project where uh i'm sure that um and the link to this is in the in the resources section so this is the um so this is a project i worked on uh where i wanted to do travel trying prediction uh using the openstreetmap data and also the uber movements uber has shared this data called uber movement where they share aggregated anonymous normalized travel time data for all the cities the operating really rich data said one of the my favorite big open data sets that you can use and so one key thing that's missing from openstreetmap is that live traffic for historic traffic data and especially in developing countries there is no such information so we combine the state as uber's historic data of travel times and combine the open street map and figure out a build a machine learning model to say which is the uh you know predicted travel time so given if i start 5 pm on tuesday from this point at this point what is the travel time and we got really good results compared to say commercial services like google maps so how did we do this uh one of the things we needed to do for training our machine learning model was we had all these points we needed to compute about 50 000 uh or origin destination pairs and we need to get a distance between those along the network and we need to do it quickly for very different kind of models so you know what we end up doing was uh running this osrm server locally so they have a docker image you install docker locally run this and then you get this docker running locally in this url and then you write a simple python function which sends the request to that you know source light long destination that long are the parameters and it returns the full route along with the distance and we use that and this was for 40 000 coordinates this takes like five minutes it's a really fast local machine and i have instructions on on how to install and run this docker image uh even if you not use docker before i've had people run this successfully when you were never familiar with docker but just follow these instructions you'll have it running another thing that you can do with osram is this uh something called route matching so a common problem if you are have a lot of the gps tracks if your gps tracks is that they are they don't snap to the road network so this is a uh me on my bike collecting with gps track and i'm traveling on this road but the road points are because of the gps errors they're not in the right place and if i want to compute the distance or if you're a cad company trying to compute a fair uh you don't want to use this noisy data you want it what's it you know snap this points to the root and it might seem a simple problem but it's actually a complex problem because where do i snap this point here here and that really depends on your the points previously the trajectory and all of that so osirim actually gives an as a nice function you can say take my gps track and snap it to the openstreetmap network and this is what i show in the blog post how to just run osram service locally just run this commands and then you know what i do is i write a simple processing script in qgis so i create a qgis script which now runs and gives you two like this which says where is your os arm url which is your input vector layer of gps points and out comes a snapped uh polyline there and this is all because it's osrem is doing the heavy lifting doing the snapping and we just get the results format there's a qgis vector layer and use that so similarly you can use kind of write some pique script to call osrn and do this really sophisticated type of analysis uh using osr the last bit i want to show is the uh let me just pull up my it's a traveling safety problem sorry about the background noise if you're hitting there's a construction going on here just started this morning so i was caught off guard with that uh all right so in your deck uh we'll add the link to this in the description tim has already sent you the link to this deck there are resources here so these are the step-by-step guides so if i just show you this one this is based on published on the qgs tutorials site you can download the data follow the step by step and you can replicate everything i showed today uh on your own uh the osrm is here the links i showed you the traveling salesman problem so now as i mentioned this opened out service provides you with uh this optimization api and i teach a python class where i teach how to use open route service api and how to you know do this so in this intro to python class uh one of my participants he ended up uh using this optimization api and he built this example and it's a kind of fun example what he's you know trying to show is that how easy it is and how accessible uh it is to now do this out optimization and he's saying that oh i have this task where i want to meet usual i'm you know but i want to do this task i want to fedex the package fill up my gas and do this and i want to meet them with him in what order should i visit all these places so that i can have a most optimal route and he in this example shows how to configure your api request and at the end you just run this and you get this you have all these points and say you know i want to go from here to here but in what order should i visit should i visit here and here and here or which is the least network cost and then you do this analysis and the opened out service api optimization api will solve this traveling salesman problem for you and you get this you know output here which is the optimal route and the api is quite rich it can specify how many vehicles you have what is the capacity of each vehicle what is the amount of things you are picking up at each destination so if you think about a waste management thing i have to collect waste i have fleet of hundred vehicles i have this demand points i know this area has generates a lot of waste how should i deploy them in what order which vehicle should go where uh this can solve that but since the problem formulation is quite complex and the output also it's not straight forward because in this case it's straightforward but if you have this in 100 vehicles what should be the output so i think that's why it is much more accessible using python uh but i have linked to the example here where you can say our outcome is using the openhouse service you can look at the python script uh and try to implement on google maps if you want to use google maps google maps also provides an output optimization service they solve the traveling salesman problem using the google maps api this is a commercial solution but you know people often asked how to do this in a commercial setting maybe the routing data in the region they're working is not as good uh so they want to use the commercial service so this is an example google maps uh has for uh solving the targeting system problem and i want to conclude by showing you what are the tools available for the kind of networks we mostly talked about road networks i primarily work on the road transportation side but if you're working on the water side there's a nice few water plugging there's a new gis water plug-in all of them use postgres database in the pg routing engine to do uh water uh like pipeline management there are a lot more different problems you have valves and your flows of water and all of that but the pg routing engine is uh can solve all of that for fiber network you know i've seen huge demand for people doing uh fiber laying networking they want to optimize for that so all of this you can do i've done kind of a smaller version of this locally they'll just build some python scripts and use the built-in network tools but there are uh this one this company provides a commercial plug-in based on qgis that can actually do uh uses underlying routing api to do fiber network planning so again check out those plugins if you're working on any of this space and you can continue with that sorry that's all the content i had today uh thanks for watching us we still have five minutes so i can take more questions um actually because we've got the next stream starting at in five minutes so i actually i think we need to stop now we did manage to get through a lot of questions during the talk and of course you're a wonderfully friendly and available person if people have more questions they can surely contact you on your on your website and maybe you want to buy the ama i'll be available in the emulator today so you can ask me yeah she's there so we can carry any questions over uh just a huge thank you from me it's been an awesome tour the force of the qgis network capabilities and thanks to all the developers and contributors who made all those tools uh obviously there's a lot of work gone into to putting all that functionality in place in qgis so um and great thank you to the um audience been really participative and uh it's really nice having all your feedback and questions during the during the session thanks for uh open day it's been really fun thanks to the audience uh look forward to interacting with you more i'll be available later today for the ask you anything so ask questions or email me the email is on the website and i'll be happy to answer any questions thank you all right all right thank you thank you everybody bye you
Info
Channel: Kartoza
Views: 7,317
Rating: 4.9856629 out of 5
Keywords:
Id: fL7udaJQEm8
Channel Id: undefined
Length: 87min 21sec (5241 seconds)
Published: Fri Jan 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.