All Projects → symerio → Pgeocode

symerio / Pgeocode

Licence: bsd-3-clause
Postal code geocoding and distance calculation

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pgeocode

Jpx
JPX - Java GPX library
Stars: ✭ 125 (+35.87%)
Mutual labels:  geolocation, geocoding
radar-sdk-android
Android SDK for Radar, the leading geofencing and location tracking platform
Stars: ✭ 57 (-38.04%)
Mutual labels:  geocoding, geolocation
Spyme
Rails plugin that stores the browser geolocation
Stars: ✭ 108 (+17.39%)
Mutual labels:  geolocation, geocoding
React Native Radar
React Native module for Radar, the leading geofencing and location tracking platform
Stars: ✭ 104 (+13.04%)
Mutual labels:  geolocation, geocoding
kirby-locator
A simple map & geolocation field, built on top of open-source services and Mapbox. Kirby 3 only.
Stars: ✭ 83 (-9.78%)
Mutual labels:  geocoding, geolocation
cordova-plugin-radar
Cordova plugin for Radar, the leading geofencing and location tracking platform
Stars: ✭ 14 (-84.78%)
Mutual labels:  geocoding, geolocation
Geo On Fire
A library to create high performance geolocation queries for Firebase. Checkout the demos: https://run.plnkr.co/plunks/AYaN8ABEDcMntgbJyLVW/ and https://run.plnkr.co/plunks/xJgstAvXYcp0w7MbOOjm/
Stars: ✭ 54 (-41.3%)
Mutual labels:  geolocation, geocoding
Leaflet Geosearch
(Leaflet) GeoSearch / GeoCode provider
Stars: ✭ 666 (+623.91%)
Mutual labels:  geolocation, geocoding
Geocoding-with-Map-Vector
Resources for the ACL 2018 publication "Which Melbourne? Augmenting Geocoding with Maps", published in July 2018.
Stars: ✭ 24 (-73.91%)
Mutual labels:  geocoding, geolocation
geocoder
Geocoder is a Typescript library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations
Stars: ✭ 28 (-69.57%)
Mutual labels:  geocoding, geolocation
Googleapi
C# .NET Core Google Api (Maps, Places, Roads, Search, Translate). Supports all endpoints and requests / responses.
Stars: ✭ 346 (+276.09%)
Mutual labels:  geolocation, geocoding
Pelias Android Sdk
Android sdk for pelias
Stars: ✭ 20 (-78.26%)
Mutual labels:  geolocation, geocoding
React Native Learning Resources
Collection of some good resources for react-native ✨ 🔥 💥
Stars: ✭ 61 (-33.7%)
Mutual labels:  geolocation
Geoip
Elixir library to find geo location information given an IP address, hostname or Plug.Conn
Stars: ✭ 77 (-16.3%)
Mutual labels:  geolocation
Ipdata
🌐 An IP lookup system utilizing open datasets
Stars: ✭ 58 (-36.96%)
Mutual labels:  geolocation
Django Places
A django app for store places with autocomplete
Stars: ✭ 55 (-40.22%)
Mutual labels:  geolocation
Geo Recon
An OSINT CLI tool desgined to fast track IP Reputation and Geo-locaton look up for Security Analysts.
Stars: ✭ 82 (-10.87%)
Mutual labels:  geolocation
P5.geolocation
a geolocation and geofencing library for p5.js
Stars: ✭ 75 (-18.48%)
Mutual labels:  geolocation
Geoip2 Golang
Unofficial MaxMind GeoIP2 Reader for Go
Stars: ✭ 1,074 (+1067.39%)
Mutual labels:  geolocation
Google Time Zone
Get time zones for coordinates
Stars: ✭ 54 (-41.3%)
Mutual labels:  geocoding

pgeocode

|pypi| |rdfd| |GHactions|

.. |pypi| image:: https://img.shields.io/pypi/v/pgeocode.svg :target: https://pypi.org/project/pgeocode/

.. |rdfd| image:: https://readthedocs.org/projects/pgeocode/badge/?version=latest :target: http://pgeocode.readthedocs.io/

.. |GHactions| image:: https://github.com/symerio/pgeocode/workflows/Test/badge.svg :target: https://github.com/symerio/pgeocode/actions?query=branch%3Amaster+

Postal code geocoding and distance calculations

pgeocode is a Python library for high performance off-line querying of GPS coordinates, region name and municipality name from postal codes. Distances between postal codes as well as general distance queries are also supported. The used GeoNames <http://download.geonames.org/export/zip/>_ database includes postal codes for 83 countries.

Currently, only queries within the same country are supported.

For additional documentation see pgeocode.readthedocs.io <https://pgeocode.readthedocs.io>_.

Installation

pgeocode requires Python 3.6+ as well as numpy and pandas packages. It can be installed with,

