GithubHelp home page GithubHelp logo

olicarbo / osmtogeojson Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tyrasd/osmtogeojson

0.0 1.0 0.0 467 KB

convert osm to geojson

Home Page: http://tyrasd.github.io/osmtogeojson/

License: MIT License

Makefile 0.13% JavaScript 99.87%

osmtogeojson's Introduction

osmtogeojson

Converts OSM data to GeoJSON. Try the demo!

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

Build Status

Usage

  • as a command line tool:

      $ npm install -g osmtogeojson
      $ osmtogeojson file.osm > file.geojson
    

    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):

      $ node --max_old_space_size=8192 `which osmtogeojson` large.osm > large.geojson
    
  • as a nodejs library:

      $ npm install osmtogeojson
    
      var osmtogeojson = require('osmtogeojson');
      osmtogeojson(osm_data);
    
  • as a 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 won't be a structured json object rather than a simple key-value list.
    • 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.

osmtogeojson's People

Contributors

tyrasd avatar olicarbo avatar vsivsi avatar matkoniecz avatar neiljp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.