Spatial index | Qlik Cloud Help
Skip to main content

Spatial index

Spatial index generates a spatial index for a dataset for use with the Auto select visible feature in map charts. Field selections are updated based on the data displayed in map charts. For more information, see Setting the zoom and selection behavior for maps.

Spatial index returns these fields:

  • <dataset key field>: A key field linking the values from SpatialIndex with the source field from the dataset.

  • SpatialIndex: Contains grid coordinates for the items in the key field.

  • SpatialIndexLevel<num>: Contains grid coordinates for the items in the key field for use with Auto select visible for each level. A field is created for each of the levels set in Number of levels.

  • All fields except the key field from dataset are prefixed with the dataset name.

If you have multiple spatial indexes, rename the fields created by Spatial index. For example:

[CountrySpatialindexResultTable]: Load * Extension GeoOperations.ScriptEval(' SELECT Country, SpatialIndex as CountrySpatialIndex, SpatialIndexLevel2 as CountrySpatialIndexLevel2, SpatialIndexLevel3 as CountrySpatialIndexLevel3, SpatialIndexLevel4 as CountrySpatialIndexLevel4, SpatialIndexLevel5 as CountrySpatialIndexLevel5, SpatialIndexLevel6 as CountrySpatialIndexLevel6 FROM SpatialIndex(gridSize="0.04", gridWidthHeightRatio="1.5", nLevels="6", levelFactor="4") DATASOURCE dataset INTABLE keyField="Country", crs="auto", namedPointField="Country" ', Sales);
  1. Under Data connections, click Select data on your Qlik GeoOperations connection.

  2. Under Operation, select Spatial Index.

  3. Under Operation, adjust the parameters as needed.

    • Grid size (degrees): Specifies the height (in degrees) of an individual spatial index cell at the most detailed level. An appropriate value is the side length of the map view that users commonly zoom into.

      The default value is 0.04.

    • Grid width / height ratio: Specifies the ratio that determines the shape of grid cells used for spatial indexing. The formula for the optimal width/height ratio is 1/cos(latitude), for example 1 at the equator, 1.15 at latitude ±30 deg and 2 at latitude ±60 deg.

      The default value is 1.5.

    • Number of levels: Specifies the number of spatial index levels to generate. Each level has cells with side lengths scaled by the level factor compared to the level below.

      The default value is 6.

    • Level factor: Specifies the factor by which to multiply the spatial index cell dimensions for each level.

      The default value is 4.

  4. Under Dataset 1, select the type of data source to use in the operation and its parameters.

    The data types and parameters are the same as those in the Load operation. For information on each of the dataset parameters, see:

    You must specify a key field.

  5. Under Tables, select the table to load.

  6. Under Fields, select the fields to load.

  7. Click Insert script.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!