I'm new with GIS systems and I need to determine if a point is into a polygon, I'm using a shapefile with SRID 32717 and I have a list of points (long, lat). With QGIS I export the shapefile to a PostGIS database, and I'm using the st_contains function, this is my query:

select * from geo_data
where st_contains(geom, ST_GeomFromText('POINT(-78.480439 -0.179156)',32717))

I validate that the point is into a polygon, but the query does not return records.

You can download the shapefile from here:


1 Answer 1


epsg:32717 is a UTM projection in meters, not degrees, which covers a thin strip from Ecuador down through Peru.

You're telling it the point coordinates you have are in epsg:32717. But these seem to be longitude and latitude, consistent with Ecuador.

That parameter doesn't project data for you. You're just tagging the coordinates with that CRS. To reproject, you need to use ST_Transform(geometry, crs_id)

You should also check the geometry type for your geo_data.geom field, for example in PgAdmin3.

For example,

  • if the type is geometry(Polygon, 32717) it's in your UTM projection
  • of it's geometry(Polygon, 4326) it's in wgs84 (lat/lon)
  • if it's geometry(Polygon, 0) it's undefined. If so you'll need to set it using st_setsrid(geometry, crs_id). This can happen if you use shp2pgsql and forget to set the srid. I do this all the time :)

For the query to work, the polygon and point geometries need to be in the same crs.

If your polygons ARE in 32717 this should work

            ST_GeomFromText('POINT(-78.480439 -0.179156)',4326),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.