DenisCarriere / geocoder-geojson

Geocoding results in GeoJSON format
https://www.npmjs.com/package/geocoder-geojson
MIT License
21 stars 10 forks source link

Geocoder GeoJSON

Build Status Circle CI Coverage Status npm version MIT licensed

Geocoding results according to the GeoJSON specification.

Install

$ npm install --save geocoder-geojson

Install globaly to access geocode via your command prompt.

$ npm install -g geocoder-geojson
$ geocode --version
$ geocode --help

Quickstart

import geocoder from 'geocoder-geojson'

geocoder.google('Ottawa, ON')
  .then(geojson => console.log(geojson))

Supports

Features

Name Coverage Restrictions
google Global Free & API Key - RateLimit 2500/day
googleReverse Global Free & API Key - RateLimit 2500/day
mapbox Global API Key
mapboxReverse Global API Key
bing Global API Key
wikidata Global Free

CLI

$ geocode --provider bing "Ottawa ON"
$ geocode -p wikidata --nearest [-75.7,45.4] Ottawa
$ geocode -p google --limit 3 "Ottawa ON"

Using jq to filter JSON data

$ geocode -p wikidata --nearest [-75.7,45.4] Ottawa | jq .features[0].id
"Q1930"

Roadmap

API

mapbox

Mapbox Provider

https://www.mapbox.com/api-documentation/#geocoding

Parameters

Examples

const geojson = await geocoder.mapbox('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

mapboxReverse

Mapbox Provider (Reverse)

https://www.mapbox.com/api-documentation/#geocoding

Parameters

Examples

const geojson = await geocoder.mapbox('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

google

Google Provider

https://developers.google.com/maps/documentation/geocoding

Parameters

Examples

const geojson = await geocoder.google('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

googleReverse

Google Provider (Reverse)

https://developers.google.com/maps/documentation/geocoding

Parameters

Examples

const geojson = await geocoder.googleReverse([-75.1, 45.1])

Returns Promise<Points> GeoJSON Point FeatureCollection

bing

Bing Provider

https://msdn.microsoft.com/en-us/library/ff701714.aspx

Parameters

Examples

const geojson = await geocoder.bing('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

wikidata

Wikidata Provider

https://query.wikidata.org/

Parameters

Examples

const geojson = await geocoder.wikidata('Ottawa')

Returns Promise<Points> GeoJSON Point FeatureCollection

request

Generic GET function to normalize all of the requests

Parameters

Returns Promise<Points> Results in GeoJSON FeatureCollection Points