What is wrong with this ST_CONTAINS statement PostGIS - Find point in polygon

974 views Asked by At

I'm trying the following:

Event.where('ST_Contains(?,ST_SetSRID(location, 4326)::geography)', search_polygon::geography)

add getting the error

*** NoMethodError Exception: undefined method `geography' for

but without that (::geography) I get a message telling me to cast, what do I do?

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

1

There are 1 answers

1
Mike T On BEST ANSWER

It looks like you are trying to use ST_Contains on geography types, but that function only works on geometry types.

If you are OK with the intersects spatial relation (see DE-9IM), then use ST_Intersects(geography, geography).