Download the PHP package farzai/geonames without Composer
On this page you can find all versions of the php package farzai/geonames. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download farzai/geonames
More information about farzai/geonames
Files in farzai/geonames
Package geonames
Short Description A PHP library for downloading and converting Geonames data.
License MIT
Homepage https://github.com/farzai/geonames-php
Informations about the package geonames
Geoname data (PHP)
A PHP library for downloading and converting Geonames data. This library provides easy access to both Postal Codes and Gazetteer data from Geonames.
Features
- Download postal codes data for specific countries or all countries
- Download detailed geographical data (Gazetteer) including administrative divisions
- Convert data to JSON format with proper structure
- Import data directly to MongoDB with proper indexing
- Memory-efficient processing for large datasets
- Progress bars for all operations
- Support for filtering by feature types (for Gazetteer data)
Installation
Usage
Postal Codes
Download postal codes for a specific country:
Download postal codes for all countries:
Options:
--output (-o)
: Output directory (default: ./data)--format (-f)
: Output format (default: json, options: json, mongodb)--mongodb-uri
: MongoDB connection URI (default: mongodb://localhost:27017)--mongodb-db
: MongoDB database name (default: geonames)--mongodb-collection
: MongoDB collection name (default: postal_codes)
The postal codes data includes:
- Country code
- Postal code
- Place name
- Administrative divisions (state/province, county/district, community)
- Latitude and longitude
- Accuracy level
Gazetteer Data
Download geographical data for a specific country:
Download geographical data for all countries:
Options:
--output (-o)
: Output directory (default: ./data)--format (-f)
: Output format (default: json, options: json, mongodb)--feature-class (-c)
: Filter by feature class (default: P)--mongodb-uri
: MongoDB connection URI (default: mongodb://localhost:27017)--mongodb-db
: MongoDB database name (default: geonames)--mongodb-collection
: MongoDB collection name (default: gazetteer)
Available feature classes:
A
: Country, state, regionH
: Stream, lakeL
: Parks, areaP
: City, villageR
: Road, railroadS
: Spot, building, farmT
: Mountain, hill, rockU
: UnderseaV
: Forest, heath
The Gazetteer data includes:
- Geoname ID
- Name (with ASCII and alternate names)
- Geographical coordinates
- Feature class and code
- Administrative divisions with names
- Population
- Elevation
- Digital elevation model (DEM)
- Timezone
- Modification date
Data Structure
Postal Codes Structure
JSON Format
MongoDB Format
In MongoDB, the postal codes data has the same structure as JSON but includes an additional location
field for geospatial queries:
The MongoDB collection is indexed for efficient queries:
- Compound index on
country_code
andpostal_code
(unique) - Index on
country_code
- Index on
postal_code
- Geospatial index on
location
Gazetteer Structure
JSON Format
MongoDB Format
In MongoDB, the gazetteer data has the same structure as JSON but includes an additional location
field for geospatial queries:
The MongoDB collection is indexed for efficient queries:
- Unique index on
geoname_id
- Index on
country_code
- Index on
feature_class
- Index on
feature_code
- Text index on
name
andascii_name
- Geospatial index on
location
MongoDB Usage Examples
Finding locations near a point
Finding postal codes by country
License
This package is open-sourced software licensed under the MIT license.
Credits
- Data provided by GeoNames under a Creative Commons Attribution 4.0 License
- Developed by Parsilver