Public
Edited
Mar 19
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
arrow_table = {
await db.registerFileHandle(geofile.name, geofile, duckdb.DuckDBDataProtocol.BROWSER_FILEREADER, true)

const parquet = /\.(geo|)parquet$/.test(geofile.name) //.parquet or .geoparquet

const connection = await db.connect()

await connection.query(`INSTALL spatial; LOAD spatial;`)

const q = (parquet ? `FROM read_parquet('${geofile.name}')` :
`FROM st_read('${geofile.name}')`)
+ ` SELECT * REPLACE(ST_AsGeoJSON(geometry) AS geometry)`
const arrowResult = await connection.query(q)

await connection.close()

return arrowResult // table au format arrow
}
Insert cell
Insert cell
geo = {
const arrow_ds = arrow_table.toArray()
return {
"type": "FeatureCollection",
"features": arrow_ds.map(
({geom, ...rest}) => Object.assign( {},
{type: "Feature", geometry: JSON.parse(geom), properties: {...rest}} )
)
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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