Data Lens Developer's Guide

$pixel_within_tile

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 Data Lens 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.

{
  "facets":["px","py"],
  "namespace":{
    "pixel_value":{"source":["count"],"apply":[{"type":"aggregate","fn":"sum"}]},
    "tile_buffer":{"source":[{"$input":"buffer"}]},
    "px":{"apply":[{"type":"transform","fn":"lon_to_x"}], "source":["lon","zoom"]},
    "py":{"apply":[{"type":"transform","fn":"lat_to_y"}], "source":["lat","zoom"]},
    "zoom":{"source":[{"$input":"zoom"}]},
    "pixels":{"source":["px","py"]},
    "tile_y":{"source":[{"$input":"ty"}]},
    "tile_x":{"source":[{"$input":"tx"}]}},
    "dataset":"a6e43f1d38644ca8824c271bb5ba1ee2",
    "metrics":["pixel_value"],
    "version":0.3,
    "filters":[
      {"pixels":{"$pixel_within_tile":["tile_x","tile_y","tile_buffer"]}}
    ],
    "order":[{"month":"asc"}]
}

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

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.