Queries Examples


Example: Create and Run a Query

See how the different parts of a command window operate when creating and running SQL queries.   Includes use of the Log tab as well as the ?expression and !fullfetch commands.

Example: Export the Results of a Query

How to export the results table of a query for use in other applications.

Example: Refer to a Table within a Data Source

Within a query, how to refer to a table that is in a data source.

Example: Switching between Manifold and Native Query Engines

How to use the !manifold and !native commands to switch a query in the Command window from use the Manifold query engine to whatever query engine is provided by a data source.

Example: Automatically Generating CREATE Queries

How to use the Command window to automatically generate SQL in the form of CREATE queries that create a desired component.

SQL Example: Miscellaneous SQL Functions

A variety of small examples using SQL functions.

SQL Example: Create Lines from a Table of Points

A classic task in GIS is to rebuild objects from data in file formats, such as CSV, which decompose GIS objects like lines or areas into individual points.  In this example we recover the original lines from a table of points that has been imported from a CSV file.   The points mark the positions of coordinates (vertices) that originally represented lines marking the boundaries of ice shelves in Antarctica.  Each point has a field giving the line of which it was a part, and also a field giving the order of the point within that line.   We use SQL and Manifold SQL functions to build lines from that table, automatically grouping points from each line in the correct order to reconstruct each line.

SQL Example: GeomOverlayAdjacent Function

Using the GeomOverlayAdjacent function, an example that shows how this function and similar functions such as GeomOverlayContained, GeomOverlayContaining, GeomOverlayIntersecting and GeomOverlayTouching operate.

SQL Example: GeomOverlayTopologyUnion Function

A continuation of the SQL Example: GeomOverlayAdjacent Function example, using the GeomOverlayTopologyUnion function, an example that shows how this function and similar functions such as GeomOverlayTopologyIdentity, GeomOverlayTopologyIntersect and GeomOverlayTopologyUpdate operate.

SQL Example: Extract Airport Runways from an OpenStreetMap PBF

We write a simple SQL query using INNER JOIN to extract runway lines from an OpenStreetMap PBF of Cyprus, and to save those lines to a new drawing and table.

SQL Example: Compute Area of an NDVI Interval

We use a small query to calculate the total area covered by pixels within a given NDVI interval range in an NDVI raster image.  For example, if our NDVI intervals have an interval colored in a shade of brown that indicate regions without foliage, we can calculate the total area covered by such regions.   If we made such calculations for the same region, perhaps by computing NDVI rasters for different years in which NAIP images were acquired, we could quickly see if regions without foliage were increasing or decreasing in area.