.. code::

pip install pgeocode

Quickstart

Postal code queries

.. code:: python

>>> import pgeocode

>>> nomi = pgeocode.Nominatim('fr')
>>> nomi.query_postal_code("75013")
postal_code               75013
country_code                 FR
place_name             Paris 13
state_name        Île-de-France
state_code                   11
county_name               Paris
county_code                  75
community_name            Paris
community_code              751
latitude                48.8322
longitude                2.3561
accuracy                      5

>>> nomi.query_postal_code(["75013", "69006"])
      postal_code place_name            state_name  latitude  longitude
0       75013   Paris 13         Île-de-France   48.8322     2.3561
1       69006    Lyon 06  Auvergne-Rhône-Alpes   45.7679     4.8506

Distance calculations

.. code:: python

>>> dist = pgeocode.GeoDistance('fr')
>>> dist.query_postal_code("75013", "69006")
389.156
>>> dist.query_postal_code(["75013", "75014", "75015"], ["69006", "69005", "69004"])
array([ 389.15648697,  390.12577967,  390.49857655])

Geocoding format

The result of a geo-localistion query is a pandas.DataFrame with the following columns,

  • country_code: iso country code, 2 characters
  • postal_code : postal code
  • place_name : place name (e.g. town, city etc)
  • state_name : 1. order subdivision (state)
  • state_code : 1. order subdivision (state)
  • county_name : 2. order subdivision (county/province)
  • county_code : 2. order subdivision (county/province)
  • community_name : 3. order subdivision (community)
  • community_code : 3. order subdivision (community)
  • latitude : estimated latitude (wgs84)
  • longitude : estimated longitude (wgs84)
  • accuracy : accuracy of lat/lng from 1=estimated to 6=centroid

Configuration and defaults

Storage directory

Defaults to ~/pgeocode_data, it is the directory where data is downloaded for later consumption. It can be changed using the environment variable PGEOCODE_DATA_DIR, i.e. export PGEOCODE_DATA_DIR=/tmp/pgeocode_data.

Data sources

Data sources are provided as a list in the pgeocode.DOWNLOAD_URL variable. The default value is,

.. code:: python

DOWNLOAD_URL = [
    "https://download.geonames.org/export/zip/{country}.zip",
    "https://symerio.github.io/postal-codes-data/data/geonames/{country}.txt",
]

Data sources are tried from first to last until one works. Here the second link is a mirror of the first.

It is also possible to extend this variable with third party data sources, as long as they follow the same format. See for instance postal-codes-data <https://github.com/symerio/postal-codes-data/tree/master/data/geonames>_ repository for examples of data files.

License

The pgeocode package is distributed under the 3-clause BSD license.

Supported countries

The list of countries available in the GeoNames database, with the corresponding country codes, are given below,

Andorra (AD), Argentina (AR), American Samoa (AS), Austria (AT), Australia (AU), Åland Islands (AX), Bangladesh (BD), Belgium (BE), Bulgaria (BG), Bermuda (BM), Brazil (BR), Belarus (BY), Canada (CA), Switzerland (CH), Colombia (CO), Costa Rica (CR), Czechia (CZ), Germany (DE), Denmark (DK), Dominican Republic (DO), Algeria (DZ), Spain (ES), Finland (FI), Faroe Islands (FO), France (FR), United Kingdom of Great Britain and Northern Ireland (GB), French Guiana (GF), Guernsey (GG), Greenland (GL), Guadeloupe (GP), Guatemala (GT), Guam (GU), Croatia (HR), Hungary (HU), Ireland (IE), Isle of Man (IM), India (IN), Iceland (IS), Italy (IT), Jersey (JE), Japan (JP), Liechtenstein (LI), Sri Lanka (LK), Lithuania (LT), Luxembourg (LU), Latvia (LV), Monaco (MC), Republic of Moldova (MD), Marshall Islands (MH), The former Yugoslav Republic of Macedonia (MK), Northern Mariana Islands (MP), Martinique (MQ), Malta (MT), Mexico (MX), Malaysia (MY), New Caledonia (NC), Netherlands (NL), Norway (NO), New Zealand (NZ), Philippines (PH), Pakistan (PK), Poland (PL), Saint Pierre and Miquelon (PM), Puerto Rico (PR), Portugal (PT), Réunion (RE), Romania (RO), Russian Federation (RU), Sweden (SE), Slovenia (SI), Svalbard and Jan Mayen Islands (SJ), Slovakia (SK), San Marino (SM), Thailand (TH), Turkey (TR), Ukraine (UA), United States of America (US), Uruguay (UY), Holy See (VA), United States Virgin Islands (VI), Wallis and Futuna Islands (WF), Mayotte (YT), South Africa (ZA)

See GeoNames database <http://download.geonames.org/export/zip/>_ for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].