Platform
Resources
Pricing
Sign in
Contact us
categori.se
Workspace
Fork
Public
utils-geo
By
Saneef H. Ansari
Edited
Jan 8, 2023
2 forks
Importers
2 stars
utils-geo
Sentinel-2 L2A | Bengalaru
Circle legend
Geo
Experiments with maps and markings
Map Styling
Style Guide for Data Visualizations
Colors for Maps
Insert cell
Insert cell
function
normalizeWinding
(
features
)
{
return
rewind
(
{
...
features
}
,
true
)
;
}
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
featureRemoveNonPolygonFeatures
(
geo
)
{
const
polys
=
featureFilter
(
geo
,
(
f
)
=>
[
"Polygon"
,
"MultiPolygon"
]
.
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
function
createFeatureCollection
(
geos
)
{
const
features
=
geos
.
flatMap
(
(
f
)
=>
(
Array
.
isArray
(
f
.
features
)
?
f
.
features
:
[
f
]
)
// Assume it is a single feature
)
;
return
geotoolbox
.
featurecollection
(
features
)
}
Insert cell
function
previewGeojson
(
arr
)
{
if
(
Array
.
isArray
(
arr
)
)
{
return
bertin
.
quickdraw
(
arr
.
map
(
normalizeWinding
)
)
}
return
bertin
.
quickdraw
(
normalizeWinding
(
arr
)
)
}
Insert cell
point
=
turf
.
point
Insert cell
Insert cell
Insert cell
geotoolbox
=
require
(
"geotoolbox@1.9.2/dist/index.min.js"
)
Insert cell
bertin
=
import
(
'https://cdn.skypack.dev/bertin@1.5.9?min'
)
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
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
featureRemoveNonPolygonFeatures
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
createFeatureCollection
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
previewGeojson
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
point
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
geotoolbox
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
bertin
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