QGIS|How to distribute the result data correctly?

How does QGIS distribute the result data correctly?

 

 

Why did I make a beautiful map and distribute it to others, but I did not see the same look on my computer after opening it? This question is actually how to correctly distribute your own results data .

 

The first thing to be clear is that in QGIS, the data source stores spatial elements such as points, lines, and regions, which are represented as individual data files, such as Shapefile files. Style is the way data is expressed in the map window, including colors, symbols, line styles, etc. After the data source has a style, it is called a layer. Therefore, the data source and the layer are two concepts that have a certain relationship, but they cannot be completely equal.

 

When distributing the result data, the content to be packaged and distributed should be determined according to requirements. If the receiver only needs the data itself and does not care about the data visualization effect, then directly package and copy the data source to him. If the receiver wants a beautiful map, in addition to the data source, the layer style must be distributed to the receiver to get the same map visualization effect.

 

Here we discuss the second case, that is, how to correctly distribute the data source and layer style.

 

 01 Results data

 

The contents of the data to be distributed in this article include:

 

Vector data surface layer: ne_110m_admin_0_countries provided by NaturalEarth.

 

 

Map: Two thematic maps based on the "GDP_MD_EST" (GDP) and "POP_EST" (population) fields of the ne_110m_admin_0_countries layer. 

 

  •  Coloring map: grading according to GDP per capita and coloring according to national elements.

 

 

  • Pie chart: The color of the pie chart represents GDP per capita, and the size of the pie represents the population of the country.

 

 

 02 Save the data source

 

When distributing data achievements, it is generally recommended to create a separate directory on the hard disk to store all the contents of this distribution. For example, the result directory of this article is: "H:\Data Results\".

 

Right-click the data to be saved in the [Browse] panel, select [Export Layer] -> [To File], and open the [Save Vector Layer As] dialog box.

 

 

In the [Save Vector Layer As] dialog box, [Format] keep the default "ESRI Shapefile", click the [...] button to the right of [File name], and set the save path: "H:\Data Results\ne_110m_admin_0_countries. shp", click the [OK] button.

 

 

Because ESRI's Shapefile file is almost the default GIS industry data exchange standard format, Shapefile is generally provided when data results are submitted. Shapefile files are composed of multiple files with different extensions. There are many files and sometimes they need to be packaged in advance.

 

 

If the recipient also uses QGIS, it is strongly recommended to use GeoPackage format for data sharing. The GeoPackage format can be regarded as a file database, storing multiple layers in a single file, which is very convenient for data copying.

 

In the [Save Vector Layer As] dialog box, do the following settings to export the layer to Geopackage format:

 

 

The Geopackage format uses *.gpkg as the extension. Multiple layers are stored in one file. You only need to copy the *.gpkg file to share data of multiple layers.

 

 

 03 Save and open layer styles

 

After the data set is packaged, the issue of layer style distribution is dealt with. In QGIS, layer styles can be saved in three types of files: Project File, layer definition file (*.qlr) and layer style file (*.qml).

 

  • Project File

 

The QGIS project file (*.qgz) saves the current working status of the QGIS window, including the opened data (layer) path, layer symbol and style, map window coordinate reference system, print layout, vectorization settings, and associated attributes Table etc. Click the menu [Project] -> [Save] or [Project] -> [Save As] to save all the states of the current QGIS window.

 

 

In the pop-up [Save Project As] dialog box, set the name and path of the project file storage, and click [Save].

 

 

Pack the entire "H:\Data Achievements\" folder, and you can use it for distribution.

 

As the party who gets the data results, you need to open the project file as follows:

 

Click the [Open Project] button on the toolbar, and in the pop-up [Select a QGIS Project File to Open] dialog box, find the project file "Data Results.qgz" and double-click to open it.

 

 

In most cases, opening the project file will encounter the [Process Unavailable Layers] dialog box, prompting that some layers are not available, and the name, type, and data source of the layer (for vector data) are listed in the dialog box. Said as OGR) and the path of the data source. Below are four buttons: [Keep unavailable layers], [Remove unavailable layers], [Browse] and [Apply changes].

 

