Geovisualization Developer's Guide

$latlon_within_tile

When you use this operator in a query, it filters data to the specified tile in the specified dataset, returning the rows that match the tile and zoom level you specified.

For more information on using query functions and operators in a REST API request, see Queries. For an end-to-end description of how to create a query, see Creating a Query.

The codeblock example below filters results in the earthquake dataset, whose {DATASET_ID} is 90af668484394fa782cc103409cafe39 to lat/long pairs in the tile within the coordinates and zoom level you specify.

{
  "version": 0.3,
  "dataset": "90af668484394fa782cc103409cafe39",
  "namespace": {
    "tile_x": {
      "source": [{"$input": "tx"}]
      },
    "tile_y": {
      "source": [{"$input": "ty"}]
    },
    "zoom": {
    "source": [{"$input": "zoom"}]
    },
    "avg_magnitude": {
    "source": ["Magnitude"],
    "apply": [{"fn": "average", "type": "aggregate"}]
    },
    "px": {
    "source": ["Lon", "zoom"],
    "apply": [{"fn": "lon_to_x", "type": "transform", "params":{"tile_size": 512} }]
    },
    "py": {
      "source": ["Lat", "zoom"],
      "apply": [{"fn": "lat_to_y", "type": "transform", "params":{"tile_size": 512}}]
    },
    "latlon": {
      "source": ["Lat", "Lon"]
    }
  },
  "facets": ["px", "py", "Src"],
  "metrics": ["avg_magnitude"],
  "filters": [{
    "latlon": {
    "$latlon_within_tile": ["tile_x", "tile_y", "tile_zoom"]
    }
  }]
}

When you submit the above request, the response includes an HTTP status code and a JSON response body.

For more information on the HTTP status codes, see HTTP Status Codes.

For more information on the elements in the JSON structure in the response body, see Query.