# Spatial Filter giving data out of range(filtering)

Hi All,

I am querying for 0.01-mile radius with latitude and longitude, But in return, it’s giving me data which are not in radius of lat-long.

“filter”: {

“type”: “and”,

“fields”: [

{

“type”: “spatial”,

“dimension”: “coordinates”,

“bound”: {

“coords”: [

53.342429,

-6.259931

],

}

}

]

},

Its giving me 1.2 miles data also.

What is the unit for radius? Am I doing something wrong?

Can we trust Geo-Spatial Query in Druid?

Thanks,

Jitesh

When I am converting radius with lat-long to min max lat-long. I am getting the result as I expect.

“filter”: {

“type”: “and”,

“fields”: [

{

“type”: “spatial”,

“dimension”: “coordinates”,

“bound”: {

“type”: “rectangular”,

“minCoords”: [

53.339531898289835,

-6.2647739227516315

],

“maxCoords”: [

53.34532610171017,

-6.255088077248368

]

}

}

]

},

I thing something I am doing different in radius, may be the radius unit is different.

calculating min-max lat-long by radius----------

double radiusInMiles = 0.2;

double lat = 53.342429;

double lon = -6.259931;

double kmInLongitudeDegree = 111.320 * Math.cos( lat / 180.0 * Math.PI);

double deltaLat = radiusInKm / 111.1;

double deltaLong = radiusInKm / kmInLongitudeDegree;

double minLat = lat - deltaLat;

double maxLat = lat + deltaLat;

double minLong = lon - deltaLong;

double maxLong = lon + deltaLong;

53.34532610171017 -6.255088077248368 53.339531898289835 -6.2647739227516315

Hope It will help our other friends too.

Please let me know if we can do same with radius.

Thanks,

Jitesh

Anyone knows the unit of radius in spatial query ?

Hi Jitesh, the radis is in terms of difference in degrees terms of latitude and longitude.
Here is the correponding impl - https://github.com/druid-io/druid/blob/master/bytebuffer-collections/src/main/java/io/druid/collections/spatial/search/RadiusBound.java

A PR to improve this to add support for units in terms of km or miles would be awesome.