Skip to content

Instantly share code, notes, and snippets.

@Pyppe
Last active May 23, 2020 08:55
Show Gist options
  • Save Pyppe/1b7e0a9536b9568b80c7d5099316a0e2 to your computer and use it in GitHub Desktop.
Save Pyppe/1b7e0a9536b9568b80c7d5099316a0e2 to your computer and use it in GitHub Desktop.
Suomen kuntakartta 2017 GeoJSON

1. Load and transform TietoaKuntajaosta_2017_4500k.zip from kartat.kapsi.fi

wget "http://kartat.kapsi.fi/files/kuntajako/kuntajako_4500k/etrs89/shp/TietoaKuntajaosta_2017_4500k.zip"
unzip TietoaKuntajaosta_2017_4500k.zip
ogr2ogr -f GeoJSON -t_srs crs:84 SuomenKuntajako_2017_4500k.geo.json SuomenKuntajako_2017_4500k.shp

2. Transform and enhance GeoJSON

  • Added "maakunta" information from Wikipedia
// Kunta -> Maakunta
const mapping = _.reduce($('.wikitable.sortable.jquery-tablesorter tbody tr').toArray(), (acc, el) => {
  acc[$(el).find('td:eq(2)').text()] = $(el).find('td:eq(5)').text();
  return acc;
}, {});

// Update orginal GeoJSON
_.forEach(geoJson.features, f => {
  const name = f.properties.NAMEFIN;
  const parent = mapping[name];
  if (!parent) {
    throw `No parent found for ${name}`;
  }
  f.properties = { name, parent };
});
geoJson.features = _.sortBy(geoJson.features, f => f.properties.name);
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment