I installed Postgres 9.5. Then I installed PostGIS. Then I created database named geodb. In it I created column with type polygon and several others like id.

Table polygon was created successfully, so it's seems that PostgreSQL know about geometry.

But when I am trying to run next query:

INSERT INTO public.rasters_previews( id, "Path", "Coordinates", "Name", "imageBounds") VALUES (1, 'foo', ST_GeomFromText('polygon((60.536 27.589,60.509 39.054,54.908 38.183,54.93 28.368,60.536 27.589))'), 'xname', 'xbound');

I am getting error that function ST_GeomFromText does not exists.

I tried to do same with setting postgis_22_sample as template but got same result.

What I am doing wrong? Should I do any other manipulation to get DB wotk as geospatial?

  • 1
    Does this work: SELECT ST_GeomFromText('polygon((60.536 27.589,60.509 39.054,54.908 38.183,54.93 28.368,60.536 27.589))'); – kttii Aug 9 '16 at 16:34
  • 2
    Datatype "polygon" is a native PostgreSQL datatype. With PostGIS you want to use "geometry", perhaps with constraint to contain only polygons. – user30184 Aug 9 '16 at 16:42
  • did you create the postgis extension in your database? You can do this by running: create extension postgis; – Hasan Mustafa Aug 10 '16 at 7:36

Is the schema PostGIS was installed into in your search path? The easiest way to test is by running the command:

SELECT PostGIS_Full_Version();

If that returns information on PostGIS you're good to go, if not find the schema you installed PostGIS into and add it to the search path. I usually install PostGIS to its own schema with:

ALTER DATABASE geodb SET search_path TO public, postgis;

Don't forget to add any other schemas in your database to the search path. If you install the topology extension it will create it's own topology schema that will need to go into the search path as well.

| improve this answer | |
  • How to find schema where PostGIS was installed? – Eugene Mala May 26 '19 at 12:32
  • 1
    SELECT specific_schema FROM information_schema.routines WHERE routine_name = 'postgis_full_version'; Running this query in the database you're trying to find postgis will tell you which schema postgis was installed into. If PostGIS isn't working then add the schema to that database's search path. – HeyOverThere May 28 '19 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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