diff --git a/README.md b/README.md index 8b45b69..c30684a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ # Lastejobb -Kjører en sekvens med steg (`stages/`) i alfabetisk rekkefølge. +Lager landskapskart i ulike formater + +| Størrelse | Format | Filnavn | URL | +| --------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | +| 5M | Kodeliste | [metadata_med_undertyper.json](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/metadata_med_undertyper.json) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/metadata_med_undertyper.json | +| 92M | GeoJSON | [polygon.32633.geojson](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.geojson) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.geojson | +| 93M | GML | [polygon.32633.gml](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.gml) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.gml | +| 96M | GeoPackage | [polygon.32633.gpkg](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.gpkg) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.gpkg | +| 93M | Spatialite | [polygon.32633.spatialite.sqlite](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.spatialite.sqlite) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.spatialite.sqlite | +| 1M | GML | [polygon.32633.xsd](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.xsd) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.32633.xsd | +| 204M | GeoJSON | [polygon.4326.geojson](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.4326.geojson) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.4326.geojson | +| 93M | Spatialite | [polygon.4326.spatialite.sqlite](https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.4326.spatialite.sqlite) | https://data.artsdatabanken.no/Natur_i_Norge/Landskap/Typeinndeling/polygon.4326.spatialite.sqlite | ## Funksjoner diff --git a/stages/deploy/staging.sh b/stages/deploy/staging.sh new file mode 100755 index 0000000..3bd4a7c --- /dev/null +++ b/stages/deploy/staging.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +scp build/* grunnkart@hydra:~/tilesdata/Natur_i_Norge/Landskap/Typeinndeling \ No newline at end of file diff --git a/stages/deploy/10_metadata.js b/stages/download/10_metadata.js similarity index 75% rename from stages/deploy/10_metadata.js rename to stages/download/10_metadata.js index 57f658e..36df756 100644 --- a/stages/deploy/10_metadata.js +++ b/stages/download/10_metadata.js @@ -1,4 +1,4 @@ -const { http, log } = require("lastejobb"); +const { http } = require("lastejobb"); const url = "https://data.artsdatabanken.no/Natur_i_Norge/Landskap/metadata_med_undertyper.json" http.downloadJson(url, 'metadata.json') diff --git a/stages/download/10_sample.js b/stages/download/10_sample.js deleted file mode 100644 index 4f73597..0000000 --- a/stages/download/10_sample.js +++ /dev/null @@ -1,3 +0,0 @@ -const { log } = require("lastejobb"); - -log.info("Processing...") \ No newline at end of file diff --git a/stages/transform/10_sample.js b/stages/transform/10_sample.js deleted file mode 100644 index 4f73597..0000000 --- a/stages/transform/10_sample.js +++ /dev/null @@ -1,3 +0,0 @@ -const { log } = require("lastejobb"); - -log.info("Processing...") \ No newline at end of file diff --git a/stages/transform/50_vector_formats.sh b/stages/transform/50_vector_formats.sh new file mode 100644 index 0000000..4bf3357 --- /dev/null +++ b/stages/transform/50_vector_formats.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e +cd build +ogr2ogr -f GML polygon.32633.gml polygon.32633.geojson +ogr2ogr polygon.32633.spatialite.sqlite polygon.32633.geojson +ogr2ogr -t_srs EPSG:4326 polygon.4326.geojson polygon.32633.geojson +ogr2ogr -f GPKG polygon.32633.gpkg polygon.32633.geojson diff --git a/stages/transform/step2.js b/stages/transform/step2.js index 8600f6b..bf14580 100644 --- a/stages/transform/step2.js +++ b/stages/transform/step2.js @@ -1,8 +1,13 @@ +const { io, json } = require('lastejobb') const fs = require("fs"); -const json = read("temp/landskap_32633.geojson", "S_kode"); +var meta = io.lesTempJson('metadata.json') +meta = json.arrayToObject(meta.items, { uniqueKey: "kode" }) +const geojson = read("temp/landskap_32633.geojson", "S_kode"); +geojson.name = "NiN Landskap" console.log("Mapping to GeoJSON"); -fs.writeFileSync("build/polygon.32633.geojson", JSON.stringify(json)); +//fs.writeFileSync("build/polygon.32633.geojson", JSON.stringify(geojson)); +io.skrivBuildfil("polygon.32633.geojson", geojson) function read(fn) { const json = JSON.parse(fs.readFileSync(fn)); @@ -22,6 +27,18 @@ function floatToInt(geom) { function map(props) { props.kode = fixKode(props.S_kode) props.KLG_RE_ID = props.KLG_RE_ID_ + const metadata = meta["NN-" + props.kode] + props.navn = metadata.tittel.nb + props.grunntype = props["GT_nr"] + delete props["GT_nr"] + props.hovedtype = props.HT[1] + delete props.HT + props.hovedtypegruppe = props.HTG + delete props.HTG + props.arealbrukspreg = metadata.flagg["NN-LA-TI-AP-AL"] ? 1 : 0 + // TODO: if (props.Arealbrukspreg != props.Naturlands) debugger + delete props.Naturlands + delete props.Navn delete props.KLG_RE_ID_ delete props.S_kode delete props.Shape_Leng @@ -29,6 +46,17 @@ function map(props) { delete props.UID_GT delete props.Nivå delete props.Pred_Lnr + const klger = ["AI", "AI_KS", "BP", "IP", "IYK", "JP", "KA", "RE_IA", "RE_ID", "RE_KS", "VE", "VP"] + for (var k of klger) + klg(props, "KLG_" + k) +} + +function klg(props, srcKey) { + const destKey = srcKey.toLowerCase() + var value = props[srcKey] + if (value !== "NA") value = parseInt(value) + props[destKey] = value + delete props[srcKey] } function fixKode(kode) {