Hi everyone,
I would like to know how to import a Geopackage file containing raster into a Postgis database. I tried with gdal library “ogr2ogr”.
This is the command line I used:
ogr2ogr -f PostgreSQL PG:"dbname='databasename' host='addr' port='5432' user='x' password='y'" path_name\geopackage_name.gpkg
I use a server Ubuntu 18.04 LAMP with postgres/postgis and I would like to import geopackage from my PC (Ubuntu 19.10 + Qgis + Postgresql 10 + gdal library installed).
Greeting, Giuseppe
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hello,
I think that your firewall might be blocking your connections on port 5432
, so I would suggest running the command locally from your Droplet.
What you should usually do is:
Download data for the whole world or by country. You can download it from here:
https://gadm.org/download_world.html
To download the package you could run:
wget https://biogeo.ucdavis.edu/data/gadm3.6/gadm36_levels_gpkg.zip
unzip gadm36_levels_gpkg.zip
Note: the URL might change so it is best to go to the gadam.org website and get the latest version from there.
Create a PostgreSQL database if you don’t already have one.
Install the PostGIS extension:
CREATE EXTENSION postgis;
ogr2ogr
with the command that you’ve provided:ogr2ogr -f PostgreSQL PG:"dbname='databasename' host='addr' port='5432' user='x' password='y'" path_name\geopackage_name.gpkg
Note: You might have to install the ogr2org
command if you don’t have it installed already:
npm install ogr2ogr
Hope that this helps!
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.