Geonames Data Parser (CLI for Shapefile/KML)
This `geonames` library (version 0.1.3) is an older Python package primarily designed as a Command Line Interface (CLI) tool. It parses downloaded GeoNames.org geographical data dump files (typically `.txt` files) and converts them into clean OGR Shapefile or KML formats. The library's last update was in 2015, indicating it is no longer actively maintained.
Warnings
- breaking The library is abandoned and was last updated in 2015. It may not be compatible with newer Python versions or depend on outdated versions of its dependencies (e.g., Fiona, GDAL) which could lead to installation or runtime issues.
- gotcha Name collision with other 'geonames' related packages: The PyPI package `geonames` (v0.1.3) is distinct from `geonames-lib` (a library for querying dumps), `geonamescache` (for in-memory cache), and `python-geonames` (an async database backend). Be careful to install and refer to the correct package.
- gotcha Heavy dependency on GDAL/OGR: This library relies on `fiona` for its core Shapefile/KML conversion, which in turn depends on the GDAL/OGR C++ library. Installing GDAL/OGR can be complex and platform-specific, often requiring system-level packages.
Install
-
pip install geonames -
sudo apt-get update && sudo apt-get install -y libgdal-dev pip install fiona pip install geonames
Imports
- geonames CLI tool
$ geonames PH.txt
Quickstart
# 1. Download a GeoNames dump file (e.g., for Philippines) # wget http://download.geonames.org/export/dump/PH.zip # unzip PH.zip # 2. Convert the downloaded .txt file to a Shapefile using the CLI tool geonames PH.txt # This will generate a Shapefile (e.g., PH.shp, PH.shx, PH.dbf, etc.) # in the current directory.