Socket
Socket
Sign inDemoInstall

geojson-geometries

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-geometries

Extract elementary geometries from a geojson inheriting properties.


Version published
Weekly downloads
3K
decreased by-24.64%
Maintainers
1
Weekly downloads
 
Created
Source

geojson-geometries

Latest version on npm Downloads on npm Project license
Lint status Test macOS status Test Ubuntu status Test Windows 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

⛏ Extract elementary geometries from a GeoJSON inheriting properties.
Coded with ❤️ by Simone Primarosa.

Install

$ npm install --save geojson-geometries

Usage

const GeoJsonGeometries = require('geojson-geometries');

const geojson = {type: 'FeatureCollection',
  features: [{
    type: 'Feature',
    geometry: {
      type: 'Point',
      coordinates: [102.0, 0.5]
    },
    properties: {prop0: 'value0'}
  }, {
    type: 'Feature',
    geometry: {
      type: 'LineString',
      coordinates: [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]
    },
    properties: {prop1: 'value1'}
  }, {
    type: 'Feature',
    geometry: {
      type: 'Polygon',
      coordinates: [
        [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]
      ]
    },
    properties: {prop2: 'value2'}
  }]
};

const extracted = new GeoJsonGeometries(geojson);

extracted.points
// => {
//   type: "FeatureCollection",
//   features: [{
//     type: "Feature",
//     geometry: {
//       type: "Point",
//       coordinates: [102, 0.5]
//     },
//     properties: {prop0: 'value0'}
//   }]
// }

extracted.lines
// => {
//   type: "FeatureCollection",
//   features: [{
//     type: "Feature",
//     geometry: {
//       type: "LineString",
//       coordinates: [[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]]
//     },
//     properties: {prop1: 'value1'}
//   }]
// }

extracted.polygons
// => {
//   type: "FeatureCollection",
//   features: [{
//     type: "Feature",
//     geometry: {
//       type: "Polygon",
//       coordinates: [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]]
//     },
//     properties: {prop2: 'value2'}
//   }]
// }

API

new GeoJsonGeometries(geoJson, [options])

Create an instance of the geometries extractor.

ParamTypeDescription
geoJsonObjectThe GeoJSON from which extract the geometries.
[options]ObjectOptional options.
options.ignorePointsbooleanIf true the extractor will ignore geometries of type Point.
options.ignoreLinesbooleanIf true the extractor will ignore geometries of type LineString.
options.ignorePolygonbooleanIf true the extractor will ignore geometries of type Polygon.

geoJsonGeometries.points ⇒ Array.<Object>

Returns the list of geometries of type Point found in the GeoJSON.

Kind: instance property of GeoJsonGeometries
Returns: Array.<Object> - A FeatureCollection of points with inherited properties if any.

geoJsonGeometries.lines ⇒ Array.<Object>

Returns the list of geometries of type LineString found in the GeoJSON.

Kind: instance property of GeoJsonGeometries
Returns: Array.<Object> - A FeatureCollection of lines with inherited properties if any.

geoJsonGeometries.polygons ⇒ Array.<Object>

Returns the list of geometries of type Polygon found in the GeoJSON.

Kind: instance property of GeoJsonGeometries
Returns: Array.<Object> - A FeatureCollection of polygons with inherited properties if any.

Authors

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

License

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

Keywords

FAQs

Package last updated on 02 Jul 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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc