Vector data can also be analyzed to reveal how different features interact with each other in space. There are many different analysis-related functions in GIS, so we won’t go through them all. Rather, we’ll pose a question and try to solve it using the tools that QGIS provides.
Scopul acestei lecții: De a pune o întrebare și de a o rezolva folosind instrumentele de analiză.
Before we start, it would be useful to give a brief overview of a process that can be used to solve any GIS problem. The way to go about it is:
Definirea Problemei
Obținerea Datelor
Analiza Problemei
Prezentarea Rezultatelor
Let’s start off the process by deciding on a problem to solve. For example, you are an estate agent and you are looking for a residential property in Swellendam for clients who have the following criteria:
Să fie situată în Swellendam.
Trebuie să fie situată la o distanță de conducere rezonabilă, față de o școală (de exemplu, 1 km).
Trebuie să aibăo dimensiune de peste 100m pătrați.
Să fie situată sub 50m față de un drum principal.
Să fie situată la maximum 500m față de un restaurant.
Pentru a răspunde la aceste întrebări, vom avea nevoie de următoarele date:
Proprietățile rezidențiale (clădirile) din zonă.
Drumurile din jurul și din cadrul orașului.
Amplasarea școlilor și a restaurantelor.
Dimensiunea clădirilor.
All of this data is available through OSM and you should find that the dataset you have been using throughout this manual can also be used for this lesson. However, in order to ensure we have the complete data, we will re-download the data from OSM using QGIS’ built-in OSM download tool.
Note
Although OSM downloads have consistent data fields, the coverage and detail does vary. If you find that your chosen region does not contain information on restaurants, for example, you may need to chose a different region.
Deschideți un nou proiect QGIS
Salvați rezultatul ca osm_data.osm, în folderul exercise_data.
Selectați osm_data.osm, apoi faceți clic pe Open
În caseta de dialog care se deschide, selectați toate straturile, cu excepția straturilor other_relations și multilinestrings:
Acest lucru va importa datele OSM în hartă ca și straturi separate.
The data you just downloaded from OSM is in a geographic coordinate system, WGS84, which uses latitude and longitude coordinates, as you know from the previous lesson. You also learnt that to calculate distances in meters, we need to work with a projected coordinate system. Start by setting your project’s coordinate system to a suitable CRS for your data, in the case of Swellendam, WGS 84 / UTM zone 34S:
Deschideți dialogul Proprietățile Proiectului, selectați CRS și filtrați lista pentru a găsi WGS 84 / UTM zone 34S.
Clic pe OK
We now need to extract the information we need from the OSM dataset. We need to end up with layers representing all the houses, schools, restaurants and roads in the region. That information is inside the multipolygons layer and can be extracted using the information in its Attribute Table. We’ll start with the schools layer:
Faceți clic-dreapta pe stratul multipolygons din Lista straturilor dvs., apoi deschideți dialogul Proprietăților Stratului.
Mergeți la meniul General.
În Subsetul Entităților faceți clic pe butonul [Query Builder] deschide dialogul Query builder.
În lista Cămpurilor din partea stângă a acestui dialog, derulați până când veți vedea câmpul amenity.
Faceți clic pe el o dată.
Faceți clic pe butonul All de sub lista Valori:
Acum, trebuie să indicați aplicației QGIS să arate doar poligoanele în care valoarea amenity este egală cu school.
Dublu-clic pe cuvântul amenity din lista Câmpurilor.
Priviți ce se întâmplă în câmpul ExpresiIor de filtrare specifice furnizorului de mai jos:
A apărut cuvântul "amenity". Pentru a construi restul interogării:
Faceți clic pe butonul = (de sub lista Operatorilor).
Dublu-clic pe valoarea school din lista Valorilor.
Clic pe OK, de două ori.
This will filter OSM’s multipolygons layer to only show the schools in your region. You can now either:
Using the above technique, use the Query Builder tool to extract the remaining data from OSM to create the following layers:
roads (din stratul OSM lines)
restaurants (din stratul OSM multipolygons)
houses (din stratul OSM multipolygons)
Ați putea re-utiliza stratul roads.shp pe care le-ați creat în lecțiile anterioare.
Some of the roads in OSM’s dataset are listed as unclassified, tracks, path and footway. We want to exclude these from our roads dataset.
Deschideți Constructorul de Interogări pentru stratul roads, clic pe Clear și construiți următoarea interogare:
"highway" != 'NULL' AND "highway" != 'unclassified' AND "highway" != 'track' AND "highway" != 'path' AND "highway" != 'footway'
You can either use the approach above, where you double-clicked values and clicked buttons, or you can copy and paste the command above.
Acest lucru ar trebui să reducă imediat numărul de drumuri de pe hartă:
Because we are going to be measuring distances within our layers, we need to change the layers’ CRS. To do this, we need to select each layer in turn, save the layer to a new shapefile with our new projection, then import that new layer into our map.
Note
In this example, we are using the WGS 84 / UTM zone 34S CRS, but you may use a UTM CRS which is more appropriate for your region.
Faceți clic-dreapta pe stratul roads din panoul Layers.
Clic pe Save as...
Noul fișier shape va fi creat, iar stratul rezultat va fi adăugat la hartă.
Note
If you don’t have activated Enable ‘on the fly’ CRS transformation or the Automatically enable ‘on the fly’ reprojection if layers have different CRS settings (see previous lesson), you might not be able to see the new layers you just added to the map. In this case, you can focus the map on any of the layers by right click on any layer and click Zoom to layer extent, or just enable any of the mentioned ‘on the fly’ options.
Eliminați vechiul strat roads.
Repeat this process for each layer, creating a new shapefile and layer with “_34S” appended to the original name and removing each of the old layers.
Once you have completed the process for each layer, right click on any layer and click Zoom to layer extent to focus the map to the area of interest.
Now that we have converted OSM’s data to a UTM projection, we can begin our calculations.
QGIS allows you to calculate distances from any vector object.
This gives you a new dialog.
Setați-l astfel:
The Buffer distance is in meters because our input dataset is in a Projected Coordinate System that uses meter as its basic measurement unit. This is why we needed to use projected data.
Now your map will look something like this:
If your new layer is at the top of the Layers list, it will probably obscure much of your map, but this gives us all the areas in your region which are within 50m of a road.
However, you’ll notice that there are distinct areas within our buffer, which correspond to all the individual roads. To get rid of this problem, remove the layer and re-create the buffer using the settings shown here:
Once you’ve added the layer to the Layers list, it will look like this:
Now there are no unnecessary subdivisions.
It needs to be 1 km in radius, and saved under the usual directory as schools_buffer_1km.shp.
Now we have areas where the road is 50 meters away and there’s a school within 1 km (direct line, not by road). But obviously, we only want the areas where both of these criteria are satisfied. To do that, we’ll need to use the Intersect tool. Find it under Vector ‣ Geoprocessing Tools ‣ Intersect. Set it up like this:
The two input layers are the two buffers; the save location is as usual; and the file name is road_school_buffers_intersect.shp. Once it’s set up like this, click OK and add the layer to the Layers list when prompted.
In the image below, the blue areas show us where both distance criteria are satisfied at once!
You may remove the two buffer layers and only keep the one that shows where they overlap, since that’s what we really wanted to know in the first place:
Now you’ve got the area that the buildings must overlap. Next, you want to select the buildings in that area.
Setați-l astfel:
The buildings highlighted in yellow are those which match our criteria and are selected, while the buildings in green are those which do not. We can now save the selected buildings as a new layer.
Clic pe OK
Now you have the selection as a separate layer and can remove the houses_34S layer.
We now have a layer which shows us all the buildings within 1km of a school and within 50m of a road. We now need to reduce that selection to only show buildings which are within 500m of a restaurant.
Using the processes described above, create a new layer called houses_restaurants_500m which further filters your well_located_houses layer to show only those which are within 500m of a restaurant.
To see which buildings are the correct size (more than 100 square meters), we first need to calculate their size.
Setați-l astfel:
Clic pe OK
Using the GIS problem-solving approach together with QGIS vector analysis tools, you were able to solve a problem with multiple criteria quickly and easily.
In the next lesson, we’ll look at how to calculate the shortest distance along the road from one point to another.