How to import spatial data to PostGIS for MapTiler Server
Do you want to use MapTiler Server vector tiles generating on the flyfeature and you wonder how to fill up your Postgres database? You can do it simply with help of QGIS software.
Prerequisites
- running QGIS
- running PostGIS database
- running MapTiler Server
Tutorial
- run QGIS
- Add any source of vector data (GeoJSON, GeoPackage, shapefile, …). In this tutorial, we will use GeoJSON with North America’s rivers from http://geojson.xyz/. Just drag and drop downloaded GeoJSON to QGIS and you should see an imported layer with rivers
- Connect to QGIS to your PostGIS: In the browser panel, right-click PostGIS and select “new connection”
- Enter connection parameters and save the connection
- In the top menu, open the database manager: Database | DB Manager and select the database connection created in the previous step.
- Press the “import layer” button and select the layer with the data you want to import. Select destination schema and table in your database. You can also specify some import options like target SRID, which is suitable to do projection transformation. For usage with MapTiler Server, we recommend targeting SRID to be Web Mercator 3857, the transformation MapTiler server is using in served tiles from PostGIS. If your import your data in a different projection, they will be transformed on the fly.
- In MapTiler Server, connect to your PostGIS (how to link) and you should be able to insert created layer.
An alternative way to do the import is using the ogr2ogr CLI tool.
Useful links
Prepare your Postgres for MapTiler Server
Vector tiles from PostgreSQL
Advanced SQL editing