Contents Menu Expand Light mode Dark mode Skip to content
  • Product
    • Editions
      • CrateDB Cloud
      • CrateDB Enterprise
      • CrateDB OSS
    • Features
      • Overview
      • High cardinality
      • SQL syntax
      • Integrations
      • Security
    • Data models
      • Time-series
      • Document/JSON
      • Vector
      • Full-text
      • Spatial
      • Relational
  • Solutions
    • By use cases | Real-time
      • Industrial Analytics
      • AI operations
      • Application analytics
    • By industry
      • Manufacturing
      • Energy
      • FMCG
      • Logistics
      • Oil, Gas & Mining
      • Transportation
      • SaaS
      • Media & Entertainment
  • Resources
    • Customer stories
    • Academy
    • Asset library
    • Blog
    • Guides
    • Events
  • Developer
    • Documentation
    • Drivers and tools
    • Community
    • GitHub
    • Support
  • Pricing
  • Login
  • Get Started
    • Overview
      • Solutions and use cases
        • Time series data
          • Fundamentals
            • Generate time series data
              • Generate time series data from the command line
              • Generate time series data using Python
              • Generate time series data using Node.js
              • Generate time series data using Go
            • Normalize time series data intervals
            • Analyzing weather data
            • Analyzing device readings with metadata integration
          • Advanced analysis
          • Video tutorials
        • Industrial big data
          • Azure IoT
          • Machine Learning
          • ABB insights
          • Rauch insights
          • SPGo! insights
          • TGW insights
        • Long-term store
          • Automatic retention and expiration
        • Real-time raw-data analytics
          • Bitmovin insights
        • Machine learning
    • Getting Started
      • Video learning
      • Data modelling
        • Relational data
        • JSON data
        • Time series data
        • Geospatial data
        • Full-text data
        • Vector data
        • Primary key strategies
      • Query capabilities
        • Aggregations
        • Ad-hoc queries
        • Search
        • AI integration
        • Performance
      • Import data
      • Sample applications

    Build

    • Load data into CrateDB
      • Load and Export (ETL)
      • Change Data Capture (CDC)
      • Metrics, telemetry, and logs
    • Connect / Drivers
      • General information
      • Applications
      • Software Testing
      • C#
      • Elixir
      • Erlang
        • Erlang ODBC
        • Erlang epgsql
      • F#
      • Go
        • pgx
        • pq
        • KSQL
      • Groovy
      • Java
        • PostgreSQL JDBC
        • CrateDB JDBC
        • Hibernate / JPA
        • jOOQ
        • Software testing
      • JavaScript
        • node-postgres
        • node-crate
      • Julia
      • Kotlin
      • Perl
      • PHP
        • AMPHP PostgreSQL
        • PostgreSQL PDO
        • CrateDB PDO
        • CrateDB DBAL
      • Python
        • crate-python
        • sqlalchemy-cratedb
        • Conecta
        • cratedb-async
        • micropython-cratedb
        • psycopg2
        • psycopg3
        • aiopg
        • asyncpg
        • ConnectorX
        • Records
        • turbodbc
      • R
      • Ruby
      • Rust
      • Scala
      • ODBC
        • C#
        • Erlang
        • Python
        • Visual Basic
      • Visual Basic
      • Zig
      • Natural language
    • Integrations
      • Categories
        • Business Intelligence
        • Data Lineage
        • Data Visualization
        • Programming Frameworks
        • Migrations
          • Rockset
            • Migrate Queries
      • Airflow / Astronomer
        • Getting started
        • Import Parquet files
        • Import stock market data
        • Export to S3
        • Data retention policy
        • Hot/cold data retention
      • AMQP
        • Usage
      • Arrow
        • Import Parquet files
      • Atlan
      • AWS Lambda
      • Azure Functions
        • Tutorial
      • Balena
        • Usage
      • Cluvio
        • Usage
      • collectd
        • Usage with collectd
        • Usage with Telegraf
      • Conecta
      • Coreflux
        • Usage
      • Dapr
        • Usage
      • Dask
        • Usage
      • Databricks
        • Azure Databricks
      • DataGrip
      • Datashader
      • DBeaver
      • dbt
        • Usage
      • Debezium
        • Tutorial
      • Django
        • Settings
        • Models
        • Fields
        • Scalar functions
      • dlt
        • Usage
      • DMS (AWS Database Migration Service)
      • DynamoDB
      • Estuary
      • Explo
      • Flink
      • Gradio
      • Grafana
        • Tutorial
      • HiveMQ
        • Usage
      • Hop
      • Iceberg
      • InfluxDB
        • Usage
        • Cloud to Cloud
        • Data Model
      • ingestr
      • JMeter
      • Kafka
        • Using Kafka with Python
        • Using Confluent Kafka Connect
      • Kestra
        • Usage
      • Kinesis
      • LangChain
        • Usage
      • LlamaIndex
        • Text-to-SQL synopsis
        • Text-to-SQL usage
      • Locust
        • Tutorial
      • Marquez
        • Usage
      • Model Context Protocol (MCP)
        • CrateDB MCP Server
        • Community servers
      • Meltano
      • Metabase
        • Usage
      • MindsDB
      • MLflow
      • MongoDB
        • Usage
        • Cloud to Cloud
        • MongoDB’s data model
      • Mosquitto
        • Usage
      • MQTT
      • MySQL and MariaDB
        • Usage
        • Use CSV
      • n8n
      • NiFi
        • Usage
      • Node-RED
        • Tutorial
      • OpenTelemetry
        • Collector Usage
        • Telegraf Usage
      • Oracle
        • Usage
      • pandas
        • Starter tutorial
        • Jupyter tutorial
        • Efficient ingest
      • Plotly and Dash
      • Polars
      • PostgreSQL
        • Usage
      • Power BI
        • Power BI Desktop
        • Power BI Service
      • Prefect
        • Usage
      • Prometheus
        • Usage
      • PyCaret
      • PyViz
      • QueryZen
      • R
        • Tutorial
      • Rill
        • Usage
      • RisingWave
        • Stream processing from Iceberg tables to CrateDB using RisingWave
      • rsyslog
        • Usage
      • scikit-learn
      • Spark
        • Usage
      • SQL Server
      • StatsD
        • Usage
      • Streamlit
      • StreamSets
        • Usage
      • Superset / Preset
        • Usage
        • Sandbox
      • Tableau
      • Telegraf
        • Usage
      • TensorFlow
        • Tutorial
      • Terraform
        • Usage
      • Trino
        • Usage
    • All Features
      • Highlights
      • SQL
      • Document Store
        • Tutorial
      • Relational / JOINs
      • Search: FTS, Geo, Vector, Hybrid
        • Full-Text Search
          • Full-text Search Options
          • Analyzers, Tokenizers, and Filters
          • Tutorial
          • Indexing Text for Both Effective Search and Accurate Analysis
        • Geospatial Search
        • Vector Search
        • Hybrid Search
      • BLOB Store
      • Clustering
      • Snapshots
      • Cloud Native
      • Storage Layer
        • Indexing and storage in CrateDB
      • Hybrid Index
      • Advanced Querying
        • Recurrent queries
      • Generated Columns
      • Server-Side Cursors
      • Foreign data wrappers
      • User-Defined Functions
      • Cross-Cluster Replication
        • Usage

    Operations

    • Installation
      • Debian, Ubuntu
      • Red Hat, SUSE
      • Windows
      • Tarball
      • Container setup
        • Docker
        • Kubernetes
          • CrateDB and Kubernetes
          • Run CrateDB with Kubernetes Operator
      • Cloud hosting
        • Amazon AWS
          • CrateDB on Amazon EC2
          • Deploy using Terraform
          • Using Amazon S3 as a snapshot repository
        • Microsoft Azure
          • CrateDB on Azure VMs
          • Deploy using Terraform
      • Configuration settings
      • Multi-node setup
      • Multi-zone setup
    • Administration
      • Bootstrap checks
      • User management
      • Going into production
      • Monitoring and diagnostics
        • Prometheus and Grafana
        • Prometheus JMX Exporter
        • Prometheus SQL Exporter
      • Memory configuration
      • Circuit breaker
      • Troubleshooting
        • System Tables
        • CrateDB Flight Recorder (CFR)
        • Java Flight Recorder (JFR)
        • The jcmd Utility
          • Using jcmd with CrateDB on Docker
          • Java Flight Recorder (JFR)
        • The crate-node command
      • Scaling
        • Expand
        • On-Demand
        • Autoscale
        • On Kubernetes
      • Upgrading
        • Guidelines
        • Rolling Upgrade
        • Full Restart Upgrade
    • Performance guides
      • Sharding and partitioning 101
      • Sharding recommendations
      • Scaling
      • Storage
      • Fast Inserts
        • Insert Methods
        • Bulk Inserts
        • Parallel Inserts
        • Configuration Tuning for Inserts
        • Testing Insert Performance
      • Fast Selects
      • Query Optimization 101

    References

  • CrateDB Cloud
    • CrateDB
      • Tools

      • Admin UI
        • CrateDB CLI
          • Cloud CLI
            • CrateDB MCP
            • CrateDB Toolkit
            • Support
            • Community

            Geospatial Search¶

            CrateDB supports location data for efficiently storing and querying geographic and spatial/geospatial data.

            Overview

            CrateDB can be used as a database to conduct geospatial search operations building upon the Prefix Tree and BKD-tree index structures of Apache Lucene.

            About

            Using spatial search, you can:

            • Index points or other shapes.

            • Filter search results by a bounding box, circle, donut, or other shape.

            • Sort or boost scoring by distance between points, or relative area between rectangles.

            Details

            CrateDB’s GEO_POINT and GEO_SHAPE geographic data types represent points or shapes in a 2D world.

            GEO_POINT:

            A geographic data type used to store latitude and longitude coordinates.

            GEO_SHAPE:

            A geographic data type used to store 2D shapes defined as GeoJSON geometry objects. It supports Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, and GeometryCollection.

            When inserting spatial data, you can use GeoJSON or WKT formats.

            • Geographic points can be inserted as a double precision array with longitude and latitude values, or by using a WKT string.

            • Geographic shapes can be inserted as GeoJSON object literal or parameter as seen above and as WKT string.

            Reference Manual

            • Geometric points

            • Geometric shapes

            • Geo search

            • distance()

            • within()

            • intersects()

            • latitude() and longitude()

            • geohash()

            • area()

            SQLAlchemy

            • Geopoint and Geoshape types

            • Working with geospatial types

            Related

            • SQL

            • Full-Text Search

            • Vector Search

            • Hybrid Search

            • Advanced Querying

            SQL Geospatial GeoJSON WKT

            About Lucene

            CrateDB uses Lucene as a storage layer, so it inherits the implementation and concepts of Lucene, in the same spirit like Solr and Elasticsearch.

            • Geospatial Indexing & Search at Scale with Lucene

            • Geospatial Indexing with Apache Lucene and OpenSearch

            • Apache Solr Spatial Search

            While Elasticsearch uses a query DSL based on JSON, in CrateDB, you can work with geospatial data using SQL.

            Synopsis¶

            Select data points by distance.

            /**
             * Based on the location of the International Space Station,
             * this query returns the 10 closest capital cities from
             * the last known position.
            **/
            
            SELECT
              city AS "City Name",
              country AS "Country",
              DISTANCE(i.position, c.location)::LONG / 1000
                AS "Distance [km]"
            FROM demo.iss i
            CROSS JOIN demo.world_cities c
            WHERE capital = 'primary'
              AND ts = (SELECT MAX(ts) FROM demo.iss)
            ORDER BY 3 ASC
            LIMIT 10;
            

            Usage¶

            Using geographic search in CrateDB.

            Index Structure Type

            Computations on very complex polygons and geometry collections are exact but very expensive. To provide fast queries even on complex shapes, CrateDB uses a different approach to store, analyze and query geo shapes. The available geo shape indexing strategies are based on two primary data structures: Prefix and BKD trees, which are described below.

            There are three geographic index types: geohash (default), quadtree, and bkdtree, described in more detail at Geo shape index structure.

            Column Definition

            Learn how to define a GEO_SHAPE column, and how to adjust parameters of the index structure in the documentation section about Geo shape column definition.

            MATCH predicate

            CrateDB’s MATCH predicate for geographical search can be used to query geographic indices for relations between geographical shapes and points. It supports the intersects, disjoint, and within operations.

            Learn¶

            Learn how to use CrateDB’s geospatial data types through ORM adapters, tutorials, or example applications.

            Articles

            • Geometric Shapes Indexing with BKD-trees

            Applications

            • Spatial data demo application using CrateDB and the Express framework

            • Plane Spotting with Software Defined Radio (SDN), CrateDB and Node.js

            Tutorials

            • Geospatial Queries with CrateDB

            • Berlin and Geo Shapes in CrateDB

            Videos

            Getting Started with Geospatial Data in CrateDB

            Discover how to effortlessly create a table and seamlessly import weather data into CrateDB in this video. Witness the power of CrateDB’s time series query capabilities in action with a weather dataset, showcasing the dynamic schema flexibility.

            CrateDB: Querying Multi-Model Heterogeneous Time Series Data with SQL

            Dive deeper into CrateDB’s multi-modal features with demonstrations on handling JSON, geospatial data, and conducting full-text searches.

             

            Fundamentals
            Geospatial Data SQL

            Let’s Go Plane Spotting with Software Defined Radio, CrateDB and Node.js!

            Did you know that passing aircraft can be a rich source of real time data? This talk will teach you how to receive and make sense of messages from aircraft in real time using an ADS-B receiver / software defined radio.

            You’ll see how to decode the messages, store them in a CrateDB database, and make sense of them. Finally, the talk demonstrates a system that alerts you when specific types of aircraft are passing by so you can run outside and see that 747 go past.

            The hardware involved is a Raspberry Pi, a Radarbox flight stick, and a flip dot sign. The software is written in JavaScript and runs on Node.js.

             

            Fundamentals
            Geospatial Data SQL

            Testimonials

            • GolfNow chooses CrateDB for location analytics and commerce.

            • Spatially Health chooses CrateDB for location analytics.

            See also

            Product: Multi-model Database • Geospatial Database • Geospatial Data Model • Dynamic Database Schemas • Nested Data Structure • Relational Database

            Next
            Vector Search
            Previous
            Indexing Text for Both Effective Search and Accurate Analysis
              Feedback

              Suggest improvement

              Edit page

              View page source

            On this page
            • Geospatial Search
              • Synopsis
              • Usage
              • Learn
            • Imprint
            • Contact
            • Legal
            Follow us
            Follow us on X Follow us on LinkedIn Follow us on Facebook Follow us on Instagram Follow us on Facebook