Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
geojson-groupby
Advanced tools
Group geojson features or array of json based on associated properties.
Group GeoJSON features or FeatureCollection based on associated properties and merge geometries to multigeometries.
npm install geojson-groupby
var geoGroupBy = require('geojson-groupby')
var group = geoGroupBy(array, properties [, collect])
array Array of JSON objects
properties Array JSON properties' path like address.city
or lookup object
lookup
{
intervals: array of numbers
,property: string
[,labels: array of string]
}
intervals Array of intervals. Like [ 10, 20, 30, 40, 50] group the data in four ranges, whereas lower bound is inclusive and upper bound is exclusive.
peroperty Property path like price
labels Array of interval labels like [ 'low', 'medium', 'high']
collect Array of properties that need to be collected in array
var features = [
{
"id": 1, "geometry": {"type": "Point", "coordinates": [10, 10]},
"properties": {"color": "blue","price": 150,"address": {"city": "New York"}}
}, {
"id": 2, "geometry": {"type": "Point", "coordinates": [20, 20]},
"properties": {"color": "green","price": 200,"address": {"city": "London"}}
}, {
"id": 3, "geometry": {"type": "Point", "coordinates": [30, 30]},
"properties": {"color": "red","price": 210,"address": {"city": "London"}}
}, {
"id": 4, "geometry": {"type": "Point", "coordinates": [40, 40]},
"properties": {"color": "red","price": 280,"address": {"city": "New York"}}
}, {
"id": 5, "geometry": {"type": "Point", "coordinates": [50, 50]},
"properties": {"color": "green","price": 300,"address": {"city": "New York"}}
}, {
"id": 6, "geometry": {"type": "Point", "coordinates": [60, 60]},
"properties": {"color": "red","price": 360,"address": {"city": "Mumbai"}}
}
]
```
##### group features and merge geometries to multigeometries
```javascript
geoGroupBy(features, ['properties.color'])
// output as
{blue: {geometry: {type: 'MultiPoint', coordinates: [[10, 10]]}},
green: {geometry: {type: 'MultiPoint', coordinates: [[20, 20], [50, 50]]}},
red:
{geometry:
{type: 'MultiPoint',
coordinates: [[30, 30], [40, 40], [60, 60]]}}}
```
##### group features, merge geometries to multigeometries and collect ids
```javascript
geoGroupBy(features, ['properties.color'],['id'])
// output as
{blue:
{id: [1],
geometry: {type: 'MultiPoint', coordinates: [[10, 10]]}},
green:
{id: [2, 5],
geometry: {type: 'MultiPoint', coordinates: [[20, 20], [50, 50]]}},
red:
{id: [3, 4, 6],
geometry:
{type: 'MultiPoint',
coordinates: [[30, 30], [40, 40], [60, 60]]}}}
```
This package `geojson-groupby` is based on [json-groupby](https://github.com/gagan-bansal/json-groupby), so please also check different [examples](https://github.com/gagan-bansal/json-groupby#examples) on usage of json-groupby
## developing
Once you run
```npm isntall```
then for running test
```npm run test```
to create build
```npm run build```
## license
This project is licensed under the terms of the MIT license.
FAQs
Group geojson features or array of json based on associated properties.
The npm package geojson-groupby receives a total of 3 weekly downloads. As such, geojson-groupby popularity was classified as not popular.
We found that geojson-groupby demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.