Platform
Resources
Pricing
Sign in
Get started
Saneef H. Ansari
Consultant Designer & Developer
Workspace
Fork
Published
By
Saneef H. Ansari
Edited
Sep 12, 2022
Fork of
Geo
Importers
2 stars
Insert cell
Insert cell
function
normalizeWinding
(
features
)
{
return
normalizeWindingInPlace
(
{
...
features
}
)
;
}
Insert cell
function
featureFilterFeatures
(
geo
,
allowedFeatures
=
[
"Point"
,
"LineString"
,
"Polygon"
,
"MultiPoint"
,
"MultiLineString"
,
"MultiPolygon"
]
)
{
const
polys
=
featureFilter
(
geo
,
(
f
)
=>
allowedFeatures
.
includes
(
turf
.
getType
(
f
)
)
)
;
return
{
...
geo
,
features
:
polys
}
;
}
Insert cell
function
featureMap
(
geo
,
fn
=
(
d
)
=>
d
)
{
return
turf
.
featureReduce
(
geo
,
(
acc
,
curr
,
index
)
=>
[
...
acc
,
fn
(
curr
,
index
,
geo
)
]
,
[
]
)
;
}
Insert cell
function
featureFilter
(
geo
,
fn
=
(
d
)
=>
d
)
{
return
turf
.
featureReduce
(
geo
,
(
acc
,
curr
,
index
)
=>
{
if
(
Boolean
(
fn
(
curr
,
index
,
geo
)
)
)
{
return
[
...
acc
,
curr
]
;
}
return
acc
;
}
,
[
]
)
;
}
Insert cell
function
featureGroupBy
(
geo
,
fn
=
(
k
)
=>
k
)
{
const
obj
=
turf
.
featureReduce
(
geo
,
(
acc
,
curr
,
index
)
=>
{
const
key
=
fn
(
curr
)
||
null
;
return
{
...
acc
,
[
key
]
:
[
...
(
acc
[
key
]
||
[
]
)
,
curr
]
}
;
}
,
{
}
)
;
return
new
Map
(
Object
.
entries
(
obj
)
)
;
}
Insert cell
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
normalizeWinding
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
featureFilterFeatures
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
featureMap
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
featureFilter
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
featureGroupBy
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
turf
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML