Platform
Resources
Pricing
Sign in
Get started
PAC
I explore Wikidata and Wikipedia using Observable notebooks.
Workspace
Fork
Unlisted
By
PAC
Edited
Feb 13, 2024
ISC
Fork of
Au bord de l'eau
•
1 fork
Insert cell
Insert cell
viewof
qid
=
Inputs
.
text
(
{
label
:
"Choisir un élément Wikidata "
,
value
:
"Q3392"
,
placeholder
:
"eg fr, en, de"
,
submit
:
true
}
)
Insert cell
query
=
`
SELECT ?item ?itemLabel ?coord
WHERE {
?item wdt:P206 wd:${
qid
};
wdt:P625 ?coord;
rdfs:label ?itemLabel .
FILTER(LANG(?itemLabel) = "fr")
} `
Insert cell
url
=
`https://query.wikidata.org/sparql?query=${
encodeURIComponent
(
query
)
}`
Insert cell
data
=
fetch
(
url
,
{
headers
:
{
accept
:
"application/sparql-results+json"
}
}
)
.
then
(
(
response
)
=>
response
.
json
(
)
)
Insert cell
array
=
data
.
results
.
bindings
.
map
(
(
d
)
=>
(
{
item
:
d
.
item
.
value
,
itemLabel
:
d
.
itemLabel
.
value
,
coord
:
d
.
coord
?.
value
}
)
)
Insert cell
geo
=
require
(
"geotoolbox@2"
)
Insert cell
geoarray
=
geo
.
coords2geo
(
array
,
{
coords
:
"coord"
,
reverse
:
true
}
)
Insert cell
d3
=
require
(
"d3@7"
,
"d3-geo-projection@4"
)
Insert cell
viz
=
require
(
"geoviz@0.4.4"
)
Insert cell
{
// Conteneur SVG
let
svg
=
viz
.
create
(
{
zoomable
:
true
,
projection
:
d3
.
geoMercator
(
)
}
)
;
// Fond de carte
svg
.
tile
(
)
;
// Basemap
// Cercles
svg
.
circle
(
{
data
:
geoarray
,
r
:
6
,
fill
:
"#365486"
,
dodge
:
true
,
tip
:
(
d
)
=>
`${
d
.
properties
.
itemLabel
}`
}
)
;
// Render
return
svg
.
render
(
)
;
}
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
qid
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
query
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
url
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
array
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
geo
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
geoarray
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
viz
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML