QuartzMap/docs/source/createdb.rst

101 lines
1.9 KiB
ReStructuredText
Raw Normal View History

2024-07-13 22:44:51 +00:00
**********************
2024-05-09 13:56:30 +00:00
Create Database
2024-07-13 22:44:51 +00:00
**********************
.. contents:: Table of Contents
Option 1: Export layers to GeoPackage
===================================
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
If you do not have an existing PostGIS database, you can create one from your QGIS Project.
2024-05-09 13:56:30 +00:00
2024-07-13 22:36:16 +00:00
You have two options for doing so.
2024-07-13 22:44:51 +00:00
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
1. Export your layer(s)
------------------------
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
Right click on layer > Export > Save As > GeoPackage
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
.. image:: images/create-db-1.png
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
2. Upload GeoPackages
-------------------------
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
Go to Data Sources > Create and upload your GeoPackage(s).
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
.. image:: images/create-db-2.png
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
3. Set Layers to Data Source
-------------------------------
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
Set your map layer(s) to use your new Data Source
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
.. image:: images/select-data.png
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
4. Change QGIS Data Source
-------------------------------
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
Optionally, you can now also set your QGIS Project to use your new database as well.
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
Just right click on the layer(s) > Change Data Source
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
Select the PostGIS data source you created above.
2024-05-09 13:56:30 +00:00
2024-05-09 14:01:18 +00:00
.. image:: images/create-db-3.png
2024-05-09 13:56:30 +00:00
2024-07-13 22:36:16 +00:00
2024-07-13 22:44:51 +00:00
Option 2: Create Empty DB and Use DB Manager
===================================
2024-07-13 22:36:16 +00:00
2024-07-13 23:12:32 +00:00
1. Create an empty database
2024-07-13 22:36:16 +00:00
------------------------
Go to Data Sources > QGS > Create
Be sure to select "Only Create PostGIS Database"
Give your database a name and click Create
.. image:: images/create-empty-db-1.png
2. Add pg_service.conf Entry
-------------------------
Go to Data Sources and click "Show Connection Information" for your new database
.. image:: images/create-empty-db-4.png
Add the connection information to your local pg_service.conf file
.. image:: images/db-manager-3.png
Add the new connection to QGIS PostgreSQL
3. Create Tables from Layers
-------------------------------
In QGIS, go to DB Manager, select your database and click "Import Layer/File"
.. image:: images/create-empty-db-5.png
Select the layer to input and table name:
.. image:: images/create-empty-db-6.png
Repeat for any additional layers.