Replies: 2 comments 4 replies
-
I think part of the problem here is that the Arrow data is likely not a normal array of GeoJSON features (it's probably a struct containing a FeatureCollection object). This might cause problems at various points if the data inside arrow isn't properly converted to "standard" JS objects. But instead of worrying about that, you might want to back up a step. Your example loads a file in the browser, registers it with DuckDB, performs some queries, and then pulls the data back out of DuckDB -- all before creating a visualization. However, Mosaic is intended to query DuckDB directly! I can't perform the join (as you did not share that file), but here is a simpler example you might build off of. The following assumes you've already set up Mosaic to use a DuckDB // construct url to us states geojson
// this assumes the file is in the same directory as the current web page
const url = new URL('us-states.json', window.location);
// load spatial extension, then load geojson file
await vg.coordinator().exec([
vg.loadExtension('spatial'),
vg.loadSpatial('state_features', url)
]);
// create a state map
// the geo mark queries DuckDB to extract the state geometry as GeoJSON
const geoPlot = vg.plot(
vg.geo(vg.from('state_features'), {
fill: 'gray',
fillOpacity: 0.2,
stroke: 'white',
strokeWidth: 1
}),
vg.projectionType('albers-usa'),
vg.width(700)
);
// add map to page
document.body.appendChild(geoPlot); |
Beta Was this translation helpful? Give feedback.
-
FWIW:
Aside from the metadata to describe the geometry type of the column, this overlaps with the GeoArrow spec for defining a column of geometries in Arrow. Once duckdb/duckdb-spatial#153 is implemented, DuckDB spatial will be able to ingest and export GeoArrow data with nearly zero overhead, and it'll be much faster than converting to/from GeoJSON |
Beta Was this translation helpful? Give feedback.
-
Hey team,
We are working with some GeoJSON data that we want to enrich with, let's say, a value that represents the population of each US state.
That all works fine. We run into an issue while attempting to feed that data to the Geo Plot.
The resulting Arrow Table from our query above represents the
geometry.coordinates
property as a set of nested Vectors.The Vector class does not implement square bracket notation for indexing into arrays so we get into trouble on line 41 in the screenshot below:
Any advice for how best to feed our Geo plot the GeoJSON it needs?
Thanks in advance.
us-states.json
Beta Was this translation helpful? Give feedback.
All reactions