I am working with Apache Druid 31.0.1 and I need t...
# dev
i
I am working with Apache Druid 31.0.1 and I need to apply a spatial filter using a polygon shape. Specifically, I want to filter data based on whether a point falls within a given polygon. Can anyone provide an example of how to set up and use spatial filters with polygons in Druid? I’ve read through the documentation and tried using various filter options, but I’m having trouble with the correct syntax for defining the polygon in a spatial filter. I would appreciate any examples or pointers on how to structure this in Druid 31.0.1. there is no example of using polygon in spatial filters in druid's official documentation. any help will be appreciated
k
based on https://druid.apache.org/docs/latest/querying/geo#polygon it looks like we need an
abscissa
and an
ordinate
like
Copy code
"filter": {
  "type": "spatial",
    "dimension": "spatialDim",
    "bound": {
      "type": "polygon",
      "abscissa": [
        72.071038,
        72.071038,
        16.7763,
        16.7763
      ],
      "ordinate": [
        -68.885417,
        <tel:164.9999999|164.9999999>,
        <tel:164.9999999|164.9999999>,
        -68.885417
      ]
    }
}
p
There are some additional examples here that might help @info Advisionary https://github.com/implydata/learn-druid/blob/main/notebooks/02-ingestion/12-spatial-dimensions.ipynb