Among the different options to load data in Postgresql, we will see here the one that, in my opinion, is the easiest and fastest. We will simply use QGis and its Database Manager.
This video is in French.
Find this video on our Youtube channel:https://www.youtube.com/@sigterritoires
We will load a large layer for the example. The Buildings layer of the Topo DB is a good example.
The one for the department 65 contains 385 880 polygonal entities. Moreover they are xyz entities.
We will load this layer in a Postgis database under PostgreSQL 15.
Open the DB Manager in QGis
Click in front of the PostGIS icon to verify that you are connected to the PostgreSQL database. If you are not, you need to go to the explorer panel->PostgreSQL and click on New connection, to define the database and the connection permissions.
Go to the database schema where you want to load the new table, then in the Table menu select Import Layer/File
You can define what data to load and where it will be loaded. You can also change the default settings.
In this example, the only interesting thing to change is the checkbox “Create a spatial index“. Given the number of entities in the table, it will be useful for spatial queries.
You click on OK, and off you go!
Loading a large number of entities can take some time. Add that the spatial index also takes its time, so be patient…
Wait for the message: Import successful. You will then see the new layer in the left panel. Click on it and you will see the complete result of the operation.
You can do the same in pgAdmin:
You will notice that these are indeed polygonZ that have been created.
The GIST index is also there. If you want other types of indexes, you will have to set them up directly with pgAdmin.