...
Numberedheadings | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Working with Vector Data in QGISVector data provides a way to represent real world features within the GIS environment. A feature is anything you can see on the landscape. QGIS can open over 60 file-based data formats (using the OGR library), including ESRI shapefile and MapInfo TAB. It can also connect to spatial database sources including PostgreSQL, SpatiaLite, Oracle, and MSSQL), to Web Feature Service (WFS) and Point Cloud data, and to Arc REST services. QGIS’s default file format is GeoPackage, a file-based database. Most QGIS functionality is available for all vector data sources, though some formats are read-only mode and need to be saved to another format for editing. In this exercise you will learn how to work with data from different sources. Vector Data SourcesGeoPackageGeoPackage is an OGC standard data format. It has a .gpkg file extension, and it can hold one or many layers, including non-spatial and raster data, and can also store QGIS projects.
MapInfo: add aonb_wales.mif in the same way ESRI ShapefileShapefile is a widely-used legacy format, developed by ESRI, used on many download sites. Shapefiles comprise four or more individual files on disk - all must be available for the file to open.
MapInfoQGIS can open both MIF and TAB files - these will appear in the browser with other file-based data. Note that MapInfo files can contain multiple geometry types, so QGIS may present a dialog with a choice of geometry types - i.e. line, polygon, point - to load.
ExcelQGIS will open an Excel file as vector data, and will recognise data types (for example string, integer, date). If the data includes coordinates, creating a geometry column which QGIS can use to represent the data spatially requires an extra step.
Database LayersLoading To loading database vector layers follows a slightly different process to loading a file-based layer, as you first need to establish a database connection. The process is similar for all databases, but in this example we will use data in a PostGreSQL PostgreSQL database. Database layersYou can load either spatial or non-spatial data from a database - the non-spatial data will be shown in QGIS as a table, which you can join to spatial data as shown below. To load data from a PostGreSQL database: Click Open Data Source Manager Click the PostgreSQL tab If you haven't connected to the database before, click New to create a new database connection Complete the dialog:
Under Authentication, click the Add button to add your credentials The first time you do this, you will be prompted for a Master password - make sure this is something you can safely store or remember, as it cannot be retrieved later Click Save to save these credentials, then click Test Connection to make sure the connection is OK Expand the database schemas, and select a table and click Add to add it to the map Check Also list tables with no geometry to view non-spatial data tables
Web Feature Service (WFS) LayersData available in OGC Web Feature Service (WFS) format can be loaded in QGIS and used in a similar way to any other vector layer. However as the data is online, , as long as you have an Internet connection is required, although once the connection has been made it data can be saved locally . WFS data is supplied as GML, and features can be selected, styled and queried in the same way as any other vector data. Create a new saved WFS ConnectionOpenThe first time you use a WFS source, you will once you are connected. As with database layers, first of all you need to create a connection: Click.
Name: your name for the connection
Authentication: complete as required
WFS Queries
Once WFS layers are loaded, they can be managed in the same way as other vector layers. Transactional Web Feature Service (WFS-T) layers, which are editable, are also supported in QGIS. Navigating Vector LayersThere are different approaches to navigating around the layers you have loaded, for example using toolbars, mouse actions and menus - some of the key ones are listed here. The buttons in the Map Navigation Toolbar will also get you around the map, and change the action of your mouse and cursor - these will help you identify the data and views you need.View Layer ExtentsWhen a layer has been added to the Layers panel, the features will be visible in the map frame on the right. To see the whole layer in the frame:
Attribute TableYouSelect the saved WFS Select the layer(s) required - you can select multiple layers Click Add to load the layer(s) into the map Note that with large datasets, it can take some time for the layers to load
Attribute TableAttribute tables hold the data which sits behind every layer - you can browse the attribute data for each layer by right-clicking on the layer and selecting Open Attribute Table, (or click the Manage the Layer ListNormally, layers at the top of the list in the Layers panel appear on the map in front of layers further down the list. You can change the order of layers in the list by dragging and dropping layers to a new position. Group LayersLayers can be grouped to create a hierarchical layer list, or table of contents.
Remove LayersTo remove a layer from the list, select the layer, then Right-click > Remove. This does not delete the data, just removes it from the map. However you will lose any styling or queries you have applied to the layer. Joining LayersIf you want to use data in your map which has no spatial references, you will need to join this to a corresponding spatial dataset. For example, you might have population data for census areas, and a polygon layer of the census areas themselves, and you want to join the two in order to show the population figures for each areas as a label.
Join definitionThe join definition is saved in memory, and is saved in the QGIS project - it does not affect the source data. It will therefore reflect the current data each time the project is loaded. You can edit the join after it has been created - for example to exclude fields from the joined data - in the same dialog you used to create it. Exporting Vector DataTo export a layer or part of a layer:
Exporting a joined layerIf you export a layer with a join, the exported data will include the fields in the join - this is a way of creating a permanent new dataset from a joined layer. |