geonames
Library to query places from GeoName dumps (http://download.geonames.org/export/dump/).
Installation
geonames requires Python 2.7 or 3.5+ as well as numpy and pandas packages. It can be installed with,
pip install geonames
Usage
The best way to search for a specific location is to have a “filter” value and then the place’s name. The filter will reduce the number of rows to check considerably. For example, when searching for a location in the US there are (currently) 2237584 entries. However, once a state is specified (e.g. West Virigina) the number drops down to 35932; 1/60th of the original number of rows.
import geonames
import io
import urllib.request as request
import zipfile
name = 'Bath(Berkeley Springs)' # (Berkeley Springs, West Virgina)
# Download US geonames dataset
US = request.urlopen('http://download.geonames.org/export/dump/US.zip')
zipfile = zipfile.ZipFile(io.BytesIO(US.read()))
# Load data
geo = geonames.GeoNames(zipfile.open('US.txt'))
# Search with state specified (`admin1code` filters by state)
location = next(geo.search(name=name, admin1code='WV'))
print(location)
Which (if all goes well) should output:
geonameid 4.7987e+06
name Berkeley Springs
asciiname Berkeley Springs
alternatenames Berkeley Spring,Berkeley Springs,Warm Springs
latitude 39.6264
longitude -78.2292
featureclass H
featurecode SPNG
countrycode US
countrycode2 NaN
admin1code WV
admin2code 065
admin3code NaN
admin4code NaN
population 0
elevation 185
dem 194
timezone America/New_York
modificationdate 2011-12-12
certainty 86
Name: 741633, dtype: object
Metadata
Release files for geonames-lib 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| geonames_lib-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for geonames_lib-0.4.1-py3-none-any.whl |
Release files / geonames_lib-0.4.1-py3-none-any.whl
| Download URL | geonames_lib-0.4.1-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e9012ccedecc8c6bd4762eaaab07629ed0233959b77b5ac3b049e8b51fb3f3c
|
|
BLAKE2b-256 checksum How to use checksums |
5e7e14dc08eb6318768ce251c19b61998c13c2d10f74ac45a186e4788f1ed0e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9
|
Security for geonames-lib 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.