wololo/csv_to_geojson.ts

37 lines
1 KiB
TypeScript
Raw Normal View History

/**
* csv_to_geojson.ts
*
2025-04-11 15:53:23 +02:00
* Convertir un fichier CSV en GeoJSON, en précisant les colonnes latitude et longitude
*
* Utilisation:
*
* npx ts-node csv_to_geojson.ts -d etalab_data/panneaux -f panneaux_limite_de_vitesse_fr_panoramax_detections.csv --latColumn 'GPSLatitude' --lonColumn 'GPSLongitude' -h
*
*/
import fs from 'fs';
import path from 'path';
import minimist from 'minimist';
2025-04-11 15:53:23 +02:00
import { csvToGeoJSON, checkFile, countGeoJSONFeatures } from './csv_to_geojson.utils';
2025-04-17 17:34:39 +02:00
import { CSVConversionOptions } from './csv_to_geojson.utils';
2025-04-11 15:53:23 +02:00
// config des arguments de conversion
const args = minimist<CSVConversionOptions>(process.argv.slice(2), {
alias: {
2025-04-11 15:53:23 +02:00
dir: 'd', // dossier source
file: 'f', // fichier source
// infos pour un fichier CSV en source au lieu d'un fichier geojson
latColumn: 'lat', // colonne latitude
lonColumn: 'lon', // colonne longitude
hasHeaders: 'h', // headers présents
},
default: {
hasHeaders: true,
},
});
checkFile(args);
csvToGeoJSON(args);
countGeoJSONFeatures(args);