# How to Gemeindescan [ToC] ## Intro The Gemeindescan sandbox environment is available at sandbox.gemeindescan.ch. This Mini How-To gives you a quick introduction how to work with the platform, browse and download prepared datasets and how you can add your own map based analysis to share with others. To start uploading snapshots (up to 20MB in file size), click login and use ``` username: demo password: hackathon ``` You are redirected to a general workspace for anyone to upload and edit snapshots freely. If you are interested in a seperate login and workspace e.g. for your challenge let us know via [@cividitech](https://twitter.com/cividitech) or send us an email to sandbox@gemeindescan.ch. ## Create your own Snapshot - Option 1: QGIS Plugin The experimental QGIS Pugin "[Spatial Data Package Export](https://github.com/cividi/spatial-data-package-export)" is available via the [QGIS plugin repository](https://plugins.qgis.org/plugins/SpatialDataPackageExport/) or on [GitHub](https://github.com/cividi/spatial-data-package-export/releases/). [Direct Download](https://github.com/cividi/spatial-data-package-export/releases/download/0.2.0/SpatialDataPackageExport.0.2.0.zip) To install: 1. make sure to have [QGIS](https://qgis.org) 3.14 or later installed 2. Open Plugins -> Manage Plugins 3. Search for Spatial Datapackage Export 4. Click Install ![](https://i.imgur.com/UydrxYB.png) ![](https://i.imgur.com/0pIjX88.png) Alternativly download the latest release from github.com/cividi/spatial-data-package-export/releases and manually install via zip or build from source. ## Create your own Snapshot - Option 2: Write your own exporter Datapackage consists of metadata and data itself. For rednering a map you need to include the styling (Mapbox Simple Styles) to the exported GeoJSON. Datapackage (Snapshot) = metadata + styled (geo)json The full spec, a JSON schema and examples are available [here](https://github.com/cividi/spatial-data-export-spec). ### 1. Metadata. Here is recommended minimal schema to use: ```yaml name: "{{ name }}" license: "ODC-By-1.0" licenses: - url: "https://opendatacommons.org/licenses/by/1.0/" type: "ODC-By-1.0" views: - name: "mapview" specType: "gemeindescanSnapshot" spec: title: "{{ title }}" description: "{{ description }}" attribution: "" bounds: "{{ bounds_to_have }} " legend: "{{ legend }}"" resources: ["data-layer", "mapbox-background"] sources: - url: "https://www.openstreetmap.org/copyright" title: "Karte: Mapbox, © OpenStreetMap" resources: - name: "data-layer" mediatype: "application/vnd.geo+json" or "application/vnd.simplestyle-extended" see below data: name: "data" type: "FeatureCollection" features: "{{ STYLED DATA }}" - name: "mapbox-background" path: "mapbox://styles/gemeindescan/ckc4sha4310d21iszp8ri17u2" mediatype: "application/vnd.mapbox-vector-tile" data: ``` In this schema you have variables in "{{ _variable_ }}", which you would rewrite to text: "{{ _variable_ }}" --> "desired variable" {{ bounds_to_have }} - defines the frame of the map. - example: ```python "geo:47.310897, 8.458443", "geo:47.446897, 8.638687" ``` {{ legend }} - legend shown - example: ```python [{"label": 0, "size": "3.0", "shape": "circle", "primary": false, "fillColor": "#f30000", "fillOpacity": 0.7, "strokeColor": "#232323", "strokeWidth": 1.0, "strokeOpacity": 1.0}, {"label": 1, "size": "3.0", "shape": "circle", "primary": false, "fillColor": "#f30a00", "fillOpacity": 0.7, "strokeColor": "#232323", "strokeWidth": 1.0, "strokeOpacity": 1.0}, {"label": 2, "size": "3.0", "shape": "circle", "primary": false, "fillColor": "#f41400", "fillOpacity": 0.7, "strokeColor": "#232323", "strokeWidth": 1.0, "strokeOpacity": 1.0}] ``` ### 2. Styled data {{ STYLED DATA }} -- your data, each data point has to have style properties, depending on which type of data layer you want to add. #### 2.1. Mediatypes A layer can be either of these three mediatypes: - `application/geo+json` -> [Simple Style GeoJSON](https://github.com/mapbox/simplestyle-spec) - `application/simplestyles-extended` -> Circles from points w/ a radius - `application/vnd.mapbox-vector-tile` -> Mapbox style background layer ### 3. Examples -example for a layer with points shown as circles ```python {"type": "Feature", "properties": { "name": "2EtJFks9cv5AD1V7tOao2L", "score": 13, "category": "13", "fill": "true", "fillColor": "#f98500", "fillOpacity": 0.7, "stroke": "true", "color": "#232323", "opacity": "1.0", "weight": 1.0, "radius": "3.0", "strokeColor": "#232323" }, "geometry": {"type": "Point", "coordinates": [8.5552764, 47.3757927]} } ``` -example for a layer with polygons styled as [Simple Styles](https://github.com/mapbox/simplestyle-spec) ```python {"type": "Feature", "properties": {"name": "2EtJFks9cv5AD1V7tOao2L", "score": 13, "category": "13", "fill": "#f98500", "fill-opacity": 0.7, "stroke": "true", "color": "#232323", "opacity": "1.0", "weight": 1.0, "radius": "3.0", "strokeColor": "#232323"}, "geometry": { "type": "Polygon", "coordinates": [[[8.5552764, 47.3757927],[8.5452764, 47.3657927],[8.5552764, 47.3657927]]]}} ``` More detailed mappings of the property names are available [here](https://hackmd.io/@n0rdlicht/HkaDNg_rL). ## Upload via web interface Once you acquired a new snapshot via QGIS or your own scripts, head over to the sandbox and login with sandbox / lenzburg. You should be redirected to a workspace with one or many existing snapshots. You can upload a new snapshot via the plus button on the bottom of the list or replace an existing one. ![](https://raw.githubusercontent.com/cividi/handbook/main/images/snapshot-upload.gif) ## Examples - [(Geo)Spatial Data Data Package Specification](https://github.com/cividi/spatial-data-package-spec) - [Streetwise Spatial Data Package](https://github.com/Streetwise/streetwise-datapackage) - [Basic Datasets Lenzburg](https://github.com/cividi/scl-lenzburg)