GeoLibre Attribute Table Query Operations: A Complete Guide to Filtering and Expressions
The GeoLibre attribute table supports logical, comparison, pattern-matching, spatial, and arithmetic query operations parsed by the core expression engine in @geolibre/core and executed via DuckDB-WASM or client-side processing.
The GeoLibre attribute table, part of the open-source opengeos/GeoLibre repository, provides a robust interface for inspecting vector feature properties and raster attribute data. Users can filter, sort, and edit attributes using an expressive query language powered by the @geolibre/core expression engine. These GeoLibre attribute table query operations range from simple value comparisons to advanced spatial predicates, executing either client-side for editable GeoJSON layers or through DuckDB-WASM for complex analytical queries.
Supported Query Operation Categories
GeoLibre implements a comprehensive expression language that supports eight major categories of operations.
Logical Operators
Combine multiple filter conditions using boolean logic:
AND— Returns records where both conditions are trueOR— Returns records where either condition is trueNOT— Negates a condition
Comparison Operators
Evaluate equality and ordering for numeric and string fields:
=,!=— Equality and inequality>,<,>=,<=— Greater than, less than, and inclusive variants
Set Membership
Test whether values exist within defined collections:
IN (value1, value2)— Field matches any item in the listNOT IN (...)— Field matches no items in the list
Pattern Matching
Perform case-insensitive substring and pattern searches:
LIKE '%text%'— SQL-style pattern matching with wildcardsSTARTS_WITH,ENDS_WITH— Prefix and suffix matchingCONTAINS— Substring search
Null Handling
Detect missing or undefined values:
IS NULL— Field has no valueIS NOT NULL— Field has any value
Arithmetic Operations
Compute values within expressions:
+,-,*,/,%— Standard mathematical operators for numeric fields
Spatial Predicates
Execute geometric relationships when layers contain geometry data (forwarded to DuckDB-WASM spatial extensions):
INTERSECTS(geometry)— Features that cross or overlapWITHIN(geometry)— Features completely inside boundsCONTAINS(geometry)— Features that enclose the specified geometry
Utility Functions
Transform and clean attribute data:
UPPER(),LOWER()— Case conversionTRIM()— Remove whitespaceCOALESCE()— Return first non-null valueROUND(),ABS()— Numeric rounding and absolute value
How the Query Engine Works
The attribute table leverages the core expression parser located in packages/core/src/expressions.ts to tokenize and validate query strings. According to the opengeos/GeoLibre source code, the system processes queries through two distinct execution paths.
Client-side execution handles editable GeoJSON layers directly within the browser, applying filters to the in-memory feature collection.
DuckDB-WASM execution routes complex analytical queries, including spatial operations, through the WebAssembly-based DuckDB engine defined in packages/processing/src/wasm-convert.ts. Spatial predicates like ST_Intersects are translated into DuckDB spatial functions for high-performance geoprocessing.
The UI synchronizes selections between the table and map canvas via packages/map/src/MapCanvas.tsx, ensuring filtered results highlight corresponding map features immediately.
Practical Implementation Examples
The following TypeScript React examples demonstrate how to apply query operations when instantiating the AttributeTable component in apps/geolibre-desktop.
Basic Numeric Filter
Display only features where the population exceeds 10,000:
<AttributeTable
layer={myVectorLayer}
filter="population > 10000"
/>
Text Pattern Matching
Search for parks containing "National" in their name:
<AttributeTable
layer={myVectorLayer}
filter="name LIKE '%National%'"
/>
Complex Logical Expressions
Combine multiple conditions using parentheses and boolean operators:
<AttributeTable
layer={myVectorLayer}
filter="(type = 'road' OR type = 'rail') AND length >= 500"
/>
Spatial Queries with DuckDB-WASM
Filter features intersecting a user-drawn polygon:
<AttributeTable
layer={myVectorLayer}
filter="ST_Intersects(geom, $myPolygon)"
/>
In the desktop application, users construct these queries interactively through the filter row at the top of the attribute table, selecting fields from dropdowns populated via apps/geolibre-desktop/src/lib/expression-inputs.ts.
Key Source Files
Understanding the query operation implementation requires examining these specific modules:
packages/core/src/expressions.ts— Core parser that tokenizes query strings and validates operator syntaxapps/geolibre-desktop/src/components/panels/AttributeTable.tsx— Main UI component that builds and applies filter expressionsapps/geolibre-desktop/src/lib/expression-inputs.ts— Helper utilities for retrieving attribute names and data typespackages/map/src/MapCanvas.tsx— Maplibre integration that syncs table filters with layer renderingpackages/processing/src/wasm-convert.ts— DuckDB-WASM bridge for executing spatial and analytical SQL functions
Summary
- GeoLibre supports eight categories of query operations: logical, comparison, set membership, pattern matching, null checks, arithmetic, spatial, and utility functions.
- The expression parser in
packages/core/src/expressions.tsvalidates all query syntax before execution. - DuckDB-WASM powers spatial predicates and complex analytics, while simple filters run client-side for GeoJSON layers.
- Users interact with queries through a filter row UI that constructs expression strings automatically.
- Query results synchronize bidirectionally between the attribute table and the map canvas via
MapCanvas.tsx.
Frequently Asked Questions
What expression syntax does GeoLibre use for attribute queries?
GeoLibre uses a SQL-like expression syntax parsed by its core expression engine. The syntax supports standard operators including AND, OR, LIKE, IN, and spatial functions such as ST_Intersects, making it familiar to users of traditional GIS and database systems.
Can I perform spatial queries directly in the attribute table?
Yes, spatial queries are supported when working with layers that contain geometry data. These operations leverage DuckDB-WASM spatial extensions and use predicates like INTERSECTS, WITHIN, and CONTAINS. However, spatial filtering requires the DuckDB-WASM backend rather than client-side processing.
How does GeoLibre handle large datasets when filtering?
For large datasets, GeoLibre offloads query execution to DuckDB-WASM (packages/processing/src/wasm-convert.ts), which provides high-performance analytical SQL capabilities running in WebAssembly. Smaller editable GeoJSON layers are filtered client-side in memory for responsive editing.
Where is the query logic defined in the source code?
The query parsing logic resides in packages/core/src/expressions.ts, while the UI implementation is found in apps/geolibre-desktop/src/components/panels/AttributeTable.tsx. The map synchronization logic connecting table filters to visual selections is implemented in packages/map/src/MapCanvas.tsx.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →