zedalaye / geonames_pg_import

Import GeoNames datasets into any PostgreSQL database
MIT License
6 stars 1 forks source link

Import GeoNames datasets into any PostgreSQL database

Use it to download, unpack and import GeoNames datasets in any PostgreSQL database.

Acknowledgments

This script is based on

https://gist.github.com/EspadaV8/1357237/25a81f06fd1d04b54cdda35a53f359c45aefce6a and https://gist.github.com/WhoAteDaCake/37823722bdf27fc03527f5b54c0ca6f0

Many thanks to GeoNames for making these datasets publicly available.

Thanks to Andreas (aka Harpagophyt) and Scott Wilson for their previous work on this script.

Prerequisites

A working PostgreSQL instance with PostGIS extensions installed.

This script has been tested against PostgreSQL 14

You will also need the wget and unzip command line tools.

Usage

Copy .env.example and change variables according to your needs/environment.

DATABASE and DB_USER variables are mandatory, other variables will get default values.

PGPASSWORD (or DBPASSWORD) can be specified in the .env file or in the command line :

PGPASSWORD=mypassword ./import.sh -d -c -g -i

For subsequent imports, you can also clean the download cache to start from scratch by using the -f (--from-scratch) argument.