Skip to content

tig12/geonames2postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This code loads geonames.org data in a postgresql database.  
In the target database, each country is stored in a schema.  
Each schema contains the following tables :
- admin1
- admin2
- admin3
- admin4
- cities
- postal

For each entity, a "slug" is computed (a slug is a string composed of lowercase letters, digits and hyphens - the slug of "New York" is "new-york").

Structure of the tables can be seen in directory sql/


Install
---------------------
- Copy config.yml.dist to config.yml  
- Adapt the parameters in config.yml
- Copy geonames files on your local machine (see comments of config.yml for details)


Usage
---------------------
Type :
python geonames2postgres.py
and follow usage instructions


About postal codes
---------------------
On geonames.org, postal codes are not stored with city informations, but in separate files (because one city can have several postal codes).  
This code tries to merge the two lists, and associates a postal code to each city.
When one city has several postal codes, the first one is retained. This generally (always ?) corresponds to the most generic code of the city, but the merge process remains basic. For a better merge of postal codes, see for example https://pypi.python.org/pypi/django-cities


About this program
---------------------

Code released under the General Public Licence, version 3 or later, available at https://www.gnu.org/licenses/gpl-3.0.en.html

Code tested with python 3.8 under ubuntu 20.4

Last commit operational with python 2 is b63fc476fcc20ee00be469328f70e8a0770cdc33

2017-05-02 : Repository created by Thierry Graff.

About

Import geonames.org data in postgresql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages