Example #1
0
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)
Example #2
0
}, function(err: any, data: GeoJSON.FeatureCollection<GeoJSON.Point>) {
  helpers.writeFileSync('address-points.geojson', data)
});
Example #3
0
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'])
Example #4
0
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]))