-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexporting_data.html
155 lines (151 loc) · 11.2 KB
/
exporting_data.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<html>
<head>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-179299301-2');
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Exporting Data</title>
<link rel="stylesheet" type="text/css" href="../css/base_styles.css">
</head>
<body>
<header></header>
<div class="sidenav">
<ul>
<li><a href="..">Home</a></li>
<li><a href="../Basics/" class="active">Basic GIS Operations</a></li>
<li><a href="../Analysis/" >Analysis Toolbox</a></li>
<li><a href="../Conversion/">Conversion Toolbox</a></li>
<li><a href="../Data Management/">Data Management Toolbox</a></li>
<li><a href="../Geocoding/">Geocoding Toolbox</a></li>
<li><a href="../Network Analyst/">Network Analyst Toolbox</a></li>
<li><a href="../Spatial Analyst/">Spatial Analyst Toolbox</a></li>
<li><a href="../Spatial Statistics/">Spatial Statistics Toolbox</a></li>
</ul>
</div>
<div class="content">
<h1>Saving Data From Different Sources and Format Conversions</h1>
<ol id="top">
<li>
<ul><h4><u><a href="#vector">Vector Formats</a></u></h4>
<li><a href="#vectorfile">Saving To a Vector Single File formats (*.SHP, *.GeoJSON)</a></li>
<li><a href="#fgdb">Saving To an ESRI FileGeoDataBase (*.gdb)</a></li>
<li><a href="#db">Saving To a DataBase</a></li>
<li><a href="#dbfile">Saving To a Layer in a Multiple Layers Database</a></li>
</ul>
</li>
<li>
<ul><h4><u><a href="#raster">Raster Foramts</a></u></h4>
<li><a href="#rasterfile">Saving To a Single Raster File</a></li>
<li><a href="#rasterdb">Saving a Raster inside a Database</a></li>
</ul>
</li>
<li>
<ul><h4><u><a href="#style">Saving Style Information</a></u></h4>
<li><a href="#qml">Saving Style Information From A Local Layer</a></li>
</ul>
</li>
</ol>
<br>
<a href="../Basics/basics.html">Back To Basic Concepts</a><br>
<a href="..">Back To Homepage</a><br>
<br>
<br><h1 id="vector">Vector Formats</h1><br>
<h2>*A note on Web Feature Services (WFS)</h2>
<p>Some Web Feature Services layers can be saved with the methodes for saving vector data below,
this means that both the data itself and in some cases the symbology information can saved to your computer and used locally.
This is common with ESRI ArcGIS Online WFS, and in some cases ArcGIS Online Web Mapping Services can be loaded as WFS and saved just the same.
</p><br>
<h2 id="vectorfile">Saving To a Vector Single File formats (*.SHP, *.GeoJSON)</h2>
<p>
Saving a Layer to an ESRI Shapefile or GeoJSON file is very easy and simple in QGIS.
What you need to do is just right-click the layer you want to save, <b>Export</b>-><b>Save Features As...</b> or <b>Save Selected Features As..</b> if you want to save only your selected features.<br>
</br><img src="img/export_vector_db0.PNG" height=700px width=900px/></br>
<br>You then need to select the format you want to save in at the top of the window, in this example you can see the option for GeoJSON and the one for selected features in Shapefile.<br>
</br><span><img src="img/export_vector_db1.PNG" height=670px width=600px/><img src="img/export_vector_db2.PNG" height=670px width=600px/></span></br>
<br>If the file exists you will be asked to overwrite, cancel the save or if you are saving as GeoJSON you will be given the option to append the layer.<br>
</br><img src="img/export_vector_db3.PNG" height=125px width=505px/></br><br>
And thats it, Simple and easy to use, and now you know how to do that in Open Source.</br>
</p>
</br><a href="#top">Go back to the top</a><br>
<h2 id="fgdb">Saving To an ESRI FileGeoDataBase (*.gdb)</h2>
<p>
You can read data from an ESRI FileGeoDataBase with the base version of QGIS.
however, if you want to be able to edit and rewrite the layers into the database, you will need the gdal-filegdb driver.
you can install it using the <a href="">OSGEO4W</a> installer.
just select to install it like so:</br>
</br><img src="img/install_gdalfgdb_db0.PNG" height=450px width=650px/></br></br>
After your installation has the new library plugin (gdal-fgdb) you can simply save your layers into an existing ESRI FileGeoDataBase or create a new one while saving.
this can be done by right-clicking the layer you want to save, <b>Export</b>-><b>Save Features As...</b> or <b>Save Selected Features As..</b> if you want to save only your selected features.<br>
</br><img src="img/export_vector_db0.PNG" height=700px width=900px/></br>
You then need to select the format you want to save in at the top of the window, simply choose <b>ESRI FileGDB</b>. Now here you will most likely get annoyed, since the expected input in the browse window is a file, and not a folder.
My suggestion, just navigate to where your *.gdb folder is, or where you want to create it and simply copy the full path for an existing one or just add the name you want to give to a new FileGeoDataBase followed by <b>.gdb</b>.
In this example the folder <i>training2</i> doesn't exist yet.<br>
<br><img src="img/export_fgdb_db0.PNG" height=670px width=600px/></br><br>
And thats it, Simple and easy to use, and now you know how to do that in Open Source.</br>
</p>
</br><a href="#top">Go back to the top</a><br>
<h2 id="db">Saving To a DataBase</h2>
<h3>*Why the example uses only PostgreSQL</h3>
<ol>
<li>Because QGIS plays very well with PostGIS, which is an extension for PostgreSQL</li>
<li>Because every section takes time to write, and I have and use PostgreSQL.</li>
<li>I do plan to add other SQL databases in the future, if you can document them yourself commits are welcome</li>
</ol>
<h3>Using The DB Manager</h3>
<p>
Exporting a layer to an existing database connection can be done by performing the foolowing steps.
From the top menu select <b>Database</b> and then select <b>DB Manager</b>.<br>
</br><img src="img/export_db_db0.PNG" height=215px width=905px/></br></br>
Then select the database you want to save into in the DB Manager window.
In this example i'm using the <b>qgistest</b> database stored in a PostgreSQL host with the PostGIS extansion enabled.
QGIS doesn't have to connect only to spatial databases but when saving data and working in the DB Manager those are all the options possible.<br>
</br><img src="img/export_db_db1.PNG" height=640px width=750px/></br></br>
You can notice that QGIS treats GeoPackage connections as database connectins. that is because they technically are. GeoPackage files are a modification of SQLite database files and can behave similliar to them.
The next step you have to take is click on the <b>Import Layer/File...</b>, this will open a new window which should look like this.
The window allows you to choose a layer from the workspace with the dropdown menu, or a file with the <kbd>...</kbd> button next to it.<br>
</br><img src="img/export_db_db2.PNG" height=450px width=500px/></br></br>
You can now select the schema in the database you want to save the layer to and the name for the table.
The options below allow you select the primary key column, the geometry column to calculate geometry from if you want to convert a table to a spatial table.
It's also possible to reproject your layer to a new spatial reference, select the encoding, split multipart geometries to single part, convert field names to lowercase (recommended in PostgreSQL) and create a spatial index.
Be patient as the process can take some time, depending on the size of your layer, until you get the message that the <i>Import was successful</i><br>
</br><img src="img/export_db_db3 .PNG" height=125px width=195px/></br></br>
And thats it, Simple and easy to use, and now you know how to do that in Open Source.</br>
</p>
</br><a href="#top">Go back to the top</a><br>
<h2 id="dbfile">Saving To a Layer in a Multiple Layers Database</h2>
<h3>Saving in GeoPackage, Spatialite, Sqlite etc.. </h3>
<p>
GeoPackage, Sqlite and Spatialite files are databases built from a single file, with GeoPackage and Spatialite being able to store spatial data.
They store data like any other database, but can be shared very easily since they are formed solely from one file.
To store vector data in them you right-click the layer you want to save then <b>Export</b>-><b>Save Features As...</b> or <b>Save Selected Features As..</b> if you want to save only your selected features.<br>
</br><img src="img/export_vector_db0.PNG" height=700px width=900px/></br>
You then need to select the format you want to save in at the top of the window, simply choose <b>GeoPackage</b> for this example, but the same options are applicable for <b>Sqlite</b> and <b>Spatialite</b>.<br>
You can either create a new file by choosing a path and adding a name or an existing one by choosing it.<br>
</br><img src="img/export_gpkg_db0.PNG" height=670px width=590px/></br>
<font size="5"><b>!!!</b></font> Pay attention that the default layer name is the same name that the file has, if you want to store multiple layers on the file make sure you change the <b>Layer Name</b>.<br>
</br><img src="img/export_gpkg_db1.PNG" height=670px width=590px/></br>
Notice that you can choose the <i>GEOMETRY</i> column in the options here, this means you can convert a regular table to a spatial layer while exporting it.<br>
To save the file you simply click <kbd>OK</kbd>, <br>
And thats it, Simple and easy to use, and now you know how to do that in Open Source.</br>
</p>
</br><a href="#top">Go back to the top</a><br>
<br><h1 id="raster">Raster Formats</h1><br>
<h2 id="rasterfile">Saving To a Single Raster File</h2>
<p>
</p>
</br><a href="#top">Go back to the top</a><br>
<h2 id="rasterdb">Saving a Raster inside a Database</h2>
<p>
</p>
</br><a href="#top">Go back to the top</a><br>
<br><h1 id="style">Saving Style Information</h1><br>
<h2 id="qml">Saving Style Information From A Local Layer</h2>
<p>
</p>
</br><a href="#top">Go back to the top</a><br>
</div>
</body>
</html>