import * as turf from '@turf/helpers' import * as helpers from 'geojson-helpers' const data: GeoJSON.FeatureCollection<any> = require('./halifax-buildings.json') const collection = turf.featureCollection( data.features.map(feature => { feature.properties = {building: 'yes'} return feature }) ) helpers.writeFileSync('halifax-buildings.geojson', collection)
}, function(err: any, data: GeoJSON.FeatureCollection<GeoJSON.Point>) { helpers.writeFileSync('address-points.geojson', data) });
import * as helpers from 'geojson-helpers' const geojson = helpers.readFileSync('./GEBADR-address-points.geojson') geojson.features = geojson.features.map(feature => { feature.properties.source = 'Canton Berne' return feature }) helpers.writeFileSync('./GEBADR-address-points-compact.geojson', geojson, ['addr:housenumber', 'addr:postcode', 'addr:city', 'addr:street', 'source'])
import * as concaveman from 'concaveman' import * as helpers from 'geojson-helpers' import * as turf from '@turf/turf' const data = './halifax-buildings.json' const geojson: GeoJSON.FeatureCollection<any> = require(data) const points: Array<Array<number>> = [] geojson.features.map(feature => { turf.explode(feature).features.map(point => { points.push(point.geometry.coordinates) }) }) const extent = turf.polygon([concaveman(points)]) const buffer = turf.buffer(extent, 500, 'meters') const simple: any = turf.simplify(buffer, 0.001, false) helpers.writeFileSync('./extent.geojson', turf.featureCollection([extent])) helpers.writeFileSync('./buffer.geojson', turf.featureCollection([buffer])) helpers.writeFileSync('./simple.geojson', turf.featureCollection([simple]))