/** GeoJSON is a single JSON file containing one or more features */
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-82, 39] /*WGS 84*/
},
"properties": {
"field": "value"
}
}
]
}
ArcGIS Feature to JSON
Source Software
github.com/Turfjs
https://cdnjs.cloudflare.com/ajax/libs/Turf.js/5.1.5/turf.min.js
npm install @turf/turf --OR-- npm install @turf/bbox
turf.booleanWithin(point, polygon)
var result = "";
counties.features.map(function(county) {
var point = turf.point([x,y]);
if (turf.booleanWithin(point, county) {
result = county.properties.NAME;
}
});
Array.filter()
turf.nearestPoint(point, points)
var data = amenities.features.filter(function(a) {
return a.properties.TYPE === 'Playground'
})
var playgrounds = turf.featureCollection(data);
var result = turf.nearestPoint(point, playgrounds)
turf.hexGrid(bbox, size, opts)
Intersect
turf.intersect(a,b)
Collect
turf.collect(p, pts, field, name)
var bbox = [-82.5, 39.7, -81.5, 40.18];
var size = 1;
var options = {
units: 'miles'
};
var hexgrid = turf.hexGrid(bbox, size, options)
// loop through each grid
// add the intersecting areas to the clippedGrid
// calculate the area in sq miles
var clippedGrid = { โtypeโ:โFeatureCollectionโ, โfeaturesโ:[] }
hexgrid.features.map(function(grid) {
var toFt = 0.00000386102159
var intersect = turf.intersect(grid, muskingum);
if (intersect) {
intersect.properties.area = (turf.area(intersect)) * toFt;
clippedGrid.features.push(intersect);
}
});
turf.collect(clippedGrid, crashes, "count", "total")
var points = turf.explode(polygon)
turf.nearestPoint(point, points)
No Coding
Dropchop
Support TurfJS
Thanks!
Malcolm Meyer
@getbounds