eyecatch

How to Export GIS Data to GeoPackage or CSV

Published: Last updated:
This article uses QGIS 3.40. The current LTR is 3.44.

What you'll learn


  • The basics of the export feature in QGIS
  • Steps for converting your data to other file formats such as GeoPackage

Recommended for


  • Anyone who wants to save a temporary scratch layer as a vector layer
  • Anyone who wants to convert a Shapefile to a modern format such as GeoPackage
  • Anyone who wants to export attribute table data as CSV and use it in Excel

Introduction

In QGIS, you often need to save a layer you created temporarily or convert it to a different file format. The export feature helps in exactly these situations. With it, you can save a layer you are working on as a file, or convert it to another format and output it.

This article covers the basics of “Save As” and some practical use cases.

What is the export feature?

The export feature saves a QGIS layer in a variety of formats. Because you can choose the destination and file format freely, it is useful in cases like these:

  • Save a temporary scratch layer created during your work to a file
  • Convert a layer to a different file format (for example, from Shapefile to GeoPackage)
  • Save an edited or filtered layer
  • Output a layer's attributes as CSV to analyze them in Excel
  • Convert a layer to a different coordinate reference system (CRS)

Export steps

This section walks through the steps. As an example, convert a .shp Shapefile to a layer in GeoPackage format, the standard file format of QGIS.

To learn more about GeoPackage, see the article below.

First, in the Layers panel, right-click the layer you want to save and click Export → Save Features As.

Click Save Features As
Click Save Features As

The Save Vector Layer as dialog opens. Use it to set the output file format, the save path, the file name, and more.

The following settings convert the Shapefile to GeoPackage format.

  1. Format: Select the file format to convert to. Here, click ESRI Shapefile and select GeoPackage from the list.
  2. File name: Specify where to save the file. Here, click the ... button and specify the file name and location.
  3. Layer name: Appears when you select GeoPackage as the format. Enter a layer name as needed.

That completes the basic settings. Click the OK button at the lower right.

Save Vector Layer as dialog
Save Vector Layer as dialog

When processing finishes, the saved file appears as a layer in the Layers panel. If Add saved file to map is checked in the export dialog, QGIS adds the layer automatically.

The saved file added as a layer
The saved file added as a layer

A message bar also appears at the top of the map canvas and shows the save path under Layer Exported. Click the path, and you can see the GeoPackage file in the location you specified.

The GeoPackage file saved at the specified path
The GeoPackage file saved at the specified path

Export steps by use case

Save a temporary scratch layer

When you create a layer without specifying a save location, such as with a Processing tool, QGIS keeps it in memory as a “temporary scratch layer.”

A temporary scratch layer shows a memory icon in the Layers panel
A temporary scratch layer shows a memory icon in the Layers panel

These layers are lost when you close QGIS, so you need to save any data you want to keep.

An error message appears when you try to close a project with an unsaved temporary scratch layer
An error message appears when you try to close a project with an unsaved temporary scratch layer

If you want to keep a temporary scratch layer, save it to a file format such as GeoPackage with the same steps as above.

Convert the CRS

QGIS supports many CRSs, and converting between them is easy too. To convert the CRS, set the target CRS in CRS in the export dialog.

Select a CRS in the Save Vector Layer as dialog
Select a CRS in the Save Vector Layer as dialog

For how QGIS handles coordinate reference systems, see the article below.

Export the attribute table as CSV

When you work with vector data in QGIS, you may want to analyze the attribute table in spreadsheet software such as Excel or create charts from it. In that case, select Comma Separated Value [CSV] as the format when you export.

Save as CSV from the Save Vector Layer as dialog
Save as CSV from the Save Vector Layer as dialog

Open the exported CSV file in Excel, and you can see that it contains the contents of the original attribute table.

The CSV file opened in Excel
The CSV file opened in Excel

Convert CSV data to a vector layer

In QGIS, you can add tabular data, such as a CSV file with latitude and longitude values, to the map. You can display and make simple edits to the data as CSV, but it is more efficient to convert it to a vector data format.

For how to add CSV data to QGIS and convert it to a vector data format such as Shapefile, see the article below.

Create a layer from selected features only

You can create a layer from only specific features of a vector layer.

First, select the features you want in the new layer.

Select the features you want in the new layer
Select the features you want in the new layer

When the selection is done, right-click the layer in the Layers panel and click Export. Save Selected Features As becomes available, so click it.

Click Save Selected Features As
Click Save Selected Features As

Next, confirm that Save only selected features is checked. The rest of the export is the same as usual, so specify the save location and other settings and export.

Export dialog with Save only selected features checked
Export dialog with Save only selected features checked

When processing finishes, the selected features are added as a new layer.

The selected features added as a new layer
The selected features added as a new layer

Export options

You can set many other options when you export.

The main options are as follows.

  1. Encoding: Save the file with the character encoding you specify.
  2. Save only selected features: Export only the selected features.
  3. Select fields to export and their export options: Export only some columns of the attribute table, or change the column names in the export.
  4. Persist layer metadata: Save a copy of any layer metadata on the source layer.
  5. Geometry: Configure the geometry capabilities of the output layer.
  6. Extent: Use the extent selector to limit the exported data to only part of the layer.
Save Vector Layer as dialog for exporting
Save Vector Layer as dialog for exporting

Conclusion

The export feature in QGIS is very useful for saving layers permanently and converting file formats. Saving temporary scratch layers and converting formats in particular come up often in daily work. Even QGIS beginners can work far more efficiently by knowing this feature. Put it to use.

About the author
QGIS LAB Editorial Team
QGIS LAB Editorial Team

QGIS LAB is a comprehensive information hub for QGIS, the open-source GIS software. Under the concept of “Geospatial for Greater Good,” we share the knowledge and skills to open up the world through location data.