Skip to content

Seg-mel/django-geonames-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-geonames-parser

Cities and countries parser based on data from GeoNames. Also supports parsing alternate names and local names for cities and countries. Tested on Python 2.7/3.6 and Django 1.8/1.11.

Installation

pip install git+https://github.com/Seg-mel/django-geonames-parser.git

Settings

Add app to INSTALLED_APPS

INSTALLED_APPS = [
    ...
    'geo_names',
    ...
]

Set path to countries dump file COUNTRIES_FILE_PATH. Download this file.

COUNTRIES_FILE_PATH = '<your_directory_with_dumps>/countryInfo.txt'

Set path to alternate names dump file ALTERNATE_NAMES_FILE_PATH. Download this file.

ALTERNATE_NAMES_FILE_PATH = '<your_directory_with_dumps>/alternateNames.txt'

Set path to alternate names dump file ALL_COUNTRIES_FILE_PATH. You can download one file from list:

  • allCountries.zip - all countries combined in one file, see 'geoname' table for columns
  • cities1000.zip - all cities with a population > 1000 or seats of adm div (ca 150.000), see 'geoname' table for columns
  • cities5000.zip - all cities with a population > 5000 or PPLA (ca 50.000), see 'geoname' table for columns
  • cities15000.zip - all cities with a population > 15000 or capitals (ca 25.000), see 'geoname' table for columns
ALL_COUNTRIES_FILE_PATH = '<your_directory_with_dumps>/cities15000.txt'

Set value for feature class CITY_FEATURE_CLASS. Default value is 'P'.

  • A: country, state, region,...
  • H: stream, lake, ...
  • L: parks,area, ...
  • P: city, village,...
  • R: road, railroad
  • S: spot, building, farm
  • T: mountain,hill,rock,...
  • U: undersea
  • V: forest,heath,...
CITY_FEATURE_CLASS = 'P'

Set value for feature codes CITY_FEATURE_CODES. Default value is 'None', with this value cities with all codes are parsed. A list of all codes is available here.

CITY_FEATURE_CODES = ['PPL', 'PPLA', 'PPLF']

Data dumps and documentation are available here.

Management commands

parse_all - parse cities, countries, alternate names, names for locale 'ru'
parse_cities - parse cities with alternate names
parse_city_locale_names - parse names for 'ru' locale for cities that were parsed earlier and are already in database
parse_countries - parse countries with alternate names
parse_country_locale_names - parse names for 'ru' locale for countries that were parsed earlier and are already in database

GeoNames license

This work is licensed under a Creative Commons Attribution 3.0 License

About

Django GeoNames parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •