Skip to main content
Not all data in a GeoPackage needs to be spatial. An attributes table stores rows of typed values without any geometry column. This is useful for lookup tables, metadata records, sensor readings, or any other tabular data that you want to keep alongside your spatial data in a single file.

Key classes

AttributesDao

The primary access object for an attributes table. Obtained from geoPackage.getAttributesDao(tableName). Provides standard query, insert, update, and delete methods inherited from UserDao.

AttributesRow

Represents a single row in an attributes table. Use getValue(columnName) to read typed column values.
AttributesDao does not support getBoundingBox() — calling it throws an exception because attributes tables have no spatial extent.

When to use attributes tables

Use attributes tables when your data is not geometric:
ScenarioRecommended table type
Building footprints with address and floor countFeature table (has geometry)
Lookup table of land-use codes and descriptionsAttributes table (no geometry)
Per-layer metadata recordsAttributes table
Sensor readings linked to locations via Related TablesAttributes table
The Related Tables Extension can create explicit relationships between rows in an attributes table and rows in a feature table, giving you the benefits of both.

Example

import { GeoPackageAPI } from '@ngageoint/geopackage';

const geoPackage = await GeoPackageAPI.open('/path/to/file.gpkg');

const attributesDao = geoPackage.getAttributesDao('land_use_codes');
console.log('Row count:', attributesDao.count());

// Iterate all rows
const resultSet = attributesDao.queryForAll();
try {
  while (resultSet.moveToNext()) {
    const row = resultSet.getRow();
    const code = row.getValue('code') as string;
    const description = row.getValue('description') as string;
    console.log(`${code}: ${description}`);
  }
} finally {
  resultSet.close();
}

// Insert a new row
const newRow = attributesDao.newRow();
newRow.setValue('code', 'RES');
newRow.setValue('description', 'Residential');
attributesDao.create(newRow);

geoPackage.close();

Column access

Attributes columns are typed using GeoPackageDataType (TEXT, INTEGER, REAL, BLOB, etc.). Column metadata is available via the AttributesTable returned by attributesDao.getTable():
const table = attributesDao.getTable();
for (const column of table.getColumns()) {
  console.log(column.getName(), column.getDataTypeName());
}

Build docs developers (and LLMs) love