In fact, this dialog box pops up mainly because QGIS can't find the data source corresponding to the layer . Carefully observe the path of the data source and find that the path is the path on the data producer's computer, which is different from the path where the data is stored by the receiver, so QGIS naturally cannot find the data.

 

Select the layer and click the [Browse] button to repair the data source path.

 

 

In the pop-up [Select File to Replace...] dialog box, find the path of the data source on this machine, and click the [Open] button. Return to [Process Unavailable Layer], you can see that the data source path is changed to the path just set.

 

 

After replacing the path of the error layer, click the [Apply Changes] button, and then click the [X] in the upper right corner to close the dialog box.

 

 

Return to the QGIS main window, you can see that the data has been opened normally.

 

 

When opening the project file, if you directly close the [Process Unavailable Layers] dialog box, you will see an empty map window. The layer names and corresponding styles are listed in the [Layer] panel, to the right of the layer name A button appears , hover the mouse over the button, and it prompts "Layer is not available! The layer data source is not found, click Set New Data Source".

 

 

Click at this time to pop up the [Select Data Source] dialog box, find the correct data source location, and fix the layer error.

 

 

  • QGIS layer definition file

 

The layer definition file (*.qlr) of QGIS is an XML format file that saves the data source link of the layer and the style information of the layer.

 

Right-click the layer to be shared in the [Layer] panel, and select [Export] -> [Save as layer definition file].

 

 

In the pop-up [Save as Layer Definition File] dialog box, set the storage path and file name, such as "H:\data results\countries-rulebase.qlr", and click [Save] to close the dialog box.

 

 

For the party who gets the data, you can directly find the location of the layer definition file in the [Browse] panel and drag it to the map window.

 

 

Similarly, if the path of the data source is different from the path of the provider, the (Layer is not available!) prompt will appear in the [Layer] panel. Just follow the steps to repair the data source above to repair the layer.

 

 

  • Layer style file (QGIS Style File, *.qml)

 

QGIS Style File is a file stored in XML format, which saves layer style information, including symbolization definition, symbol size, rotation angle, label, transparency, blending mode, etc.

 

Right-click the layer name in the [Layer] panel, and select [Export] -> [Save as QGIS Layer Style File...], and a dialog box will pop up.

 

 

In the [Save as QGIS Layer Style File] dialog box, set the storage path and file name, such as: "H:\Data Achievements\country-rulebase.qml", click the [Save] button to close the dialog box.

 

 

Follow the same steps to save the style files of other layers in sequence. Then package and distribute with the data source.

 

For the party who gets the data, first find the data source in the [Browse] panel and drag it to the map window.

 

 

QGIS uses random colors to render the data. Right-click the layer name in the [Layer] panel to open the properties dialog box.

 

 

Switch to the [Symbolization] tab, click the [Style] button in the lower left corner, expand the drop-down menu, and select [Load Style...].

 

 

In the pop-up [Database Style Management] dialog box, click the [...] button on the right side of [File], find the layer style file, and fill in the path in the text box. Click the [Load Style] button and click [X] in the upper right corner to return to the Properties dialog box.

 

 

In the properties dialog box, you can see that the style has been loaded, click the [OK] button to close the dialog box and return to the map window.

 

 

The effect after loading the layer style is as follows:

 

 

Why has the map background not changed? This is because the map background is set by the project properties and has nothing to do with the layer. Therefore, the layer style file and the layer definition file will not save the map background color and need to be set separately.

 

Click the menu [Project] -> [Properties] to open the project properties dialog box, switch to the [General] tab, and click [Background Color] to set the map background.

 

 

The final effect is as follows:

 

 

It is recommended to use Project File to distribute QGIS data and map results. If the project file and the data source file are in the same directory, the project file uses a relative path to store the data source path, which can avoid the situation that the layer cannot be found when the project file is opened.

 


Copyright Notice

 

This article welcomes reprinting, please indicate the source when reprinting.

 

 

Guess you like

Origin blog.csdn.net/QGISClass/article/details/108994001