Public
Edited
Oct 31, 2022
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
toGeoJSON = async (fileOrFiles, params = { opts: [], openOpts: []}) => {
const openOptions = params.openOpts || [];
const input = await Gdal.open(fileOrFiles, openOptions);
const options = [
'-f', 'GeoJSON',
'-t_srs', 'EPSG:4326',
'-lco', 'RFC7946=YES'
].concat(params.opts || []);
const output = await Gdal.ogr2ogr(input.datasets[0], options);
const bytes = await Gdal.getFileBytes(output);
await Gdal.close(input);
return JSON.parse(new TextDecoder().decode(bytes));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
nuts2 = toGeoJSON(fgbFile);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
frenchDep = toGeoJSON(gmlFile)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
citiesGeo = toGeoJSON(
citiesFile,
{
openOpts: ['AUTODETECT_TYPE=YES', 'X_POSSIBLE_NAMES=lng', 'Y_POSSIBLE_NAMES=lat'],
opts: ['-s_srs', 'EPSG:4326'],
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
citiesGeo2 = toGeoJSON(
citiesFile2,
{
openOpts: ['AUTODETECT_TYPE=YES', 'GEOM_POSSIBLE_NAMES=coords'],
opts: ['-s_srs', 'EPSG:4326', '-sql', 'SELECT city from cities4'],
}
)
Insert cell
view(citiesGeo2, { width: 700, height: 350 })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cuba = toGeoJSON(files);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
afg = toGeoJSON(gpkg);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bolivia = toGeoJSON(kmlFile);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
JSZip = import('https://cdn.skypack.dev/jszip');
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more