Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Created March 22, 2023 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasG77/4ab7840c00aa352f278636ea3f3f0d3e to your computer and use it in GitHub Desktop.
Save ThomasG77/4ab7840c00aa352f278636ea3f3f0d3e to your computer and use it in GitHub Desktop.
const zlib = require('zlib');
const unzip = zlib.createUnzip();
const fs = require('fs');
var geojsonStream = require('geojson-stream');
function mergeFeatureCollectionStream (inputs) {
var out = geojsonStream.stringify();
inputs.map(async (file) => {
fs.createReadStream(file)
.pipe(unzip)
.pipe(geojsonStream.parse())
.pipe(out)
});
return out;
}
var mergedStream = mergeFeatureCollectionStream([
'cadastre-38002-parcelles.json.gz',
'cadastre-38006-parcelles.json.gz'
])
mergedStream.pipe(process.stdout);
const fs = require('fs');
var geojsonStream = require('geojson-stream');
function mergeFeatureCollectionStream (inputs) {
var out = geojsonStream.stringify();
inputs.forEach(function(file) {
fs.createReadStream(file)
.pipe(geojsonStream.parse())
.pipe(out);
});
return out;
}
var mergedStream = mergeFeatureCollectionStream([
'cadastre-38002-parcelles.json'
,'cadastre-38006-parcelles.json'
])
mergedStream.pipe(process.stdout);
npm i geojson-stream
wget "https://cadastre.data.gouv.fr/data/etalab-cadastre/2023-01-01/geojson/communes/38/38002/cadastre-38002-parcelles.json.gz"
wget "https://cadastre.data.gouv.fr/data/etalab-cadastre/2023-01-01/geojson/communes/38/38006/cadastre-38006-parcelles.json.gz";
gzip -k -f -d cadastre-38002-parcelles.json.gz
gzip -k -f -d cadastre-38006-parcelles.json.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment