- QGIS:Becoming a GIS Power User
- Anita Graser Ben Mearns Alex Mandel Víctor Olaya Ferrero Alexander Bruy
- 1140字
- 2021-07-09 19:32:44
Vector data – Extract, Transform, and Load
Our suitability analysis uses map algebra and criteria grids to give us a single value for the suitability for some activity in every place. This requires that the data be expressed in the raster (grid) format. So, let's perform the other necessary ETL steps and then convert our vector data to raster.
We will perform the following actions:
- Ensure that our data has identical spatial reference systems. For example, we may be using a layer of the roads maintained by the state department of transportation and a layer of land use maintained by the department of natural resources. These layers must have identical spatial reference systems or be transformed to have identical systems.
- Extract geographic objects according to their classes as defined in some attribute table field if we want to operate on them while they're still in the vector form.
- If no further analysis is necessary, convert to raster.
Loading data and establishing the CRS conformity
It is important for the layers in this project to be transformed or projected into the same geographic or projected coordinate system. This is necessary for an accurate analysis and for publication to the web formats. Perform the following steps for this:
- Disable 'on the fly' projection if it is turned on. Otherwise, 'on the fly' will automatically project your data again to display it with the layers that are already in the Canvas.
- Navigate to Settings | Options and configure the settings shown in the following screenshot:
- Add the project layers:
- Navigate to Layer | Add Layer | Vector Layer.
- Add the following layers from within
c2/data/original
.Applicants
County
Easements
Land use
Roads
Tip
You can select multiple layers to add by pressing Shift and clicking on the contiguous files or pressing Ctrl and clicking on the noncontiguous files.
- Import the Digital Elevation Model from
c2/data/original/dem/dem.tif
.- Navigate to Layer | Add Layer | Raster Layer.
- From the
dem
directory, selectdem.tif
and then click on Open.
- Even though the layers are in a different CRS, QGIS does not warn us in this case. You must discover the issue by checking each layer inpidually. Check the CRS of the county layer and one other layer:
- Highlight the county layer in the Layers panel.
- Navigate to Layer | Properties.
- The CRS is displayed under the General tab in the Coordinate reference system section:
Note
Note that the county layer is in EPSG: 26957, while the others are in EPSG: 2776.
- Follow the steps in Chapter 1, Exploring Places – from Concept to Interface, for transformation and projection. We will transform the county layer from EPSG:26957 to EPSG:2776.
- Navigate to Layer | Save as | Select CRS.
Note
We will save all the output from this chapter in
c2/data/output
.
To prepare the layers for conversion to raster, we will add a new generic column to all the layers populated with the number 1. This will be translated to a Boolean type raster, where the presence of the object that the raster represents (for example, roads) is indicated by a cell of 1 and all others with a zero. Follow these steps for the applicants, easements, and roads:
- Navigate to Layer | Toggle Editing.
- Then, navigate to Layer | Open Attribute Table.
- Add a column with the button at the top of the Attribute table dialog.
- Use
value
as the name for the new column and the following data format options: - Select the new column from the dropdown in the Attribute table and enter
1
into the value box: - Click on Update All.
- Navigate to Layer | Toggle Editing.
- Finally, save.
The extracting (filtering) features
Let's suppose that our criteria includes only a subset of the features in our roads layer—major unlimited access roads (but not freeways), a subset of the features as determined by a classification code (CFCC). To temporarily extract this subset, we will do a layer query by performing the following steps:
- Filter the major roads from the roads layer.
- Highlight the roads layer.
- Navigate to Layer | Query.
- Double-click on CFCC to add it to the expression.
- Click on the = operator to add to the expression
- Under the Values section, click on All to view all the unique values in the CFCC field.
- Double-click on A21 to add this to the expression.
- Do this for all the codes less than A36. Include A63 for highway on-ramps.
- Your selection code will look similar to this:
"CFCC" = 'A21' OR "CFCC" = 'A25' OR "CFCC" = 'A31' OR "CFCC" = 'A35' OR "CFCC" = 'A63'
- Click on OK, as shown in the following screenshot:
- Save the roads layer as a new layer with only the selected features (
major_roads
) inc2/data/output
.Tip
To clear a layer filter, return to the query dialog on the applied layer (highlight it in the Layers pane; navigate to Layer | Query and click on Clear).
- Repeat these steps for the
developed
(LULC1 = 1
) andagriculture
(LULC1 = 2
) land uses (separately) from thelanduse
layer.
Converting to raster
In this section, we will convert all the needed vector layers to raster. We will be doing this in batch, which will allow us to repeat the same operation many times over multiple layers.
Doing more at once—working in batch
The QGIS Processing Framework provides capabilities to run the same operation many times on different data. This is called batch processing. A batch process is invoked from an operation's context menu in the Processing Toolbox. The batch dialog requires that the parameters for each layer be populated for every iteration. Perform the following steps:
- Convert the vector layers to raster.
- Navigate to Processing Toolbox.
- Select Advanced Interface from the dropdown at the bottom of Processing Toolbox (if it is not selected, it will show as Simple Interface).
- Type
rasterize
to search for the Rasterize tool. - Right-click on the Rasterize tool and select Execute as batch process:
- Fill in the Batch Processing dialog, making sure to specify the parameters as follows:
The following images show how this will look in QGIS:
- Scroll to the right to complete the entry of parameter values.
- Organize the new layers (optional step).
- Batch sometimes gives unfriendly names based on some bug in the dialog box.
- Change the layer names by doing the following for each layer created by batch:
- Highlight the layer.
- Navigate to Layer | Properties.
- Change the layer name to the name of the vector layer from which this was created (for example,
applicants
). You should be able to find a hint for this value in the layer properties in the layer source (name of the.tif
file). - Group the layers:
Press Shift + click on all the layers created by batch and the previous
roads
raster, in the Layers panel.Right-click on the selected layers and click on Group selected.
- 華為HMS生態與應用開發實戰
- Learn Scala Programming
- 實戰低代碼
- Full-Stack Vue.js 2 and Laravel 5
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- 組態軟件技術與應用
- Python語言實用教程
- Application Development with Swift
- Web前端測試與集成:Jasmine/Selenium/Protractor/Jenkins的最佳實踐
- Android應用程序設計
- 美麗洞察力:從化妝品行業看顧客需求洞察
- Visual FoxPro程序設計實驗教程
- Advanced C++
- 測試架構師修煉之道:從測試工程師到測試架構師(第2版)
- Python Geospatial Analysis Cookbook