This repository contains Finland's municipalities in TopoJSON format. The geometry was somewhat simplified in order to decrease the resulting file size. The contents are up to date as of September 2017.
The municipalities are inside an object called kuntarajat
. Each municipality
has a properties
object with code
(string id) and name
fields.
Included is also a GeoJSON of the municipalities' centroids.
Convert the TopoJSON to GeoJSON using topojson:
import { feature } from 'topojson';
const municipalitiesTopoJSON = require('./finland-municipalities-topojson.json');
const geoJSON = feature(
municipalitiesTopoJSON,
municipalitiesTopoJSON.objects.kuntarajat,
);
The file was generated by simplifying https://github.com/tomimick/mapcolorizer/blob/master/data-finland/data/kuntarajat.geojson using http://mapshaper.org/. Since the source data contained old municipalities that no longer exist, these were combined with the correct neighbouring municipalities with the following command:
topomerge kuntarajat=kuntarajat -k '["476", "174"].indexOf(d.properties.code) > -1 ? "297" : "532" === d.properties.code ? "398" : "283" === d.properties.code ? "098" : "164" === d.properties.code ? "301" : "413" === d.properties.code ? "609" : "442" === d.properties.code ? "051" : "319" === d.properties.code ? "783" : "838" === d.properties.code ? "423" : d.properties.code' < finland-municipalities-topojson.json > finland-municipalities-topojson-new.json
Once merged, the properties
object (with code
and name
) needed to be added
to the combined shapes manually.
The centroids were generated with:
import { geoCentroid } from 'd3-geo';
import { feature } from 'topojson';
const municipalitiesTopoJSON = require('./finland-municipalities-topojson.json');
const geojson = feature(
municipalitiesTopoJSON,
municipalitiesTopoJSON.objects.kuntarajat,
);
JSON.stringify({
type: 'FeatureCollection',
features: geojson.features.map(f => ({
type: 'Feature',
id: f.properties.code,
geometry: {
type: 'Point',
coordinates: geoCentroid(f),
},
})),
}),