Find all geometry intersecting a point

I am trying to find a way to find all the geometry that intersects a given point from PostGIS on CartoDB.com (cloud spatial db).

The closest I could reproduce this:

SELECT * FROM sf_blocks WHERE ST_Contains(the_geom, ST_GeomFromText('POINT(-122.44107 37.750066)'));

Unfortunately, these errors cause ERROR: working on mixed SRID geometries.

What is the correct syntax for selecting geometry from a table that intersects with a point? My table, sf_blocks - all polygons.

+5
source share
2 answers

The ST_GeomFromText function takes a second argument - SRID. Therefore, if your sf_blocks level is in Lon / Lat, WGS84, then the EPSG code is 4326. In this case

SELECT * 
FROM sf_blocks 
WHERE ST_Contains(
    the_geom, 
    ST_GeomFromText('POINT(-122.44107 37.750066)', 4326)
); 

. sf_blocks ( , , Lon/Lat), ST_Transform GeomFromText.

+5

st_transform SRID, . 4326 . , , , .

edit..just "the_geom" ?

+1

All Articles