Clip all layers in a geopackage with QGIS - 01 | burdGIS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
map fans welcome back today we're looking at how we can clip all layers in a geo package using qgis this is the first of a three part series and in this series i'll be using the mighty ordnance survey open zoom stack so i'll just drag that geo package down and into my project and add all of these layers so in this first of the series we'll be looking at how we can use a batch command in order to clip all of these layers in the os open zoom stack just using qgis part two we'll be taking a look at how we can do the same thing with gdal and in part three we'll be taking a look at how we can do the same thing again but this time using python now with open zoom stack when everything loads in we generally speaking don't want all the data for the uk or we might not for our particular project so what i'm going to do is just zoom into an area that i would like let's go for flambert because it's easy to identify there we go that should do and once i'm here just for the rest of the series i'm going to make a little bookmark and this should be able to get me back to roughly the same area each time so to make that bookmark i'll just go up to new spatial bookmark and i'll call this vlambra the extent is fine the crs is great and instead of user bookmarks i will put this in project bookmarks okay save that so what i'd like to do is clip all of these layers within the open zoom stack to this particular area so to the extent i'm currently looking at so i'm going to go over to my processing toolbox and just type in clip and here we can see we've got some various options instead of going for the clip i'm going to go for the extract clip by extent so i'll just double click that processing tool to open it up and here it is now as always on the right hand side we've got a lot of information about how this tool works and i recommend that you always read that when you're working with a new tool now i could just go through and do each layer individually but that would become very tedious very quickly and so what i'd like to do instead is run this as a batch process if i click on here it will reopen and this little dialog box looks a little bit different now the neat thing about batch processing is these little auto fill parts at the top so i'm just going to widen each column as i use it so you can see what's going on and for the autofill here in this first column we need an input layer so i'll use the drop down here and i'm going to select from open layers and i'll select all of my open layers and ok that and look at that we have all of our inputs sorted now for the extent what i would like to use i'm going to go to autofill again and let's calculate by expression now when i go for calculate by expression you will see some tool related options variables up at the top here for example extent and it might be tempting just to double click extent and think that that will clip to our current map extent but that is not the case extent here relates to what we put in this column so if i was to put this in you can see down in the preview it says that it is currently null and that's because it has not been set so what i'd actually like to add in is my current map extent so if i type in map and if we look down here we should have there we go a variable that is map extent so that is my current extent and you can see that that's going to be a polygon so i'll okay that and that is auto filled in excellent clip features to extend now this is an option where we could have the features overrun so if we have a contour line that's going to continue beyond our extent it will continue to continue beyond the extent if we select no here if we select yes then it will be chopped off just where the extent ends so i'll do this i'll chop off the contours and leave everything else to run over the extent that we've set now when it comes to output or the extracted features that we're going to save i'd like to save them to a geo package and i want this to be a new geo with the same name as the input layer and in the same location as my project is currently saved in so in order to do all this i'm going to use autofill and i'll calculate by expression again now this expression will get a little long so just stay with me on this one and i'm just going to make the expression window a little bit bigger so you can see what's happening now i'd like the output to have the same name as my input layer so i'm going to go for input first of all and if i double click on this that looks okay no problems with the expression but if i look at the preview you can see that i've got all this goldy afterwards and really what i just like is the airports part not all of this afterwards now the gobbledygook at the end is because this is actually our layer id instead of our layer name and so in order to get the layer name if i use this layer property it would like an input layer or a layer which i've got there that's our layer id and then it would like to know which property i'd like and i'd like the name of this particular layer please and you can see down at the bottom there it's changed from the layer id to the layer name so we've just got airports right there now here i've got the expression in full and i'd just like to walk you through it bit by bit so here we're using ogr and we are specifying a database name and that expects to have a string these double pipes here mean that we're going to concatenate a string with a string and this is at project folder so that's the same folder that my project is currently stored in and then we use the double pipes again and instead of just having a folder i'm going to specify a geo package so i'll say batch.gpkg now if we're saving to a geopackage we also need to specify the table name so i'll put in table equals and again this is expecting a string and i'm going to use that layer property our input and the name for that and you can see down at the bottom how this pans out so we've got ogr db name and this is the file path to the new geo package that i've just specified and the table is going to be called this the final part at the end just lets qgis know where the geometry is stored so this all looks good i'm going to ok that and we can see our autofill has done its magic again and then i'm going to ask our batch process to load the layers on completion well actually i won't i'll leave it and then we can add them from our new geo package that gets created and so i'll just run this and off it goes all looking good that is clipping our open zoom stack and let's close that says that the task is complete and you can see up in my folders here that i've got a new geo package called batch and i'm just going to bring this down and add all the layers there and you can see that we've got this group batch and down at the bottom we've got the original os open zoom stack so i'll switch that off for the time being and let's just zoom out and if we zoom into our contours you can see where i decided to clip the contours off and then other areas i've just let them run over so rather than cutting features it'll just let the natural shape of the feature persist and that is how we can batch clip all of the layers in a geo package using qgis now next time we'll be having a look at how we can use gdal directly from the terminal and then in the final part we'll take a look at how we can use python that's all for today thanks very much for watching please don't forget to like don't forget to subscribe and leave a comment below happy mapping
Info
Channel: burdGIS
Views: 449
Rating: 5 out of 5
Keywords: burdGIS, GIS, mapping, geospatial, cartography, QGIS, batch, clip, geopackage, ordnance survey, os, open zoomstack, gpkg
Id: YFRy90anJ0M
Channel Id: undefined
Length: 8min 53sec (533 seconds)
Published: Tue Aug 10 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.