Skip to content
pyautark (soon)

Retrieving data

Once data is loaded or analyzed, autk-db provides getter methods to move results from DuckDB back into JavaScript. These methods let you inspect registered tables, read rows as plain objects, export vector layers as GeoJSON, export raster tables in a map-friendly format, and query layer bounding boxes.

Tables metadata

Use getTablesMetadata() to inspect the tables registered in the current workspace. Each entry is table metadata, not the table rows themselves. This is useful when you want to see what is available before calling getTable, getLayer, getRaster, or getLayersMetadata.

The returned metadata includes:

  • name — table name used by autk-db methods
  • columns — DuckDB column names and types
  • source — table origin, such as 'csv', 'osm', 'geojson', or 'geotiff'
  • type — table type such as 'pointset', 'polygons', 'roads', or 'raster'

OSM layer types

When a table comes from OSM auto-loading, its type usually reflects one of the predefined thematic layers:

  • surface — base land polygons used as the workspace surface
  • parks — green and recreational areas
  • water — rivers, lakes, coastlines, and other water features
  • roads — line features representing the street network
  • buildings — polygon features representing building footprints

Layers metadata

getLayersMetadata() returns only the vector tables that can be exported with getLayer. This is useful when a workspace contains many tables and you want to know which ones are ready for map rendering or layer export.

Layer versus table

The entries returned by getLayersMetadata() are still DuckDB tables. In other words, a layer in this context is a table whose contents can be exported as a vetor layer.

Raster metadata

getRastersMetadata() returns only the raster tables that can be exported with getRaster. This is useful when a workspace contains many tables and you want to know which raster datasets are ready for map rendering or raster export.

Layer versus raster table

The entries returned by getRastersMetadata() are also DuckDB tables. The difference is that a layer usually refers to vector geometries that can be exported with getLayer, while a raster table stores pixel-based data that must be exported with getRaster.

Get table data

getTable returns all rows from a registered table as plain JavaScript objects. It works with CSV, JSON, vector, and raster tables.

Try changing the code above

Use the live code box to experiment with getTable. For example, try changing tableName, logging rows.length, or inspecting different properties from the returned objects.

List of getTable parameters

OptionTypeDescription
tableNamestringTable name.

Get layer data

getLayer exports a renderable vector table as a GeoJSON FeatureCollection. Use getLayersMetadata to see which tables qualify.

The returned FeatureCollection includes a bbox property. The bounding box is resolved from the workspace bounds when available, then from the layer geometry itself.

Vector tables only

Calling getLayer on a non-vector table throws an error. Use getLayersMetadata to inspect the available vector tables, and use getRaster for raster tables.

List of getLayer parameters

OptionTypeDescription
layerTableNamestringLayer table name.

Get raster data

getRaster exports a loaded GeoTIFF table as a packed raster FeatureCollection. Pass the result to autk-map with loadRasterCollection().

If you need metadata for raster tables before exporting them, use getRastersMetadata().

Try changing the previous example

Modify the previous code sample to explore more of autk-db. For example, try loading a different raster table or inspect the returned packed properties before passing the result to autk-map.

List of getRaster parameters

OptionTypeDescription
tableNamestringGeoTIFF table name.

Get bounding boxes

Bounding boxes are useful for camera framing, clipping rasters, and defining grid extents. getBoundingBoxFromLayer() computes the bounding box from the geometry of a specific renderable table.

The returned object contains minLon, minLat, maxLon, and maxLat properties. However, these values are not always expressed in latitude and longitude. They are returned in the coordinate system used by the current workspace.

Missing or non-geometric layers

getBoundingBoxFromLayer() throws an error if the database is not initialized, the layer table is missing, or the table does not have a geometry column.

Choosing a getter

MethodReturnsUse for
getTablesMetadata()Table metadata arrayAll table metadata
getLayersMetadata()Table metadata arrayVector layer metadata
getRastersMetadata()Table metadata arrayRaster table metadata
getTable(name)Record<string, unknown>[]Plain rows
getLayer(name)FeatureCollectionVector layer export
getRaster(name)FeatureCollectionRaster layer export
getBoundingBoxFromLayer(name)BoundingBoxLayer bounds

Released under the MIT License.