` `
Layers can be created in many ways, including:
QGIS also provides tools to import/export different formats.
QGIS allows you to create new Shapefile layers, new SpatiaLite layers, new GPX layers and new Temporary Scratch layers. Creation of a new GRASS layer is supported within the GRASS plugin. (Please refer to section Criando uma nova camada vectorial GRASS for more information on creating GRASS vector layers.)
To create a new Shapefile layer, choose Create Layer ‣ New Shapefile Layer... from the Layer menu. The New Shapefile Layer dialog will be displayed as shown in figure_create_shapefile. Choose the type of layer (point, line or polygon) and the CRS (coordinate reference system).
Note that QGIS does not yet support creation of 2.5D features (i.e., features with X,Y,Z coordinates).
To complete the creation of the new Shapefile layer, add the desired attributes by specifying a name and type for each attribute and clicking on the [Add to fields list] button. A first ‘id’ column is added by default but can be removed, if not wanted. Only Decimal number , Whole number , Text data and Date attributes are supported. Additionally, depending on the attribute type, you can also define the length and precision of the new attribute column. Once you are happy with the attributes, click [OK] and provide a name for the Shapefile. QGIS will automatically add the .shp extension to the name you specify. Once the Shapefile has been created, it will be added to the map as a new layer, and you can edit it in the same way as described in section Digitalizar uma camada existente.
To create a new SpatiaLite layer for editing, choose New ‣ New SpatiaLite Layer... from the Layer menu. The New SpatiaLite Layer dialog will be displayed as shown in Figure_create_spatialite.
The first step is to select an existing SpatiaLite database or to create a new SpatiaLite database. This can be done with the browse button to the right of the database field. Then, add a name for the new layer, define the layer type, and specify the coordinate reference system with [Specify CRS]. If desired, you can select Create an autoincrementing primary key.
To define an attribute table for the new SpatiaLite layer, add the names of the attribute columns you want to create with the corresponding column type, and click on the [Add to attribute list] button. Once you are happy with the attributes, click [OK]. QGIS will automatically add the new layer to the legend, and you can edit it in the same way as described in section Digitalizar uma camada existente.
Further management of SpatiaLite layers can be done with the DB Manager. See Módulo Gestor BD.
To create a new GeoPackage layer go to Layer ‣ New ‣ New GeoPackage Layer.... The New GeoPackage Layer dialog will be displayed as shown in figure_create_geopackage.
The first step is to select an existing GeoPackage or create a new one. This can be done by pressing the ellipses [...] button at the right of the Database field. Then, give a name for the new layer, define the layer type and specify the coordinate reference system with [Specify CRS].
To define an attribute table for the new GeoPackage layer, add the names of the attribute columns you want to create with the corresponding column type, and click on the [Add to fields list] button. Once you are happy with the attributes, click [OK]. QGIS will automatically add the new layer to the legend, and you can edit it in the same way as described in section Digitalizar uma camada existente.
To create a new GPX file, you need to load the GPS plugin first. Plugins ‣ Plugin Manager... opens the Plugin Manager Dialog. Activate the GPS Tools checkbox.
When this plugin is loaded, choose New ‣ Create new GPX Layer... from the Layer menu. In the Save new GPX file as dialog, choose where to save the new file and press [Save]. Three new layers are added to the Layers Panel: waypoints, routes and tracks with predefined structure.
Temporary Scratch Layers are in-memory layers, meaning that they are not saved on disk and will be discarded when QGIS is closed. They can be handy to store features you temporarily need or as intermediate layers during geoprocessing operations.
Empty, editable temporary scratch layers can be defined using Layer ‣ Create Layer ‣ New Temporary Scratch Layer. Here you can create Multipoint, Multiline and Multipolygon Layers beneath Point, Line and Polygon layers.
You can also create Temporary Scratch Layers from the clipboard. See Creating new layers from the clipboard.
Both raster and vector layers can be saved in a different format and/or reprojected to a different coordinate reference system (CRS) using the Save As... function in the layer context menu (by right-clicking in the layer in the layer tree) or in the Layer ‣ Save As... menu.
The Save As dialog shows several parameters to change the behavior when saving the layer. Common parameters for raster and vector are:
However, some parameters are specific to raster and vector formats:
Depending on the format of export, some of these options are available or not:
Note
OGR Feature Styles are a way to store style directly in the data as a hidden attribute. Only some formats can handle this kind of information. KML, DXF and TAB file formats are such formats. For advanced users, you can read the OGR Feature Styles specification document.
Tip
Overriding layer geometry type makes it possible to do things like save a geometryless table (e.g. .csv file) into a shapefile WITH any type of geometry (point, line, polygon), so that geometries can then be manually added to rows with the Add Part tool .
When saving a vector layer into an existing file, depending on the capabilities of the output format (Geopackage, SpatiaLite, FileGDB...), the user can decide whether to:
For formats like ESRI Shapefile, MapInfo .tab, feature append is also available.
Besides the Save As... dialog which provides options to export a single layer to another format, including *.DXF, QGIS provides another tool to export multiple layers as a single DXF layers. It’s accessible in the Project ‣ DXF Export... menu.
The DXF Export dialog allows the user to:
indicate the destination layer file;
choose the symbology mode and scale (see the OGR Feature Styles note);
select the encoding and CRS;
check the loaded layers to include in the DXF files or pick them from an existing visibility preset.
For each layer, you can choose a field whose values are used to split features in generated destination layers in the DXF output. You can also choose to Use the layer title as name if set and keep features grouped.
choose to only Export features intersecting the current map extent.
Features that are on the clipboard can be pasted into a new layer. To do this, Select some features, copy them to the clipboard, and then paste them into a new layer using Edit ‣ Paste Features as ‣ and choosing:
A new layer, filled with selected features and their attributes is created and added to map canvas if asked.
Note
Creating layers from clipboard applies to features selected and copied within QGIS and also to features from another source defined using well-known text (WKT).
Virtual layers are a special kind of vector layer. They allow you to define a layer as the result of an SQL query involving any number of other vector layers that QGIS is able to open. Virtual layers do not carry data by themselves and can be seen as views to other layers.
To create a virtual layer, open the virtual layer creation dialog by clicking on Add Virtual Layer in the Layer menu or from the corresponding toolbar.
The dialog allows you to specify a Layer name and an SQL Query. The query can use the name (or id) of loaded vector layers as tables, as well as their field names as columns.
For example, if you have a layer called airports, you can create a new virtual layer called public_airports with an SQL query like:
SELECT *
FROM airports
WHERE USE = "Civilian/Public"
The SQL query will be executed, regardless of the underlying provider of the airports layer, even if this provider does not directly support SQL queries.
Joins and complex queries can also be created, for example, to join airports and country information:
SELECT airports.*, country.population
FROM airports
JOIN country
ON airports.country = country.name
Note
It’s also possible to create virtual layers using the SQL window of Módulo Gestor BD.
Besides the vector layers available in the map canvas, the user can add layers to the Embedded layers list, which he can use in queries without the need to have them showing in the map canvas or Layers panel.
To embed a layer, click Add and provide the Local name, Provider, Encoding and the path to the Source.
The Import button allows adding layers loaded in the map canvas into the Embedded layers list. This allows to later remove those layers from the Layers panel without breaking any existent query.
The underlying engine uses SQLite and SpatiaLite to operate.
It means you can use all of the SQL your local installation of SQLite understands.
Functions from SQLite and spatial functions from SpatiaLite can also be used in a virtual layer query. For instance, creating a point layer out of an attribute-only layer can be done with a query similar to:
SELECT id, MakePoint(x, y, 4326) as geometry
FROM coordinates
Functions of QGIS expressions can also be used in a virtual layer query.
To refer the geometry column of a layer, use the name geometry.
Contrary to a pure SQL query, all the fields of a virtual layer query must be named. Don’t forget to use the as keyword to name your columns if they are the result of a computation or function call.
With default parameters set, the virtual layer engine will try its best to detect the type of the different columns of the query, including the type of the geometry column if one is present.
This is done by introspecting the query when possible or by fetching the first row of the query (LIMIT 1) at last resort. Fetching the first row of the result just to create the layer may be undesirable for performance reasons.
The creation dialog allows to specify different parameters:
The virtual layer engine tries to determine the type of each column of the query. If it fails, the first row of the query is fetched to determine column types.
The type of a particular column can be specified directly in the query by using some special comments.
The syntax is the following: /*:type*/. It has to be placed just after the name of a column. type can be either int for integers, real for floating point numbers or text.
For instance:
SELECT id+1 as nid /*:int*/
FROM table
The type and coordinate reference system of the geometry column can also be set thanks to special comments with the following syntax /*:gtype:srid*/ where gtype is the geometry type (point, linestring, polygon, multipoint, multilinestring or multipolygon) and srid an integer representing the EPSG code of a coordinate reference system.
When requesting a layer through a virtual layer, indexes of this source layer will be used in the following ways:
A specific syntax exists to handle spatial predicates in requests and triggers the use of a spatial index: a hidden column named _search_frame_ exists for each virtual layer. This column can be compared for equality to a bounding box. Example:
SELECT *
FROM vtab
WHERE _search_frame_=BuildMbr(-2.10,49.38,-1.3,49.99,4326)
Spatial binary predicates like ST_Intersects are significantly sped up when used in conjunction with this spatial index syntax.