All Projects → alexprengere → neobase

alexprengere / neobase

Licence: Apache-2.0 license
Minimalist GeoBases: single file, no dependency, compatible with Python 2.6+, Python 3.x, Pypy

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to neobase

Geofacet
R package for geographical faceting with ggplot2
Stars: ✭ 275 (+1618.75%)
Mutual labels:  geography
Mybox
Easy tools of document, image, file, network, location, color, and media.
Stars: ✭ 45 (+181.25%)
Mutual labels:  geography
Geobases
Data services and visualization
Stars: ✭ 190 (+1087.5%)
Mutual labels:  geography
Awesome Falsehood
😱 Falsehoods Programmers Believe in
Stars: ✭ 16,614 (+103737.5%)
Mutual labels:  geography
Geography for hackers
Geography for Hackers - Teaching all how to hack geography, use GIS, and think spatially
Stars: ✭ 25 (+56.25%)
Mutual labels:  geography
Iran Geography
Iran Locality persian name with Finglish name and also coordinates
Stars: ✭ 70 (+337.5%)
Mutual labels:  geography
shadow-accrual-maps
Accumulated shadow data computed for New York City
Stars: ✭ 15 (-6.25%)
Mutual labels:  geography
geoguessr-tips
Tips and resources for GeoGuessr
Stars: ✭ 54 (+237.5%)
Mutual labels:  geography
Proj Codes
Deprecated
Stars: ✭ 9 (-43.75%)
Mutual labels:  geography
Geostats
A tiny and standalone javascript library for classification and basic statistics :
Stars: ✭ 183 (+1043.75%)
Mutual labels:  geography
Anki Ultimate Geography
Geography flashcard deck for Anki
Stars: ✭ 330 (+1962.5%)
Mutual labels:  geography
Geographer
PHP library that knows how countries and cities are called in any language
Stars: ✭ 714 (+4362.5%)
Mutual labels:  geography
Historical Basemaps
Collection of georeferenced boundaries of world countries and cultural regions for use in mapping historical data on the world scale
Stars: ✭ 134 (+737.5%)
Mutual labels:  geography
Osmnx
OSMnx: Python for street networks. Retrieve, model, analyze, and visualize street networks and other spatial data from OpenStreetMap.
Stars: ✭ 3,357 (+20881.25%)
Mutual labels:  geography
Geokit
Geo-Toolkit for PHP.
Stars: ✭ 223 (+1293.75%)
Mutual labels:  geography
geowombat
GeoWombat: Utilities for geospatial data
Stars: ✭ 34 (+112.5%)
Mutual labels:  geography
Geoserver
geoserver is a Go library for manipulating a GeoServer instance via the GeoServer REST API.
Stars: ✭ 48 (+200%)
Mutual labels:  geography
wikirepo
Python based Wikidata framework for easy dataframe extraction
Stars: ✭ 33 (+106.25%)
Mutual labels:  geography
Contextily
Context geo-tiles in Python
Stars: ✭ 254 (+1487.5%)
Mutual labels:  geography
Doctrine Postgis
Spatial and Geographic Data with PostGIS and Doctrine.
Stars: ✭ 161 (+906.25%)
Mutual labels:  geography

NeoBase actions cratev crated

Minimalist GeoBases implementation:

  • no dependencies
  • compatible with Python 3.6+, CPython and PyPy
  • one data source: opentraveldata
  • one Python module for easier distribution on clusters (like Hadoop)
  • faster load time (5x)
  • tested with pytest and tox
>>> from neobase import NeoBase
>>> b = NeoBase()
>>> b.get('ORY', 'city_code_list')
['PAR']
>>> b.get('ORY', 'city_name_list')
['Paris']
>>> b.get('ORY', 'country_code')
'FR'
>>> b.distance('ORY', 'CDG')
34.87...
>>> b.get_location('ORY')
LatLng(lat=48.72..., lng=2.35...)

Installation

Use the Python package:

pip install neobase

Docs

Check out readthedocs for the API.

You can customize the source data when initializing:

with open("file.csv") as f:
    N = NeoBase(f)

Otherwise the loaded file will be the embedded one, unless the OPTD_POR_FILE environment variable is set. In that case, it will load from the path defined in that variable.

You can manually retrieve the latest data source yourself too, but you expose yourself to some breaking changes if they occur in the data.

from io import StringIO
from urllib.request import urlopen

from neobase import NeoBase, OPTD_POR_URL

data = urlopen(OPTD_POR_URL).read().decode('utf8')
N = NeoBase(StringIO(data))
N.get("PAR")

The reference date of validity can be changed as well:

N = NeoBase(date="2000-01-01")
N.get("AIY")  # was decommissioned in 2015

By default, the reference date will be set to today, unless the OPTD_POR_DATE environment variable is set. In that case, it will use that value.

You can customize the behavior regarding duplicates: points sharing the same IATA code, like NCE as airport and NCE as city. By default everything is kept, but you can set it so that only the first point with an IATA code is kept:

N = NeoBase(duplicates=False)
len(N)  # about 10,000 "only"

Note that you can use the OPTD_POR_DUPLICATES environment variable to control this as well: set it to 0 to drop duplicates.

Finally, you can customize fields loaded by subclassing.

class SubNeoBase(NeoBase):
    KEY = 0  # iata_code

    # Those loaded fields are the default ones
    FIELDS = (
        ("name", 6, None),
        ("lat", 8, None),
        ("lng", 9, None),
        ("page_rank", 12, lambda s: float(s) if s else None),
        ("country_code", 16, None),
        ("country_name", 18, None),
        ('continent_name', 19, None),
        ("timezone", 31, None),
        ("city_code_list", 36, lambda s: s.split(",")),
        ('city_name_list', 37, lambda s: s.split('=')),
        ('location_type', 41, None),
        ("currency", 46, None),
    )

N = SubNeoBase()

Command-line interface

You can query the data using:

python -m neobase PAR NCE

Tests

tox
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].