A newer version of this documentation is available.

View Latest

Querying Using Spatial Views

Spatial views support a variety of different use cases including multidimensional analysis, geographical data, and a combination of both. When analyzing multidimensional data, spatial views can operate on numeric data and map categories to numbers.

Spatial views support the GeoJSON format and allow bounding-box queries on complex geometries that are represented as points, line-strings, or polygons. Geospatial views also index arrays supporting flat, multidimensional arrays of min-max coordinates, and combination of arrays and GeoJSON objects.

For example, the following spatial view written in JavaScript emits GeoJSON within an array combined with document attributes.

    function (doc)
    {
     if( typeof doc.geo != ‘undefined’ and typeof doc.updated != ‘undefined’ )
     {
      var geojson = {};
      geojson.type = "Point";
      geojson.coordinates = [doc.geo.lon, doc.geo.lat];

      var date = Date.parse(doc.updated)/1000;

      //By convention, the GeoJSON object must be the first element
      emit([geojson, date], doc.name);
     }
    }