• Stars
    star
    640
  • Rank 70,324 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

convert osm to geojson

osmtogeojson

Converts OSM data to GeoJSON. Try the demo!

This code is used in and maintained by the overpass turbo project.

Build Status

Usage

command line tool

Installation:

  $ npm install -g osmtogeojson

Usage:

$ osmtogeojson file.osm > file.geojson

Supported command line options are shown with:

$ osmtogeojson --help

When working with extra large data files (≳ 100 MB) it is recommended to run the programm with a little extra memory to avoid process out of memory errors. The easiest way to do this is by running the command as node <path-to-osmtogeojson> and setting the --max_old_space_size=… parameter to the available memory size in MB (osmtogeojson typically needs about 4-5 times the input data size). On a Unix system, you can use the following command:

$ node --max_old_space_size=8192 `which osmtogeojson` large.osm > large.geojson

nodejs library

Installation:

$ npm install osmtogeojson

Usage:

var osmtogeojson = require('osmtogeojson');
osmtogeojson(osm_data);

browser library

<script src='osmtogeojson.js'></script>

osmtogeojson(osm_data);

API

osmtogeojson( data, options )

Converts OSM data into GeoJSON.

  • data: the OSM data. Either as a XML DOM or in OSM JSON.
  • options: optional. The following options can be used:
    • flatProperties: If true, the resulting GeoJSON feature's properties will be a simple key-value list instead of a structured json object (with separate tags and metadata). default: false
    • uninterestingTags: Either a blacklist of tag keys or a callback function. Will be used to decide if a feature is interesting enough for its own GeoJSON feature.
    • polygonFeatures: Either a json object or callback function that is used to determine if a closed way should be treated as a Polygon or LineString. read more

The result is a javascript object of GeoJSON data:

GeoJSON

The GeoJSON produced by this library will include exactly one GeoJSON-feature for each of the following OSM objects (that is everything that is also visible in overpass turbo's map view):

  • all unconnected or interesting tagged nodes (POIs)
  • all ways (except uninteresting multipolygon outlines)
  • all multipolygons (simple multipolygons with exactly one closed outer way are present via their outer way)

All data is given as a FeatureCollection. Each Feature in the collection has an id property that is formed from the type and id of the original OSM object (e.g. node/123) and has the member properties containing the following data:

  • type: the OSM data type
  • id: the OSM id
  • tags: a collection of all tags
  • meta: metainformaton about the feature (e.g. version, timestamp, user, etc.)
  • relations: an array of relations the feature is member of. Each relation is encoded as an object literal containing the following properties: role (membership role), rel (the relation's id) and reltags (contains all tags of the relation)
  • tainted: this flag is set when the feature's geometry is incomplete (e.g. missing nodes of a way or missing ways of a multipolygon)

If the option flatProperties is set to true, the properties object will not contain any nested object literals, but directly provide a concise id, meta data and the tags of the respective OSM object.

More Repositories

1

overpass-turbo

A web based data mining tool for OpenStreetMap using the Overpass API.
TypeScript
725
star
2

jxon

lossless JavaScript XML Object Notation
JavaScript
88
star
3

togpx

convert geojson to gpx
JavaScript
66
star
4

osm-node-density

🌇 a visualization of OpenStreetMaps node density
JavaScript
50
star
5

taghistory

📈 History of OSM tag usage
HTML
35
star
6

overpass-wizard

💫 Human friendly way to generate Overpass API queries
JavaScript
31
star
7

geojsontoosm

Convert GeoJSON to OSM XML
JavaScript
18
star
8

osm-tile-access-log-viewer

👀 Visualize tile logs from planet.osm.org/tile_logs
JavaScript
18
star
9

osm-qa-feeds

A tool to create personalized OpenStreetMap quality assurance feeds
JavaScript
14
star
10

rfc7946-to-d3

Converts rfc7946 geojson polygons to d3 compatible ones
JavaScript
11
star
11

tortuosmity

🐢 tortuOSMity
JavaScript
11
star
12

tiny-osmpbf

smallest osm.pbf parser
JavaScript
10
star
13

osm-polygon-features

OSM tags indicate if a closed way should be treated as a polygon or linestring
JavaScript
8
star
14

geojson-stats

calculate stats of GeoJSON properties
JavaScript
8
star
15

Baumkataster-Graz

🌲 🌳
JavaScript
7
star
16

geojson-length

Calculate the length of a GeoJSON LineString or MultiLineString
JavaScript
5
star
17

html2canvas-proxy-node

JavaScript
2
star
18

geojson-numeric

Makes properties of geojson features numeric.
JavaScript
2
star
19

oqt-filter

tile-reduce job that filters osmqatiles and enhances it with external data
JavaScript
1
star
20

openstreetmap-carto-typos

search for typos in openstreetmap cartocss stylesheets
JavaScript
1
star
21

sasa-bus-stops

Shell
1
star