Geovisualization Developer's Guide


This filter operator returns true if the variable that it is applied on lies inside a tile given by x and y coordinates, or within tile_buffer pixels around it.

The example below shows a query that prepares data to be used for a heat map. It receives the tile's coordinates tx and ty as parameter, as well as the zoom level zoom and the buffer tile_buffer (a request setting those parameters automatically generated by the heat map control of the Geovisualization JavaScript API). It will return values only for rows whose lat and lon values lie within the borders of the provided tile, or tile_buffer around it.

In order to achieve this, the datasets lat and lon are first translated to screen pixel coordinates py and px respectively, using the lat_to_y and lon_to_x transformation rules. Then, a tuple of those values called pixels is created. Finally, in the filtering section, it is tested whether this pixel lies within the range of the desired tile.

One row per px,py pair is generated (as these are the facets), containing the coordinates themselves plus the metric pixel_value which contains the sum of all values of the column count in all rows mapped to the same pixel.

    "px":{"apply":[{"type":"transform","fn":"lon_to_x"}], "source":["lon","zoom"]},
    "py":{"apply":[{"type":"transform","fn":"lat_to_y"}], "source":["lat","zoom"]},

For more information on using methods and operators in queries in a REST API request, see Queries.