Created
March 22, 2023 14:20
-
-
Save ThomasG77/4ab7840c00aa352f278636ea3f3f0d3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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