Skip to content

Commit 6cdf01f

Browse files
authored
Add files via upload
1 parent 992cec9 commit 6cdf01f

File tree

1 file changed

+70
-37
lines changed

1 file changed

+70
-37
lines changed

module3stuff/WikidataMapMakingWorkshop.ipynb

Lines changed: 70 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,24 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {},
5+
"metadata": {
6+
"slideshow": {
7+
"slide_type": "-"
8+
}
9+
},
610
"source": [
711
"# Building a stand-alone off-Wiki layered map using Wikidata & SPARQL\n",
812
"\n",
913
"This Jupyter notebook shows you step by step **how to make a Wikidata-driven layered map that can be used off-Wiki**.\n",
1014
"\n",
1115
"It is part of Module 3 of the map making workshop [From Wikidata to interactive off-Wiki maps in three steps](https://github.com/ookgezellig/WikidataMapMakingWorkshop)\n",
1216
"\n",
13-
"See https://github.com/ookgezellig/WikidataMapMakingWorkshop/blob/master/OutlineAndNotes.md for the full layout of this workshop\n",
17+
"<img src=\"https://raw.githubusercontent.com/ookgezellig/WikidataMapMakingWorkshop/master/images/generic-workshop-opening.jpg\" alt=\"Generic workshop opening slide\" width=\"400\" align=\"left\"/>\n",
18+
"<br clear=\"all\"/>\n",
19+
"\n",
20+
"For more context to this workshop you can check the\n",
21+
"* [full layout](https://github.com/ookgezellig/WikidataMapMakingWorkshop/blob/master/OutlineAndNotes.md), and\n",
22+
"* [full slides (pdf)](https://github.com/ookgezellig/WikidataMapMakingWorkshop/blob/master/slides/Generic/WikidataMapMakingWorkshop_Generic.pdf) \n",
1423
"\n",
1524
"This notebook is publically available at\n",
1625
"* https://paws-public.wmflabs.org/paws-public/User:OlafJanssen/WikidataMapMakingWorkshop.ipynb (and in [raw format](https://paws-public.wmflabs.org/paws-public/User:OlafJanssen/WikidataMapMakingWorkshop.ipynb?format=raw))\n",
@@ -22,15 +31,14 @@
2231
"metadata": {},
2332
"source": [
2433
"For questions about this notebook, contact [Olaf Janssen](https://www.wikidata.org/wiki/User:OlafJanssen) on Wikidata // olaf.janssen@kb.nl // https://twitter.com/ookgezellig\n",
25-
" \n",
26-
"************"
34+
"***********"
2735
]
2836
},
2937
{
3038
"cell_type": "markdown",
3139
"metadata": {},
3240
"source": [
33-
"## Start of the workshop"
41+
"## Start of the notebook"
3442
]
3543
},
3644
{
@@ -64,9 +72,20 @@
6472
},
6573
{
6674
"cell_type": "code",
67-
"execution_count": null,
68-
"metadata": {},
69-
"outputs": [],
75+
"execution_count": 1,
76+
"metadata": {},
77+
"outputs": [
78+
{
79+
"name": "stdout",
80+
"output_type": "stream",
81+
"text": [
82+
"Enabling notebook extension jupyter-leaflet/extension...\n",
83+
" - Validating: \u001b[32mOK\u001b[0m\n",
84+
"Enabling notebook extension jupyter-js-widgets/extension...\n",
85+
" - Validating: \u001b[32mOK\u001b[0m\n"
86+
]
87+
}
88+
],
7089
"source": [
7190
"#Skip this step if you are running this notebook on a local Jupyter Notebooks installation, such as Anaconda. See the cell below for the alternative instructions.\n",
7291
"\n",
@@ -114,7 +133,7 @@
114133
},
115134
{
116135
"cell_type": "code",
117-
"execution_count": null,
136+
"execution_count": 1,
118137
"metadata": {},
119138
"outputs": [],
120139
"source": [
@@ -139,7 +158,7 @@
139158
"cell_type": "markdown",
140159
"metadata": {},
141160
"source": [
142-
"Next we want to import data that is the result of a SPARQL query in Wikidata \n",
161+
"Next we want to import a dataset containing geo coordinates (P625) that is the result of a SPARQL query in Wikidata \n",
143162
"\n",
144163
"For this, we are using the query https://w.wiki/6gJ (public libraries in the Netherlands, an (as per 9-8-2019) incomplete data set)\n",
145164
"<img src=\"https://raw.githubusercontent.com/ookgezellig/WikidataMapMakingWorkshop/master/images/3-3-layered-dutch-public-libraries-wikidata-query.png\" alt=\"Public libraries in the Netherlands, layered by province\" align=\"left\"/>\n"
@@ -175,7 +194,7 @@
175194
},
176195
{
177196
"cell_type": "code",
178-
"execution_count": null,
197+
"execution_count": 2,
179198
"metadata": {},
180199
"outputs": [],
181200
"source": [
@@ -235,7 +254,7 @@
235254
},
236255
{
237256
"cell_type": "code",
238-
"execution_count": null,
257+
"execution_count": 3,
239258
"metadata": {},
240259
"outputs": [],
241260
"source": [
@@ -260,7 +279,7 @@
260279
},
261280
{
262281
"cell_type": "code",
263-
"execution_count": null,
282+
"execution_count": 16,
264283
"metadata": {},
265284
"outputs": [],
266285
"source": [
@@ -269,7 +288,7 @@
269288
},
270289
{
271290
"cell_type": "code",
272-
"execution_count": null,
291+
"execution_count": 17,
273292
"metadata": {},
274293
"outputs": [],
275294
"source": [
@@ -298,9 +317,24 @@
298317
},
299318
{
300319
"cell_type": "code",
301-
"execution_count": null,
302-
"metadata": {},
303-
"outputs": [],
320+
"execution_count": 18,
321+
"metadata": {},
322+
"outputs": [
323+
{
324+
"data": {
325+
"application/vnd.jupyter.widget-view+json": {
326+
"model_id": "c50a357259484776b6e5e608accf55f2",
327+
"version_major": 2,
328+
"version_minor": 0
329+
},
330+
"text/plain": [
331+
"Map(basemap={'url': 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 'max_zoom': 19, 'attribution': 'Map …"
332+
]
333+
},
334+
"metadata": {},
335+
"output_type": "display_data"
336+
}
337+
],
304338
"source": [
305339
"# Now that we have the data ready & loaded, we can start building a layered map step by step\n",
306340
"\n",
@@ -340,7 +374,7 @@
340374
},
341375
{
342376
"cell_type": "code",
343-
"execution_count": null,
377+
"execution_count": 20,
344378
"metadata": {},
345379
"outputs": [],
346380
"source": [
@@ -358,7 +392,7 @@
358392
},
359393
{
360394
"cell_type": "code",
361-
"execution_count": null,
395+
"execution_count": 21,
362396
"metadata": {},
363397
"outputs": [],
364398
"source": [
@@ -395,7 +429,7 @@
395429
},
396430
{
397431
"cell_type": "code",
398-
"execution_count": null,
432+
"execution_count": 9,
399433
"metadata": {},
400434
"outputs": [],
401435
"source": [
@@ -415,7 +449,7 @@
415449
" #===================POPUP TEMPLATE=======================================\n",
416450
" # This template determines the text layout in the popup. \n",
417451
" # With the external css you can tweak the styling of the text. You might need to create this css yourself, \n",
418-
" # or download it from https://paws-public.wmflabs.org/paws-public/User:OlafJanssen/popupstyle.css\n",
452+
" # or download it from https://raw.githubusercontent.com/ookgezellig/WikidataMapMakingWorkshop/master/module3stuff/popupstyle.css\n",
419453
" # and upload it to your own PAWS server\n",
420454
" \n",
421455
" # The approach with rendering the HTML template was found via \n",
@@ -441,10 +475,10 @@
441475
" #https://ipyleaflet.readthedocs.io/en/latest/api_reference/popup.html\n",
442476
" message = HTML()\n",
443477
" message.value = rendered_template\n",
444-
" #message.description = popup_image\n",
478+
" #message.description = popup_image #you could add an image in the popup here\n",
445479
" #============================================================\n",
446480
" \n",
447-
" coor=result['dplLoc']['value'] #library coordinates, eg (53.0671982, 6.4616009)\n",
481+
" coor=result['dplLoc']['value'] #library lat,long coordinates, eg (53.0671982, 6.4616009)\n",
448482
" \n",
449483
" #https://ipyleaflet.readthedocs.io/en/latest/api_reference/circle.html\n",
450484
" circle = Circle(location=coor, radius=12, color=\"red\", fill_color=\"red\", opacity=0.005) #0.005 = hardly visible\n",
@@ -461,7 +495,7 @@
461495
"cell_type": "markdown",
462496
"metadata": {},
463497
"source": [
464-
"Now we want to combine the three layers above \n",
498+
"Now we want to combine the three layers we created in the above cells \n",
465499
"1. simple_heatmap layer \n",
466500
"2. dark background layer \n",
467501
"3. circles popup layer\n",
@@ -471,7 +505,7 @@
471505
},
472506
{
473507
"cell_type": "code",
474-
"execution_count": null,
508+
"execution_count": 22,
475509
"metadata": {},
476510
"outputs": [],
477511
"source": [
@@ -486,7 +520,7 @@
486520
"cell_type": "markdown",
487521
"metadata": {},
488522
"source": [
489-
"The resulting map should look like this\n",
523+
"Your resulting map should look something like this\n",
490524
"\n",
491525
"<img src=\"https://raw.githubusercontent.com/ookgezellig/WikidataMapMakingWorkshop/master/images/3-3-heatmap-with-popup.png\" alt=\"Heatmap Dutch public libraries with popup\" width=\"400\" align=\"left\"/>\n",
492526
"<br clear=\"all\"/>\n",
@@ -500,7 +534,7 @@
500534
"As a next step we want to make a layer displaying the boundaries of all municipalities in The Netherlands that have \n",
501535
"one or more public libraries, using GeoShapes, as [explained in Module 2](https://github.com/ookgezellig/WikidataMapMakingWorkshop/blob/master/OutlineAndNotes.md#module-26-geoshapes-using-sparql-and-osm) of the workshop.\n",
502536
"\n",
503-
"To make this layer, we first need to requets GeoJson geoshapes (boundaries) from Wikidata Q-values. See\n",
537+
"To make this layer, we first need to requets GeoJson geoshapes (municipal boundaries) from Wikidata Q-values. See\n",
504538
"* https://phabricator.wikimedia.org/T138868\n",
505539
"* https://maps.wikimedia.org/geoshape?getgeojson=1&ids=Q701,Q694\n",
506540
"* https://maps.wikimedia.org/geoshape?getgeojson=1&query=SPARQLQuery \n",
@@ -522,7 +556,7 @@
522556
},
523557
{
524558
"cell_type": "code",
525-
"execution_count": null,
559+
"execution_count": 23,
526560
"metadata": {},
527561
"outputs": [],
528562
"source": [
@@ -561,7 +595,7 @@
561595
},
562596
{
563597
"cell_type": "code",
564-
"execution_count": null,
598+
"execution_count": 24,
565599
"metadata": {},
566600
"outputs": [],
567601
"source": [
@@ -591,7 +625,7 @@
591625
"cell_type": "markdown",
592626
"metadata": {},
593627
"source": [
594-
"We have added a number of layers to the map. We can add a control in the top right corner of the map to switch layers on and off.\n",
628+
"in the previous steps we have added a number of layers to the map. Next we can add a control in the top right corner of the map to switch layers on and off.\n",
595629
"\n",
596630
"We also add a Fullscreen control\n",
597631
"\n",
@@ -601,7 +635,7 @@
601635
},
602636
{
603637
"cell_type": "code",
604-
"execution_count": null,
638+
"execution_count": 14,
605639
"metadata": {
606640
"scrolled": false
607641
},
@@ -619,7 +653,7 @@
619653
"cell_type": "markdown",
620654
"metadata": {},
621655
"source": [
622-
"The resulting heatmap looks like this, with the red municipal geoshapes, a popup, a layers control and a fullscreen control\n",
656+
"Your resulting heatmap should look something like this, with the red municipal geoshapes, a popup, a layers control and a fullscreen control\n",
623657
"\n",
624658
"<img src=\"https://raw.githubusercontent.com/ookgezellig/WikidataMapMakingWorkshop/master/images/3-3-netherlands-public-libraries-heatmap.jpg\" alt=\"Dutch public library heatmap with the red municipal geoshapes, popup, layers control and fullscreen control\" width=\"800\" align=\"left\"/>\n",
625659
"<br clear=\"all\"/>"
@@ -629,7 +663,7 @@
629663
"cell_type": "markdown",
630664
"metadata": {},
631665
"source": [
632-
"As a final step for this workshop, we want to export the map to a (stand-alone, off-Wiki) HTML page that can be viewed in a browser.\n",
666+
"As the final step we want to export the map to a (stand-alone, off-Wiki) HTML page that can be viewed in a browser.\n",
633667
"\n",
634668
"https://ipywidgets.readthedocs.io/en/latest/embedding.html#python-interface\n",
635669
"\n",
@@ -638,7 +672,7 @@
638672
},
639673
{
640674
"cell_type": "code",
641-
"execution_count": null,
675+
"execution_count": 15,
642676
"metadata": {},
643677
"outputs": [],
644678
"source": [
@@ -663,7 +697,7 @@
663697
"metadata": {},
664698
"source": [
665699
"## Reusing this notebook\n",
666-
"You are free to reuse this notebook, it is available under the license [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/)\n",
700+
"You are free to reuse this notebook (and all the other [workshop materials](https://github.com/ookgezellig/WikidataMapMakingWorkshop)), as it is available under the license [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/)\n",
667701
"\n",
668702
"![CC-BY-SA logo](https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/CC-BY-SA.svg/200px-CC-BY-SA.svg.png)"
669703
]
@@ -845,7 +879,6 @@
845879
}
846880
],
847881
"metadata": {
848-
"celltoolbar": "Tags",
849882
"kernelspec": {
850883
"display_name": "Python 3",
851884
"language": "python",
@@ -861,7 +894,7 @@
861894
"name": "python",
862895
"nbconvert_exporter": "python",
863896
"pygments_lexer": "ipython3",
864-
"version": "3.6.7"
897+
"version": "3.7.1"
865898
}
866899
},
867900
"nbformat": 4,

0 commit comments

Comments
 (0)