13.1. Abrir Dados
Como parte de um ecossistema de software de código aberto, o QGIS é baseado em diferentes bibliotecas que, combinadas com seus próprios provedores, oferecem capacidades para ler e muitas vezes escrevem vários formatos:
Os formatos de dados vetoriais incluem GeoPackage, GML, GeoJSON, GPX, KML, Valores separados por vírgula, formatos ESRI (Shapefile, Geodatabase…), formatos de arquivo MapInfo e MicroStation, AutoCAD DWG/DXF, GRASS e muito mais… Leia o artigo completo lista de formatos vetoriais suportados.
Raster data formats include GeoTIFF, JPEG, ASCII Gridded XYZ, MBTiles, R or Idrisi rasters, GDAL Virtual, SRTM, Sentinel Data, ERDAS IMAGINE, ArcInfo Binary Grid, ArcInfo ASCII Grid, and many more… Read the complete list of supported raster formats.
Database formats include PostgreSQL/PostGIS, SQLite/SpatiaLite, Oracle, DB2 or MSSQL Spatial, MySQL…
Web map and data services (WM(T)S, WFS, WCS, CSW, XYZ tiles, ArcGIS services, …) are also handled by QGIS providers. See Working with OGC / ISO protocols for more information about some of these.
You can read supported files from archived folders and use QGIS native formats such as QML files (QML - O Formato de Arquivo de Estilo QGIS) and virtual and memory layers.
Mais de 80 formatos de vetor e 140 raster são suportados pelos provedores nativos GDAL e QGIS.
Nota
Not all of the listed formats may work in QGIS for various reasons. For
example, some require external proprietary libraries, or the GDAL/OGR
installation of your OS may not have been built to support the format you
want to use. To see the list of available formats, run the command line
ogrinfo --formats
(for vector) and gdalinfo --formats
(for raster),
or check the menu in QGIS.
In QGIS, depending on the data format, there are different tools to open a dataset, mainly available in the Manage Layers toolbar (enabled through menu). However, all these tools point to a unique dialog, the Data Source Manager dialog, that you can open with the Open Data Source Manager button, available on the Data Source Manager Toolbar, or by pressing Ctrl+L. The Data Source Manager dialog(Fig. 13.1) offers a unified interface to open vector or raster file-based data as well as databases or web services supported by QGIS. It can be set modal or not with the Modeless data source manager dialog in the menu.
menu or from theBeside this main entry point, you also have the DB Manager plugin that offers advanced capabilities to analyze and manipulate connected databases. More information on DB Manager capabilities can be found in DB Manager Plugin.
Existem muitas outras ferramentas, complementos nativos ou de terceiros, que ajudam a abrir vários formatos de dados.
Este capítulo descreve apenas as ferramentas fornecidas por padrão no QGIS para carregar dados. Ele se concentra principalmente na caixa de diálogo Gerenciador de Fonte de Dados, mas, além de descrever cada guia, também explora as ferramentas baseadas no provedor de dados ou nas especificidades do formato.
13.1.1. The Browser Panel
The Browser is one of the main ways to quickly and easily add your data to projects. It’s available as:
a Data Source Manager tab, enabled pressing the Open Data Source Manager button (Ctrl+L);
as a QGIS panel you can open from the menu ) or by pressing Ctrl+2.
(or
In both cases, the Browser helps you navigate in your file system and manage geodata, regardless the type of layer (raster, vector, table), or the datasource format (plain or compressed files, databases, web services).
13.1.1.1. Exploring the Interface
At the top of the Browser panel, you find some buttons that help you to:
Add Selected Layers: you can also add data to the map canvas by selecting Add selected layer(s) from the layer’s context menu;
Filter Browser to search for specific data. Enter a search word or wildcard and the browser will filter the tree to only show paths to matching DB tables, filenames or folders – other data or folders won’t be displayed. See the Browser Panel(2) example in Fig. 13.2. The comparison can be case-sensitive or not. It can also be set to:
Normal: mostra itens que contêm o texto de pesquisa
Wildcard(s): fine tune the search using the
?
and/or*
characters to specify the position of the search textExpressão regular
Enable/disable properties widget: when toggled on, a new widget is added at the bottom of the panel showing, if applicable, metadata for the selected item.
The entries in the Browser panel are organised hierarchically, and there are several top level entries:
Favorites where you can place shortcuts to often used locations
Spatial Bookmarks where you can store often used map extents (see Favoritos Espaciais)
Project Home: for a quick access to the folder in which (most of) the data related to your project are stored. The default value is the directory where your project file resides.
Home directory in the file system and the filesystem root directory.
Connected local or network drives
Then comes a number of container / database types and service protocols, depending on your platform and underlying libraries:
13.1.1.2. Interacting with the Browser items
The browser supports drag and drop within the browser, from the browser to the canvas and Layers panel, and from the Layers panel to layer containers (e.g. GeoPackage) in the browser.
Project file items inside the browser can be expanded, showing the full layer tree (including groups) contained within that project. Project items are treated the same way as any other item in the browser, so they can be dragged and dropped within the browser (for example to copy a layer item to a geopackage file) or added to the current project through drag and drop or double click.
The context menu for an element in the Browser panel is opened by right-clicking on it.
For file system directory entries, the context menu offers the following:
to create in the selected entry a:
Diretório…
GeoPackage…
ShapeFile…
Add as a Favorite: favorite folders can be renamed (Rename favorite…) or removed (Remove favorite) any time.
Hide from Browser: hidden folders can be toggled to visible from the setting
Fast Scan this Directory
Open Directory
Open in Terminal
Propriedades…
Directory Properties…
For leaf entries that can act as layers in the project, the context menu will have supporting entries. For example, for non-database, non-service-based vector, raster and mesh data sources:
Apagar Arquivo “<name of file>”…
Export Layer –> To File…
Add Layer to Project
Layer Properties
File Properties
In the Layer properties entry, you will find (similar to what you will find in the vector and raster layer properties once the layers have been added to the project):
Metadados for the layer. para a camada. Grupos de Metadados: Informações do provedor (se possível,será um hiperlink para a fonte Path), Identificação, Extensão, Acesso, Campos (para camadas vetoriais), Bandas (para camadas raster), Contatos, Links (para camadas vetoriais), Referências (para camadas raster), Histórico.
A Preview panel
The attribute table for vector sources (in the Attributes panel).
Para adicionar uma camada ao projeto usando a Navegador:
Enable the Browser as described above. A browser tree with your file system, databases and web services is displayed. You may need to connect databases and web services before they appear (see dedicated sections).
Find the layer in the list.
Use the context menu, double-click its name, or drag-and-drop it into the map canvas. Your layer is now added to the Layers panel and can be viewed on the map canvas.
Dica
Open a QGIS project directly from the browser
You can also open a QGIS project directly from the Browser panel by double-clicking its name or by drag-and-drop into the map canvas.
Depois que um arquivo é carregado, você pode ampliar usando as ferramentas de navegação do mapa. Para alterar o estilo de uma camada, abra a caixa de diálogo :guilabel: Propriedades da Camada clicando duas vezes no nome da camada ou clicando com o botão direito do mouse no nome da legenda e escolhendo :menuselection:` Propriedades` no menu de contexto. Veja a seção Propriedades da simbologia para mais informações sobre a configuração de simbologia para camadas vetoriais.
Right-clicking an item in the browser tree helps you to:
for a file or a table, display its metadata or open it in your project. Tables can even be renamed, deleted or truncated.
para uma pasta, adicione-a aos favoritos ou oculte-a na árvore do navegador. As pastas ocultas podem ser gerenciadas a partir da guia
.manage your spatial bookmarks: bookmarks can be created, exported and imported as
XML
files.crie uma conexão com um banco de dados ou um serviço da web.
atualizar, renomear ou excluir um esquema.
Você também pode importar arquivos para bancos de dados ou copiar tabelas de um esquema/banco de dados para outro com um simples arrastar e soltar. Há um segundo painel do navegador disponível para evitar rolagem longa enquanto arrasta. Basta selecionar o arquivo e arrastar e soltar de um painel para o outro.
Dica
Add layers to QGIS by simple drag-and-drop from your OS file browser
You can also add file(s) to the project by drag-and-dropping them from your operating system file browser to the Layers Panel or the map canvas.
13.1.2. The DB Manager
The DB Manager Plugin is another tool for integrating and managing spatial database formats supported by QGIS (PostGIS, SpatiaLite, GeoPackage, Oracle Spatial, MSSQL, DB2, Virtual layers). It can be activated from the menu.
The DB Manager Plugin provides several features:
connect to databases and display their structure and contents
preview tables of databases
add layers to the map canvas, either by double-clicking or drag-and-drop.
add layers to a database from the QGIS Browser or from another database
create SQL queries and add their output to the map canvas
criar virtual layers
More information on DB Manager capabilities is found in DB Manager Plugin.
13.1.3. Provider-based loading tools
Beside the Browser Panel and the DB Manager, the main tools provided by QGIS to add layers, you’ll also find tools that are specific to data providers.
Nota
Some external plugins also provide tools to open specific format files in QGIS.
13.1.3.1. Loading a layer from a file
To load a layer from a file:
Abra a guia do tipo de camada na caixa de diálogo Gerenciador de Fonte de Dados, ou seja, clique no botão Abrir Gerenciador de Fonte de Dados (ou pressione: kbd:Ctrl+L) e ative a guia de destino ou:
for vector data (like GML, ESRI Shapefile, Mapinfo and DXF layers): press Ctrl+Shift+V, select the Add Vector Layer menu option or click on the Add Vector Layer toolbar button.
para dados raster (como camadas GeoTiff, MBTiles, GRIdded Binary e DWG): pressione Ctrl+Shift+R, selecione a opção Adicionar Camada Raster do menu ou clique no botão Adicionar Camada Raster da barra de ferramentas.
Click on the … Browse button
Navegue no sistema de arquivos e carregue uma fonte de dados suportada. É possível carregar mais de uma camada ao mesmo tempo mantendo pressionada a tecla Ctrl e clicando em vários itens da caixa de diálogo ou pressionando a tecla Shift para selecionar um intervalo de itens clicando em o primeiro e o último item do intervalo. Somente os formatos que foram bem testados aparecem no filtro de formatos. Outros formatos podem ser carregados selecionando
Todos os arquivos
(o item superior no menu pull-down).Press Open to load the selected file into Data Source Manager dialog
Press Add to load the file in QGIS and display them in the map view. Fig. 13.7 shows QGIS after loading the
alaska.shp
file.
Nota
For loading vector files the GDAL driver offers to define open actions. These will be shown when the vector file is selected. Options are described in detail on https://gdal.org/drivers/vector/ .
Nota
Because some formats like MapInfo (e.g., .tab
) or Autocad (.dxf
)
allow mixing different types of geometry in a single file, loading such
datasets opens a dialog to select geometries to use in order to have one
geometry per layer.
The Add Vector Layer and Add Raster Layer tabs allow loading of layers from source types other than File:
You can load specific vector formats like
ArcInfo Binary Coverage
,UK. National Transfer Format
, as well as the raw TIGER format of theUS Census Bureau
orOpenfileGDB
. To do that, you select Directory as Source type. In this case, a directory can be selected in the dialog after pressing … Browse.With the Database source type you can select an existing database connection or create one to the selected database type. Some possible database types are
ODBC
,Esri Personal Geodatabase
,MSSQL
as well asPostgreSQL
orMySQL
.Pressing the New button opens the Create a New OGR Database Connection dialog whose parameters are among the ones you can find in Creating a stored Connection. Pressing Open lets you select from the available tables, for example of PostGIS enabled databases.
O tipo de fonte Protocolo: HTTP(S), nuvem, etc. abre dados armazenados localmente ou na rede sejam publicamente acessíveis, ou em armazenamentos em nuvem particulares fornecidos por serviços comerciais. Os tipos de protocolo suportados são:
HTTP/HTTPS/FTP
, with a URI and, if required, an authentication.Cloud storage such as
AWS S3
,Google Cloud Storage
,Microsoft Azure Blob
,Alibaba OSS Cloud
,Open Stack Swift Storage
. You need to fill in the Bucket or container and the Object key.service supporting OGC
WFS 3
(still experimental), usingGeoJSON
orGEOJSON - Newline Delimited
format or based onCouchDB
database. A URI is required, with optional authentication.For all vector source types it is possible to define the Encoding or to use the setting.
13.1.3.2. Loading a mesh layer
A mesh is an unstructured grid usually with temporal and other components. The spatial component contains a collection of vertices, edges and faces in 2D or 3D space. More information on mesh layers at Working with Mesh Data.
To add a mesh layer to QGIS:
- dialog, either by selecting it from the menu or clicking the
Pressione o botão … Buscar para selecionar o arquivo. Vários formatos são suportados.
Select the layer and press Add. The layer will be added using the native mesh rendering.
13.1.3.3. Importing a delimited text file
Delimited text files (e.g. .txt
, .csv
, .dat
,
.wkt
) can be loaded using the tools described above.
This way, they will show up as simple tables.
Sometimes, delimited text files can contain coordinates / geometries
that you could want to visualize.
This is what Add Delimited Text Layer
is designed for.
Click the Open Data Source Manager icon to open the Data Source Manager dialog
Select the delimited text file to import (e.g.,
qgis_sample_data/csv/elevp.csv
) by clicking on the … Browse button.In the Layer name field, provide the name to use for the layer in the project (e.g.
Elevation
).Configure the settings to meet your dataset and needs, as explained below.
File format
Depois que o arquivo é selecionado, o QGIS tenta analisar o arquivo com o delimitador usado mais recentemente, identificando campos e linhas. Para permitir que o QGIS analise corretamente o arquivo, é importante selecionar o delimitador correto. Você pode especificar um delimitador escolhendo entre:
Records and fields
Some other convenient options can be used for data recognition:
Number of header lines to discard: convenient when you want to avoid the first lines in the file in the import, either because those are blank lines or with another formatting.
First record has field names: values in the first line are used as field names, otherwise QGIS uses the field names
field_1
,field_2
…Detect field types: automatically recognizes the field type. If unchecked then all attributes are treated as text fields.
Decimal separator is comma: you can force decimal separator to be a comma.
Trim fields: allows you to trim leading and trailing spaces from fields.
As you set the parser properties, a sample data preview updates at the bottom of the dialog.
Geometry definition
Once the file is parsed, set Geometry definition to
Point coordinates and provide the X field, Y field, Z field (for 3-dimensional data) and M field (for the measurement dimension) if the layer is of point geometry type and contains such fields. If the coordinates are defined as degrees/minutes/seconds, activate the DMS coordinates checkbox. Provide the appropriate Geometry CRS using the Select CRS widget.
Well known text (WKT) option if the spatial information is represented as WKT: select the Geometry field containing the WKT geometry and choose the approriate Geometry field or let QGIS auto-detect it. Provide the appropriate Geometry CRS using the Select CRS widget.
If the file contains non-spatial data, activate No geometry (attribute only table) and it will be loaded as an ordinary table.
Layer settings
Additionally, you can enable:
Use spatial index to improve the performance of displaying and spatially selecting features.
Use subset index to improve performance of subset filters (when defined in the layer properties).
Watch file to watch for changes to the file by other applications while QGIS is running.
At the end, click Add to add the layer to the map.
In our example, a point layer named Elevation
is added to the project
and behaves like any other map layer in QGIS.
This layer is the result of a query on the .csv
source file
(hence, linked to it) and would require
to be saved in order to get a spatial layer on disk.
13.1.3.4. Importing a DXF or DWG file
DXF
and DWG
files can be added to QGIS by simple drag-and-drop
from the Browser Panel.
You will be prompted to select the sublayers you would like to add
to the project. Layers are added with random style properties.
Nota
For DXF files containing several geometry types (point, line and/or polygon), the name of the layers will be generated as <filename.dxf> entities <geometry type>.
To keep the dxf/dwg file structure and its symbology in QGIS, you may want to use the dedicated
tool which allows you to:import elements from the drawing file into a GeoPackage database.
add imported elements to the project.
In the DWG/DXF Import dialog, to import the drawing file contents:
Input the location of the Target package, i.e. the new GeoPackage file that will store the data. If an existing file is provided, then it will be overwritten.
Especifique o sistema de referência de coordenadas dos dados no arquivo de desenho.
Check Expand block references to import the blocks in the drawing file as normal elements.
Check Use curves to promote the imported layers to a
curved
geometry type.Use the Import button to select the DWG/DXF file to use (one per geopackage). The GeoPackage database will be automatically populated with the drawing file content. Depending on the size of the file, this can take some time.
After the .dwg
or .dxf
data has been imported into the
GeoPackage database, the frame in the lower half of the dialog is
populated with the list of layers from the imported file.
There you can select which layers to add to the QGIS project:
At the top, set a Group name to group the drawing files in the project.
Check layers to show: Each selected layer is added to an ad hoc group which contains vector layers for the point, line, label and area features of the drawing layer. The style of the layers will resemble the look they originally had in *CAD.
Escolha se a camada deve estar visível na abertura.
Marcar a opção Mesclar camadas coloca todas as camadas em um único grupo.
Press OK to open the layers in QGIS.
13.1.3.5. Importing OpenStreetMap Vectors
The OpenStreetMap project is popular because in many countries no free geodata such as digital road maps are available. The objective of the OSM project is to create a free editable map of the world from GPS data, aerial photography and local knowledge. To support this objective, QGIS provides support for OSM data.
Using the Browser Panel, you can load an .osm
file to the
map canvas, in which case you’ll get a dialog to select sublayers based on the
geometry type.
The loaded layers will contain all the data of that geometry type
in the .osm
file, and keep the osm
file data structure.
13.1.3.6. Camadas SpatiaLite
The first time you load data from a SpatiaLite database, begin by:
ou digitando Ctrl+Shift+L
This will bring up a window that will allow you either to connect to a
SpatiaLite database already known to QGIS (which you choose from the
drop-down menu) or to define a new connection to a new database. To define a
new connection, click on New and use the file browser to point to
your SpatiaLite database, which is a file with a .sqlite
extension.
O QGIS também suporta visualizações editáveis no SpatiaLite.
13.1.3.7. GPS
Loading GPS data in QGIS can be done using the core plugin GPS Tools
.
Instructions are found in section Complemento GPS.
13.1.3.8. GRASS
Working with GRASS vector data is described in section Integração com SIG GRASS.
13.1.4. Formatos personalizados QGIS
QGIS proposes two custom formats:
Temporary Scratch Layer: a memory layer that is bound to the project (see Creating a new Temporary Scratch Layer for more information)
Virtual Layers: a layer resulting from a query on other layer(s) (see Creating virtual layers for more information)
13.1.5. QLR - QGIS Layer Definition File
Layer definitions can be saved as a
Layer Definition File (QLR -
.qlr
) using
in the layer
context menu.
The QLR format makes it possible to share “complete” QGIS layers with other QGIS users. QLR files contain links to the data sources and all the QGIS style information necessary to style the layer.
QLR files are shown in the Browser Panel and can be used to add layers (with their saved styles) to the Layers Panel. You can also drag and drop QLR files from the system file manager into the map canvas.
13.1.6. Connecting to web services
With QGIS you can get access to different types of OGC web services (WM(T)S, WFS(-T), WCS, CSW, …). Thanks to QGIS Server, you can also publish such services. QGIS Server Guide/Manual contains descriptions of these capabilities.
13.1.6.1. Using Vector Tiles services
Vector Tiles services can be found in the Vector Tiles
top level entry in the Browser.
You can add a service by opening the context menu with a right-click
and choosing New Generic Connection ….
You set up a service by adding a Name and a URL.
The Vector Tiles Service must provide tiles in .pbf
format.
The dialog provides two menus to define the
Min. Zoom Level and the
Max. Zoom Level. Vector Tiles have a
pyramid structure. By using these options you have the opportunity
to individually generate layers from the tile pyramid. These layers
will then be used to render the Vector Tile in QGIS.
For Mercator projection (used by OpenStreetMap Vector Tiles) Zoom Level 0
represents the whole world at a scale of 1:500.000.000. Zoom Level 14
represents the scale 1:35.000.
Fig. 13.13 shows the dialog with the
MapTiler planet Vector Tiles service configuration.
By using New ArcGIS Vector Tile Service Connection … you can connect to ArcGIS Vector Tile Services.
13.1.6.2. Using XYZ Tile services
XYZ Tile services can be found in the XYZ Tiles top level entry in the Browser. By default, the OpenStreetMap XYZ Tile service is configured. You can add other services that use the XYZ Tile protocol by choosing New Connection in the XYZ Tiles context menu (right-click to open). Fig. 13.14 shows the dialog with the OpenStreetMap XYZ Tile service configuration.
Configurations can be saved (Save Connections) to XML and loaded (Load Connections) through the context menu. Authentication configuration is supported. The XML file for OpenStreetMap looks like this:
<!DOCTYPE connections>
<qgsXYZTilesConnections version="1.0">
<xyztiles url="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
zmin="0" zmax="19" tilePixelRatio="0" password="" name="OpenStreetMap"
username="" authcfg="" referer=""/>
</qgsXYZTilesConnections>
Once a connection to a XYZ tile service is set, right-click over the entry to:
Edit… the XYZ connection settings
Delete the connection
- ,
Add layer to project: a double-click also adds the layer
View the Layer Properties… and get access to metadata and a preview of the data provided by the service. More settings are available when the layer has been loaded into the project.
Examples of XYZ Tile services:
OpenStreetMap Monochrome: URL:
http://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png
, Min. Zoom Level: 0, Max. Zoom Level: 19.Google Maps: URL:
https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}
, Min. Zoom Level: 0, Max. Zoom Level: 19.Temperatura do Mapa Meteorológico Aberto: URL:
http://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid={api_key}
Nível Mín. de Zoom: 0, :guilabel: Nível Máx. de Zoom`: 19.