Basic Layer Operations
This chapter introduces fundamental layer operations including adding layers, removing layers, and adjusting layer order.
In GIS, layers define the display mechanism of spatial data in the map window and serve as the visual representation of geospatial data. Layers typically associate with specific data sources and use cartographic elements such as symbols and labels to render spatial data on maps. Multiple layers can be overlaid to create rich, content-dense maps.
QGIS supports various vector data formats, including common ones like Shapefile, gdb, MapInfo MIF, and TAB, as well as PostGIS layers from Oracle spatial databases and PostgreSQL databases.
This chapter uses the widely-used ESRI Shapefiles format as an example, which consists of three main files:
- shp file: Stores spatial information of geometric features, including point coordinates, line and polygon shapes.
- shx file: Stores index information for the .shp file, recording the position of each geometry in the .shp file to accelerate search efficiency.
- dbf file: Stores attribute data for each geometry in dBASE table format, such as names and descriptions.
Additionally, Shapefiles may include other optional files, such as:
- prj file: Saves geographic coordinate system and projection information.
- shp.xml file: Stores metadata in XML format, including creation time and other information.
- cpg file: Describes the code page of the .dbf file, indicating its character encoding.
Data source: USA NGA: GADM(Database of Global Administrative Areas)
1. Adding Layers
QGIS offers 5 methods to add layers:
1.1 Drag and Drop from Folder
Open the folder containing your data files. Note that the same filename may include multiple file formats such as CPG, DBF, PRJ, SHP, and SHX. Hold the left mouse button and drag the SHP format file "gadm41_USA_0.shp" into the QGIS map window.
The layer management panel will now display a layer named "gadm41_USA_0," and the geometry will appear in the map window.
By default, QGIS renders the layer using a single symbol with a random color, so even when following identical steps to open layers, the default colors may differ.
1.2 Adding Layers from the 【Browser】 Panel
The QGIS 【Browser】 panel integrates common data sources in a tree structure, including local directories, network data sources (WMS, WCS, WFS, etc.), and database data sources (PostGIS, SpatiaLite, GeoPackage, MSSQL, DB2, Oracle, etc.).
From the 【Browser】 panel, locate the path where your data is stored, select the file you want to open, and drag it to the map window to complete the layer addition.
The advantage of the 【Browser】 panel is its 【Favorites】 functionality. Typically, frequently used spatial data is stored in a dedicated directory. Right-click on this directory and select 【Add as a Favorites】 from the popup menu to add it to your favorites. You can then access this folder from the 【Favorites】 node at the top of the panel, saving operational time.
1.3 Using the 【Manage Layers Toolbar】
Right-click in an empty area of the toolbar to display the tools dropdown list, then check 【Manage Layers Toolbar】. This toolbar will appear in the interface, and you can dock or float it according to your preference.
Alternatively, you can click on the 【View】 menu -> 【Toolbar】, and check 【Manage Layers Toolbar】 to display this toolbar.
The functions of each button in the 【Manage Layers Toolbar】 are as follows:
Click the 【Add Vector Layers】 button to open the 【Data Source Manager】 dialog. 【Source Type】 indicates the data source, and different sources require different opening methods. Vector data can come from files, directories, databases, or protocols. For 【Encoding】, typically select "automatic" or "utf-8". If Chinese character data appears garbled, you can switch the encoding.
Taking opening a shapefile as an example, select the 【File】 source type, and click the 【...】 button next to 【Source】 -> 【Vector Dataset(s)】 to open the file selection dialog.
Click the 【All files】 dropdown box in the bottom right and select "ESRI Shapefile (*.shp, *.SHP)" to filter and display only .shp files.
Select the data you want to open, click 【Open】 to return to the 【Data Source Manager】 dialog. The path will be populated in the 【Vector Dataset(s)】 text box. Click the 【Add】 button to add the data to the map window.
1.4 Adding Layers from the Menu
Click on the 【Layer】 menu -> 【Add Layer】 -> 【Add Vector Layer】 to similarly invoke the 【Data Source Manager】 dialog for opening data.
1.5 Adding Layers with Keyboard Shortcuts
The 【Add Vector Layer...】 menu item is labeled with the shortcut "Ctrl+Shift+V". Pressing Ctrl+Shift+V simultaneously will open the 【Data Source Manager】 dialog.
1.6 Batch Adding Layers
Maps typically consist of multiple layers. In the file open dialog, you can use the Ctrl key or Shift key to select multiple data files and add them to the map window in a single batch operation.
QGIS will randomly select rendering colors for the layers, as shown in the image below:
2. Adjusting Layer Order
In electronic map production, layer organization follows certain conventions. For example, polygon layers are typically arranged at the bottom, line layers in the middle, and point layers at the top, ensuring that polygon layers don't obscure lines and points.
In QGIS, layer order can be adjusted through mouse dragging: select the layer name in the 【Layers】 panel, drag it to the desired position, and release the mouse.
If you want to move a layer to the top or bottom, right-click on the layer name and select 【Move to Top】 or 【Move to Bottom】 from the popup menu.
3. Removing Layers
There are several methods to remove layers:
- Select the layer name in the 【Layers】 panel and click the delete button in the toolbar above to remove it.
- Right-click on the layer name and select 【Remove Layer/Group】 from the popup menu to remove the layer.
- Select the layer and use the keyboard shortcut "Ctrl+D" to delete it directly.
Having any problems? Please contact us
We value every feedback you give.