I have the following table defined, which uses PostGIS geography.
CREATE TABLE test_geog (
id SERIAL PRIMARY KEY,
boundary GEOGRAPHY(Polygon)
);
I added the following test polygon to the table:
INSERT INTO test_geog VALUES (ST_GeographyFromText('SRID=4326;POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'));
I am trying to determine whether a point lies within any of the polygons in this table. I have this query:
SELECT ST_ContainsProperly(ST_GeographyFromText('Point(2 2)'), area)
FROM (SELECT boundary FROM test_geog) AS area;
This yields the following error:
ERROR: function st_containsproperly(geography, record) does not exist
LINE 1: SELECT ST_ContainsProperly(ST_GeographyFromText('Point(2 2)'...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
How do I convert this "record" into a POLYGON? I'm confused because it seems like the column has already been declared to only hold POLYGON types, but for some reason that is not what I am pulling out of the database.
I attempted to cast the record to a POLYGON like this:
SELECT ST_ContainsProperly(ST_GeographyFromText('Point(2 2)'), CAST (nitf_area AS POLYGON))
FROM (SELECT boundary FROM source_imagery) AS nitf_area;
But that gives me this error:
ERROR: cannot cast type record to polygon
LINE 1: ...tainsProperly(ST_GeographyFromText('Point(2 2)'), CAST (nitf...
What am I not understanding here?
