Vector to raster conversion in QGIS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and this video I will look at doing a vector to raster conversion in cookus so although this might seem as a really simple thing to do there are some details that are so annoying if you get wrong so you know let's look at those details and hopefully your life of converting vector to raster incubus will be much easier so if I switch to QGIS and just get rid of me we can see I have to pay as I can work with here I have a you got rid of my layers hmm you and pedals and yes so I got my Victor Lea I'm a raster layer here and I know that I'll be using this vector layer to give the raster layer was a later operations so it's important that when I convert my Victor to raster that the rest that I create matches the cells cell size not only the cell size and coordinate system but also exactly where the borders of the cells are located so ever when I do have conversion so I we can of course do it from the raster and then we could do conversion and ways to pasteurize here how often prefer to do it oh yeah so we will be on the G Dale and Victor conversion and here we have different versions that can be can burn into an existing so if you really want to be sure that things are working right you know use one of these but this one that converts a Victor Torres don't be fine if we do it right so we have our buildings you can now type a attribute from the the a our town so the if ID or something like that tests are made we can only write insecure values so be careful that you know if you want to what had to be learned has to be and it's in 2k attribute so but in this case I just wanted to buy create a true/false layer so true where there's a building so I'll have one the unit's is where do I know about the size of these units are so if we look in our layer here and properties on it now one day information it says up there here but the coordinate system is but interesting here is that has a pixel size of 0.4 meters so that's what the information I want to need for this so I can now go and do my a version I say one and my unit is that you referenced and they are Oh Boyd Oh and 0.4 and my extent and this is a really important part so now I sit the size as the same as in my the one I want to match roof but I also have to ensure that an extent is exactly the same so be sure to choose the extent of the Restylane want to come work with later so go under use the egg step and then choose extent of the raster layer you want to work with so now I've set this one and I can write a if I need a no data I can put in no there's our value in I can also what I really want is I want this to be a true/false layer if I just run it is it now I will have a true no data one and no data but if I change this one to a zero and I can sit I integral yeah so now this is just because it's it's always a problem of there's more values that that if you can avoid them please do that it's a makes life better because exactly one in exactly two might be difficult to get in hey did some more value so I prefer to have them as in because if I'm knowing I mean I don't need the dismal values so in Zuka and I'm writing down a zero so all cells will be first set to zero and then those that are buildings will be updated to a one so that's a a little advanced thing you can do it and then we can run our little process here and we have now rasterized our buildings the trick we can see is that I go in and now change the way that is symbolized if I go and save properties because this no longer needs to be a single layer gray as photographs sound like data it's going to be a pelleted because there's only some unique values so I say hey let's add unique values classify gives me the 1 and the 0 I can now remove the 0 so I only got the ones and say ok and what we hopefully now can see if i zoom into somebody little tricky corner is that these raster cells exactly line up of the pasture cells in my digital surface model so because I used exactly the same size of cells and the exact same same extent then the cells will match so that's important part to watch out for when you do this make sure you have exactly the same extent and cell size you can see here that there is some different ways of converting here you might wonder why this one is not a building that's because what chookies does is convert says if the center point falls outside this one center point is this there so even though this might be more than 50% it will not be converted to a building raster because the center point of this cell is outside in when we do this type of conversion there are some some different rules so what the standard is that you use the center of the cell and that's good approach because you don't who estimate any values on the estimate any because it's smallest random if the center point is in it you can if you're using our chess bow you can choose that the largest one for the largest area so if you have two polygons weights or polygons then the one with the largest air when the cell moving you can also have a if you have many different you can have the maximum and so on and there's also a highest priority to geez only a center one but we can do things so if we want to make sure that we have that it's just a corner or half of it is when we can do a little trick this trick is first to do our conversion at a fraction of the desired size so instance since they have a view point for having 0.1 then we can resample the data move statistics what resample does is added we sample some from the quarter-sized to the original size but then sums up the values in the quarter so that means that if all of how publican was a building then it will have a value of 16 if only one port of it was the core is in both dimensions over there 16 of them even if only one yield corner is part then it would be 1 and once we've done that we can use our raster calculator we've been using earlier to do a conversion to a true/false layer by comparing the value in our example of say if it's larger than 8 and that's more than half if it's a large strictly larger and seven then it's half or more enough so that's you know the different variations we have you can see if it's larger than one than any if just part of it is in a vector then it will be converted to how raster or you can say larger than fifteen and then all of our cell has to be win our victor for it to be a raster so let's try that in the qgs so if we go back here and do our best of eyes again on our buildings and we again what use a value of one and you'll against it and two Geographic and this time you will set them to 0.1 so open one and 0.1 again very important make sure that they extent is something that matches and that this fraction one it is a fraction so it fits to our side layer again we can set a and no value don't really need it and we will set as 0 and we will convert it to in tickets sir we know better than tiny a bit up here so this one was our original have you rasterized to 0.4 so let's call it all point four and this one must be pasteurized to Oh point one so we can see that if I drag this one on top that these are four times larger than that ones so how are we done this we can do all these samples that yes ty you can seize from the grass just time resampling said yeah I just take it from my shortcuts and are now as my input used my rasterizer by one I will tell you to calculate the sum and it aggregates and I want my output to be that one this one down here I want to be 0.45 said I want to aggregate to 0.4 and I want to calculate the sum I'm going to do the echo gage you you so it's done that and you now see I have this layer which has same size and now I have different values in here so this now I've created my aggregated has values between I get up top here that is between 0 and 16 so in the buildings see that I can bring the buildings up and maybe change some energy to just have a what I wanted I just wanted to say and a brush and a line sir so he now can see the outline so everything now in this aggregated layer you can say that this cell here at them this corner here I know a gated buildings but my resampled yeah he's there and it had a value of 6 so this one had six of the quarters in it I was part of it and when I want this corner to be part of my new buildings I can when I do my raster calculator I can find my raster calculator and I can use my resampling aggregated I can say okay if more than five so that is if more than 5/16 of a cell is inside the building or I could save more than more than zero and if just any one corner of the building is covered by the vast and then it will be murder so now hopefully my village would be much larger oh I would say that more more than sixty fifteen so I said this I have to sit in this case it's really important that I sit my reference layer down here in the calculator I mean every we do the calculator view stead of setting all these parameters unis sit our reference and on this you you you [Music] I'm not get now is this layer so my new awkward layer so let's call it up building this touch or something like it so if there are two cell just touches a building then it will be part of the building and I'll just change some biology to you get rid of that man how maybe change this home as ever you can see the difference off the screen bring that back set it to yellow color okay so this one now is constructor so that if any part or at least almost any part is covered by a roster it is part of it the original one which was this one will have a bit less come on so so you can see this was my original so is that so the lecture is the building layer so this the red ones is by the center and orangey green yellow things are the ones were just one of the sixteenth the end so depending on how we want our conversion to do be we can convert first to a smaller grid so using this trick of saying first convert to a raster image has a fraction of the desired size so to be a quarter then bonding this either V sample to start to calculate it back to the visual size bottle calculating the sum of ones and zeros there and then using the raster calculator to decide which rule we want to use on our calculation so these are the basic simple rules form but for doing vector to raster and the really important thing is to ensure that whenever you do this make sure that your raster layer aligns with your desired as tool as you go to do the calculation on so I am hope that this serve will save you a lot of frustration when working with vectors raster conversion in you guys because I can really be annoying things if the vaster cells do not align so I hope it was you
Info
Channel: Geoinformatics
Views: 14,827
Rating: 4.9008265 out of 5
Keywords: QGIS, raster to vector conversion, raster data, vector data
Id: AUV99OGF8Us
Channel Id: undefined
Length: 19min 20sec (1160 seconds)
Published: Tue Apr 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.