• Stars
    star
    224
  • Rank 173,040 (Top 4 %)
  • Language
    TypeScript
  • License
    BSD 3-Clause "New...
  • Created over 11 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Swiss geodata as TopoJSON

swiss-maps on npm

This is the documentation for the swiss-maps npm package and website v4. For the previous Makefile and instructions, please check the legacy branch.

Swiss Maps

This repository provides a mechanism to generate TopoJSON from publicly available swisstopo geodata.

The geodata is based on the generalized from the FSO.

The Makefile cleans the source data further, so the features are as consistent as possible across different years and the properties are consistently named.

For convenience, the generated files are published on npm

Getting Started

All Shapefiles and TopoJSON files are cleaned and pre-packaged in this package.

You can install it locally using npm:

npm i swiss-maps

You can read the files from the installed package directory, which is structured like this:

- node_modules/
  - swiss-maps/
    - 2010/
      - cantons.{dbf,prj,shp,shx}
      - country.{dbf,prj,shp,shx}
      - districts.{dbf,prj,shp,shx}
      - lakes.{dbf,prj,shp,shx}
      - municipalities.{dbf,prj,shp,shx}
      - ch-combined.json (TopoJSON)
    - 2011/
      ...
    - 2021/

The TopoJSON file combines all layers into one file. Separate TopoJSON files for single layers will be added in the future.

Use the TopoJson files in your web application

Load from Unpkg.com

If you don't want to install anything and just want to load the file, you can fetch it from https://unpkg.com (or any other npm registry CDN).

import * as topojson from "topojson-client";

const res = await fetch(`https://unpkg.com/swiss-maps@4/2021/ch-combined.json`);
const topo = await res.json();

const municipalities = topojson.feature(topo, topo.objects.municipalities);
// Render the municipalities ...

Bundled app (e.g. Next.js)

If you're using a bundler that can resolve locally installed npm packages, you can add the swiss-maps npm package to your project.

npm i swiss-maps
import * as topojson from "topojson-client";

const topo = await import(`swiss-maps/2021/ch-combined.json`);

const municipalities = topojson.feature(topo, topo.objects.municipalities);

// Render the municipalities ...

License

The code in this repository is licensed under BSD-3-Clause.

The geodata is published under a non-commercial license and needs to be attributed with the source "Bundesamt fΓΌr Statistik (BFS), GEOSTAT".

More Repositories

1

catalog

Create living style guides using Markdown or React
JavaScript
1,580
star
2

gsheets

Get public Google Sheets as plain JavaScript/JSON
JavaScript
86
star
3

d3-grid

D3 grid layout
JavaScript
77
star
4

historical-world-atlas

World TopoJSON data from 2000 BC until today
31
star
5

d3-comparator

Multi-dimensional comparator function generator for D3
JavaScript
28
star
6

d3-indent

D3 indented tree layout.
JavaScript
27
star
7

galaxy-of-covers

Galaxy of Covers: Honoring the evolution of the 50 most popular cover songs of all time.
JavaScript
23
star
8

chart-server

A server for a light-weight charting system.
JavaScript
17
star
9

swiss-transport-flows

Submission for the make.opendata.ch camp spring 2012.
JavaScript
6
star
10

make-opendata-finance

Submission for the make.opendata.ch camp spring 2013
Ruby
5
star
11

vega-react-hooks-example

Create a chart with Vega, manage state with React
JavaScript
4
star
12

inclusive-data

This repo is an experiment to develop inclusive data visualization
JavaScript
4
star
13

afghan-2010-visualizations

A set of static and interactive information graphics created in collaboration with Democracy International for their Election Observation Mission to Afghanistan 2010.
JavaScript
4
star
14

eslint-config-interactivethings

The Interactive Things ESLint config
JavaScript
3
star
15

khan-academy-map

Map covering the Khan Academy video library
CoffeeScript
3
star
16

catalyst

Catalyst is a small and solid foundation for responsive CSS layouts
JavaScript
3
star
17

swiss-army-contaminated-sites

Submission for the make.opendata.ch camp.
HTML
3
star
18

SassDoc

Get a visual overview of what's inside your Sass files through your web browser.
JavaScript
2
star
19

postcss-includes

JavaScript
2
star
20

packup

WIP: A no-config development tool for modern web apps
JavaScript
2
star
21

create-catalog

Create a Catalog
JavaScript
2
star
22

LifeofPlastic

TypeScript
2
star
23

make.opendata.ch

Website for the first Open Data Camp in Switzerland.
PHP
2
star
24

webglworkshop-examples

Examples for Mark's WebGL workshop
HTML
1
star
25

catalog-specimen-project

Catalog Project Specimen
JavaScript
1
star
26

road-to-school

The Road to School – The Syrian conflict is robbing millions of children of their right to education.
JavaScript
1
star
27

catalog-docs

Catalog Docs
Makefile
1
star