New answers tagged query
$sql = "SELECT points.name FROM polygons, points WHERE ST_CONTAINS(polygons.geom, Point(points.longitude, points.latitude)) AND polygons.name = 'California'";
If you want to test whether some points (or shapes, etc) fall within a given distance of a given location, use the geographic version of ST_DWithin(). From http://www.postgis.org/docs/ST_DWithin.html boolean ST_DWithin(geography gg1, geography gg2, double precision distance_meters, boolean use_spheroid); Thus, SELECT ST_DWithin( ST_GeomFromText( ...
Skip the trig, create view mypoints as select id, st_makepoint( st_x(st_endpoint(geom)) + (st_x(st_endpoint(geom))-st_x(st_startpoint(geom)))/2, st_y(st_endpoint(geom)) + (st_y(st_endpoint(geom))-st_y(st_startpoint(geom)))/2 ) as geom from mytable; then select geom from mypoints where id = 1; should work fine, for all values of id
Best way is to use the geographic type. geography ST_Buffer(geography g1, float radius_of_buffer_in_meters); SELECT 1 as cartodb_id, ST_Transform( ST_Buffer( ST_GeomFromText( 'POINT(-58.427185 -34.624592)' , 4326 )::geography ) , 2000 ), 3857 ) as the_geom_webmercator By casting to geography the st_buffer will work ...
Top 50 recent answers are included