Tim's transform of dentists
select * from ( | |
select the_geom as the_geom_webmercator, | |
min(ST_Distance_Sphere(st_transform(st_centroid(the_geom), 4326), st_transform(otherGeom, 4326)))/1600 as minDist | |
from ( | |
select grids.the_geom, st_collect(st_transform(timchung.allbusiness.the_geom, 3857)) as otherGeom | |
from ( | |
SELECT CDB_HexagonGrid( | |
ST_SetSRID( | |
ST_Envelope( | |
ST_Collect( | |
st_transform(the_geom, 3857) | |
) | |
), | |
3857), | |
500) as the_geom | |
from timchung.allbusiness | |
where state in ('AZ') | |
union | |
SELECT CDB_HexagonGrid( | |
ST_SetSRID( | |
ST_Envelope( | |
ST_Collect( | |
st_transform(the_geom, 3857) | |
) | |
), | |
3857), | |
500) as the_geom | |
from timchung.allbusiness | |
where state in ('NV')) as grids | |
where position('Mexican' in categories)>0 | |
and open | |
group by grids.the_geom | |
) as gridsPoints | |
group by the_geom) as allGrid | |
where minDist<7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment