I am trying to display data held in the PostGIS Geography type on a map in QGIS. Whatever I do I can't get it to work.

Here is the SQL that creates my data - a single point in London.

CREATE TABLE test_srid.world_points
  id serial NOT NULL,
  name character varying(150),
  geog_point geography(Point,4326),
  CONSTRAINT world_points_pkey PRIMARY KEY (id)
ALTER TABLE test_srid.world_points
  OWNER TO postgres;

CREATE INDEX idx_world_points_geog_point
  ON test_srid.world_points
  USING gist

INSERT INTO test_srid.world_points (name, geog_point) VALUES ('my_address', ST_GeogFromText('SRID=4326;POINT(0.1275 51.5072)') );

QGIS recognises this as a layer, but does not display any data:

I've spent a while looking through the documentation and can't find what I'm doing wrong. I'd be very grateful for any help. I have found this which seems to suggest that the geography type is supported.

Finally I've checked that the data in PostGIS is working correctly: I've created two points using code similar to the above, and run the following query:

SELECT ST_Distance(a.geog_point,b.geog_point)

from test_srid.world_points as a,
 test_srid.world_points as b

where a.id = 1 and b.id=2

The result came back as expected (I double checked against google maps).

Is there a setting I need to change to get this to work? I was initially working with QGIS Brighton, but upgraded to Wien to check it wasn't anything to do with my QGIS version.

Data in geometry datatypes displays with no issue.

QGIS screenshot

  • 1
    tested it and works for me. maybe you didn't use the template_postgis at creating your database in postgres?
    – Ms. Smith
    Apr 17 '15 at 11:22
  • Wonderful - thank you. I created a new database and it now works. I used the template1 database since the template_postgis wasn't available - see here gis.stackexchange.com/questions/26508/…. This seemed to fix the problem. In the database where I was having problems, I had accidentally failed to use any template at all - which was probably why it wasn't working.
    – RobinL
    Apr 17 '15 at 11:34
  • I am having the same problem of rendering geography, but the solution of using the template doesn't seem to work. I didn't use the template, but ensured that CREATE EXTENSION PostGIS; is run, which should be equivalent (according to gis.stackexchange.com/questions/26508/…). Any ideas?
    – amball
    Apr 18 '17 at 23:38
  • Update: this seems to be a bug in the QGIS DB Manager (hub.qgis.org/issues/12680) that causes it to not recognize geography columns. Add PostGIS layer works, but is very slow for large databases.
    – amball
    Apr 19 '17 at 0:25

I think we can assume it is a interoperability issue.

I had this same issue because I was using a old version 2.8.6 and I was wondering if it was my DB that was not well defined, not enough privileges, extensions weren't added, etc. But in fact it was much simpler than that.

Installing the newest version of QGIS will solve the problem and you'll be able to see your geography type. Unfortunately for me, I work also with ArcMap 10.4 and it doesn't support Geography type:

PostGIS has two spatial type options: geometry and geography. Only the geometry type is supported with ArcGIS (ESRI Docs).

Only on Arcmap 10.6+ it is supported.

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.