New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@giscience/ohsome2x

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@giscience/ohsome2x

convenience library to query ohsome-api using nodejs

  • 2.0.0
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-58.33%
Maintainers
2
Weekly downloads
 
Created
Source

ohsome2X

Query OSM History Data (count, length, area) about specific OSM Features or OSM User activity (user-count) for your areas of interest.

Input: Accepts GeoJSON or PostgreSQL/PostGIS as input source.

Output: Creates a GeoJSON File or new result table in your PostgreSQL/PostGIS database.

The package includes a library with a single class to run.

Additionally it includes ohsome2x-cli, a command-line tool with a configuration wizard to create and run a query-configuration-JSON.

This library/tool makes use of the ohsome API (https://api.ohsome.org) as data backend and many other great open-source libraries.

This software is developed by HeiGIT:

HeiGIT Logo

Usage

There are two ways how you can use ohsome2x.

1. Without installation using the npm package runner npx

Info: The npx command comes with the installation of npm.

To run the command-line wizard:

Syntax info:
$ npx @giscience/ohsome2x
-------------------------
USAGE:
with 'npx'
npx @giscience/ohsome2x createconfig [(-o|--out) path]
npx @giscience/ohsome2x run (-c|--conf) fullConfig.json
as local command
node ohsome2x-cli.js createconfig [(-o|--out) path]
node ohsome2x-cli.js run (-c|--conf) fullConfig.json
-------------------------

2. With installation as library to use it in your Node.js script

  1. For use as library in Node.js install the package:

    $ npm install @giscience/ohsome2x
    
  2. You find the built library in the /dist folder after executing:

    $ npm run build
    
  3. Write your own JavaScript or TypeScript file:

    See Examples and API section to learn how to do it. Enjoy!
    

Example

Query the number of buildings in a bbox around Heidelberg in a yearly resolution from 2008 to 2020

Step 1. You need some input (one or many polygons): heidelberg.geojson
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"id": "Heidelberg"},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [ [8.625984191894531, 49.38527827629032],
            [8.735504150390625, 49.38527827629032],
            [8.735504150390625, 49.433975502014675],
            [8.625984191894531, 49.433975502014675],
            [8.625984191894531, 49.38527827629032]
          ]]}}]}
Step 2. Specify your query as JSON-file (you can use the commandline wizard to create this): myquery.json

Info: for the filter Syntax see: https://docs.ohsome.org/ohsome-api/stable/filter.html

{
  "ohsomeQuery": {
    "queryType": "elements/count/groupBy/boundary",
    "filter": "building=* and building!=no and geometry:polygon",
    "time": "2008/2020/P1Y"
  },
  "source": {
    "geometryId": "id",
    "name": "heidelberg.geojson",
    "store": { "path": "heidelberg.geojson", "type": "geojson" }
  },
  "target": {
    "horizontalTimestampColumns": false,
    "createGeometry": true,
    "transformToWebmercator": false,
    "storeZeroValues": true,
    "computeValuePerArea": true,
    "name": "heidelberg_buildings_count.geojson",
    "store": { "path": "heidelberg_buildings_count.geojson", "type": "geojson" }
  }
}
Step 3. Run the Query
$ npx @giscience/ohsome2x run --conf myquery.json

API

Node:

const Ohsome2X = require('@giscience/ohsome2x');

// you can create this config using the command-line wizard, run: npx ohsome2x-cli
const config = {
                ohsomeQuery: {...},
                source: {...},
                target: {...}
}                               

const ohsome2x = new Ohsome2X(config);

// This will return a Promise
ohsome2x.run().catch(console.log);

TypeScript:

import Ohsome2X = require('@giscience/ohsome2x'); 
import {Ohsome2XConfig} from '@giscience/ohsome2x/dist/config_types_interfaces';

// you can create this config using the command-line wizard, run: npx ohsome2x-cli
const config: Ohsome2XConfig = {
                ohsomeQuery: {...},
                source: {...},
                target: {...}
}                               

const ohsome2x = new Ohsome2X(config);

// This will return a Promise
ohsome2x.run().catch(console.log);
  • OhsomeHeX - The OSM History Explorer: Uses this library as backend
  • ohsome API - WebAPI to query OSM History Data
  • OSHDB - The OpenStreetMap History Database: Query OSM History Data with Java
  • ohsome.org - Get information about all these technologies and more
  • heigit.org - The Heidelberg Institute for Geoinformation Technology: The non-profit company behind all those useful tools.

Keywords

FAQs

Package last updated on 10 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc