├── data ├── french_departments.gpkg-wal ├── covid_data.ods ├── french_departments.gpkg └── french_departments.gpkg-shm ├── images ├── map.png └── qgis.png ├── sparkline_map.qgz └── README.md /data/french_departments.gpkg-wal: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datagistips/sparkline_map/HEAD/images/map.png -------------------------------------------------------------------------------- /images/qgis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datagistips/sparkline_map/HEAD/images/qgis.png -------------------------------------------------------------------------------- /sparkline_map.qgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datagistips/sparkline_map/HEAD/sparkline_map.qgz -------------------------------------------------------------------------------- /data/covid_data.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datagistips/sparkline_map/HEAD/data/covid_data.ods -------------------------------------------------------------------------------- /data/french_departments.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datagistips/sparkline_map/HEAD/data/french_departments.gpkg -------------------------------------------------------------------------------- /data/french_departments.gpkg-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datagistips/sparkline_map/HEAD/data/french_departments.gpkg-shm -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # COVID-19 Sparkline Map 2 | 3 | ![](images/map.png) 4 | 5 | ## Steps 6 | [Download QGIS](https://www.qgis.org/fr/site/forusers/download.html) 7 | 8 | I used version `3.12` 9 | 10 | Open project `sparkline_map.qgz` 11 | 12 | You'll have this : 13 | ![](images/qgis.png) 14 | 15 | That's it ! Now, play with styling, parameters 16 | 17 | ## Data 18 | - [French Boundaries from IGN](https://www.data.gouv.fr/fr/datasets/admin-express/) 19 | - [Covid-19 cases from Santé Publique France](https://www.data.gouv.fr/fr/datasets/donnees-hospitalieres-relatives-a-lepidemie-de-covid-19/) 20 | 21 | ## Expression 22 | We use this expression for the line geometry : 23 | 24 | with_variable( 25 | 'height', 26 | -- Height factor for each segment. Total height will be nb cases * @height 27 | 100, 28 | with_variable( 29 | -- Width of the line, starting from centroid 30 | 'width', 31 | 200000, 32 | with_variable( 33 | 'nb_cases', 34 | array_sort( 35 | relation_aggregate( 36 | -- Relation name 37 | 'covid_data_dep_french_dep_INSEE_DEP', 38 | -- Compile in an array 39 | 'array_agg', 40 | -- Calculate number of cases 41 | to_int("dc")+to_int("hosp")+to_int("rea")+to_int("rad") 42 | ) 43 | ), 44 | -- Create geometry 45 | geom_from_wkt( 46 | -- Create WKT String 47 | 'LINESTRING (' || 48 | -- First node is the centroid 49 | x(centroid($geometry))||' '||y(centroid($geometry)) ||','|| 50 | -- Paste the node coordinates 51 | array_to_string( 52 | -- Iterate over indexes 53 | array_foreach( 54 | -- Generate a series over the indexes / nodes 55 | generate_series(1, array_length(@nb_cases)), 56 | -- X Coordinate of the node 57 | to_string(x(centroid($geometry)) + (@element/array_length(@nb_cases)*@width)) ||' '|| 58 | -- Y coordinate of the node 59 | to_string(y(centroid($geometry)) + @nb_cases[@element]*@height) 60 | ), 61 | ',') || ')' 62 | ) 63 | ))) 64 | 65 | Also, the labels are positioned using the same kind of expression. 66 | 67 | ## Links 68 | [See my blog post for an explanation of the expression code](https://datagistips.hypotheses.org/488) 69 | 70 | ## Map image licence 71 | CC BY SA NC 72 | 73 | --------------------------------------------------------------------------------