Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including osm-geojson with all npm packages installed. Try it out:

var osmGeojson = require("osm-geojson")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

osm-geojson v0.8.3

Get GeoJSON of a OpenStreetMap's relation from the API.

osm-geojson

Mac/Linux Build Status Windows Build status Codecov Coverage report Known Vulnerabilities Dependency Status


XO Code Style used AVA Test Runner used Istanbul Test Coverage used NI Scaffolding System used NP Release System used


Latest version on npm Project license

🔰 Get GeoJSON of a OpenStreetMap's relation from the API.

Coded with ❤️ by Simone Primarosa.

Install

$ npm install --save osm-geojson

Usage

const osmGeoJson = require('osm-geojson');

osmGeoJson.get('365331'); // Italy
// => { type: 'GeometryCollection', geometries: [ { type: 'MultiPolygon', coordinates: [Array] } ] }

osmGeoJson.getAll({'ITA': '365331', 'USA': '148838'}); // Italy
// => {
// 'ITA': { type: 'GeometryCollection', geometries: [ { type: 'MultiPolygon', coordinates: [Array] } ] },
// 'USA': { type: 'GeometryCollection', geometries: [ { type: 'MultiPolygon', coordinates: [Array] } ] }
// }

CLI

Install

To use the CLI just install the package globally.

$ npm install --g osm-geojson

Or run it with npx if you are not planning to use it more than once.

$ npx osm-geojson

Help

Usage
  $ osm-geojson <osmId>
  $ osm-geojson -l [<osmId>:<filename>]+
Options
  -l  --list [<osmId>:<filename>]+   To fetch a list of osmIds. Each relation
                                     will be saved in a file called
                                     filename.geojson
  -p --pretty                        To beautify the outputted JSON.
Examples
  $ osm-geojson 365331
  $ osm-geojson -p 365331
  $ osm-geojson -p 365331 > filename.geojson
  $ osm-geojson -l 365331:ita 148838:usa

API

get(osmid) ⇒ Promise.<object>

Returns the GeoJSON of a particular OSM relation id.

Returns: Promise.<object> - A promise that contains the GeoJSON of the given relation.

ParamTypeDescription
osmidstringRelation id from which extract the GeoJSON.

getAll(map) ⇒ Promise.<object>

Returns a map of GeoJSON of multiple OSM relation ids.

Returns: Promise.<object> - A promise that contains the map with the same keys of the map provided but with the GeoJSON of the given relation id as value.

ParamTypeDescription
mapobjectMap from a name to a relation id from which extract the GeoJSON.

Authors

See also the list of [contributors][contributors] who participated in this project.

License

This project is licensed under the MIT License - see the license file for details.

[start]: https://github.com/simonepri/osm-geojson#start-of-content [contributors]: https://github.com/simonepri/osm-geojson/contributors
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free