Spatial subset

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
(Vector polygon masking)
(Masking by vector polygon)
 
(17 intermediate revisions by one user not shown)
Line 1: Line 1:
= Interactive box selection =
+
== Interactive box selection ==
# Click the {{button|text=Open Data Source Manager}} [[Image:QGIS_3.0_datasource.png|30px]] and {{button|text=Add raster layer}} [[Image:QGIS_2.0_addrast.png|20px]] and select the file ''/geodata/raster/s2/Subset_S2A_MSIL2A_20170619T_MUL.tif''.
+
# Click the {{button|text=Open Data Source Manager}} [[Image:QGIS_3.0_datasource.png|30px]] and {{button|text=Add raster layer}} [[Image:QGIS_2.0_addrast.png|20px]] and select a multiband raster file.
 
# {{mitem|text=Raster --> Extraction ---> Clip Raster by Extent}}
 
# {{mitem|text=Raster --> Extraction ---> Clip Raster by Extent}}
# Input file (raster): Choose a loaded file from the drop down list or click {{button|text=Select}} to browse for a file.
+
# Input layer: Choose a loaded raster file from the drop down list or click [[File:QGIS_file_select.png]] to browse for a file.
# Output file:  click {{button|text=Select}} to choose a new file name for the subset image.
+
# Define the clipping extent by clicking [[File:QGIS_file_select.png]] and select '''Draw on canvas'''. The clipping mode is now active. Hold a left click on the map canvas dragging a box of your region of interest.
# Define the clipping extent by clicking{{button|text=...}} and '''Select extent from canvas''' The clipping mode is now active. Hold a left click on the map canvas dragging a box of your region of interest.
+
# Clipped (extent): click [[File:QGIS_file_select.png]] to choose a new file name for the subset image.
 
# Adjust the extent coordinates in the text file rounding the coordinates (upper left and lower right).
 
# Adjust the extent coordinates in the text file rounding the coordinates (upper left and lower right).
[[File:Qgis_raster_clipper.png|600px]]
+
[[File:Qgis_raster_clipper.png|700px]]
# Click {{button|text=OK}}.
+
* Click {{button|text=Run}}.
  
= Vector polygon masking =
+
== Masking by vector polygon ==
* Load the vector file ''\geodata\vector\gadm36_DEU_4.shp''. These are the level 4 administrative boundaries of the country Germany downloaded from https://gadm.org/index.html .
+
* Load the vector file (e.g. administrative boundary).
* Right click on Layer name in the Layers Panel {{mitem|text=Properties --> General}}. Change the '''Data source encoding''' from {{button|text=System}} to {{button|text=UTF-8}}. Click {{button|text=UTF-8}}.
+
* Select a community of your choice: right click {{mitem|text=Open Attribute Table}}
* Right click on Layer name in the Layers Panel and open the {{button|text=Attribute table}}.
+
* Click [[File:Qgis_select_by_expression.png]] and select by the expression: {{typed|text="NAME_4" ='Göttingen'}}. {{button|text=Select}}.
+
[[File:Qgis_select_munic.png|400px]]
+
* Right click on Layer name in the Layers Panel . {{mitem|text=Export --> Save Features as...}} {{button|text=Save as...}}. Fill the form as shown below.
+
* Select
+
[[File:Qgis_vector_save_as.png|300px]]
+
  
Make sure that the CRS is the same like the image file (here WGS84/UTM Zone 32, EPSG:32632)!
+
* {{mitem|text=Raster --> Extraction ---> Clip Raster by Mask Layer...}}
# Click {{button|text=OK}}.
+
# Input layer: Choose a loaded raster file from the drop down list or click [[File:QGIS_file_select.png]] to browse to a file.
# {{mitem|text=Raster --> Extraction ---> Clip Raster by Mask Layer...}}
+
# Mask layer: Select the vector file (s. above).
# Input file (raster): Choose a loaded file name fron the drop down list or click {{button|text=Select}} to browse to a file (see above).
+
# Assign a specofied nodata value: {{button|text=65535}}
# Output file: click {{button|text=Select}} to choose a new file name for the subset image.
+
# Switch the checkbox on: '''Match the extent of the clipped raster to the extent of the mask layer'''. All image data outside the polygon will be masked.
# Change the clipping mode from '''Extent''' to '''Mask'''. Choose the newly created polygon of the municipality as '''Mask Layer'''.
+
# Clipped (extent)):  click {{button|text=Select}} to choose a new file name for the subset image.
# Switch the checkbox on: '''Crop the extent of the target dataset to the extent of the cutline'''. All image data outside the polygon will be masked.
+
# Click {{button|text=Run}}.
# Switch the '''No data value''' checkbox on and specify the value {{typed|text=0}}.
+
[[File:Qgis_raster_mask.png|400px]]
# Click {{button|text=OK}}.
+
[[File:Qgis_raster_mask.png|600px]]
+
 
[[Category: Working with Raster Data]]
 
[[Category: Working with Raster Data]]

Latest revision as of 10:57, 31 May 2021

[edit] Interactive box selection

  1. Click the Open Data Source Manager QGIS 3.0 datasource.png and Add raster layer QGIS 2.0 addrast.png and select a multiband raster file.
  2. Raster --> Extraction ---> Clip Raster by Extent
  3. Input layer: Choose a loaded raster file from the drop down list or click QGIS file select.png to browse for a file.
  4. Define the clipping extent by clicking QGIS file select.png and select Draw on canvas. The clipping mode is now active. Hold a left click on the map canvas dragging a box of your region of interest.
  5. Clipped (extent): click QGIS file select.png to choose a new file name for the subset image.
  6. Adjust the extent coordinates in the text file rounding the coordinates (upper left and lower right).

Qgis raster clipper.png

  • Click Run.

[edit] Masking by vector polygon

  • Load the vector file (e.g. administrative boundary).
  • Select a community of your choice: right click Open Attribute Table
  • Raster --> Extraction ---> Clip Raster by Mask Layer...
  1. Input layer: Choose a loaded raster file from the drop down list or click QGIS file select.png to browse to a file.
  2. Mask layer: Select the vector file (s. above).
  3. Assign a specofied nodata value: 65535
  4. Switch the checkbox on: Match the extent of the clipped raster to the extent of the mask layer. All image data outside the polygon will be masked.
  5. Clipped (extent)): click Select to choose a new file name for the subset image.
  6. Click Run.

Qgis raster mask.png

Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export