[GIS] PostGIS Geography data type not displaying in QGIS

postgisqgis

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)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE test_srid.world_points
  OWNER TO postgres;


CREATE INDEX idx_world_points_geog_point
  ON test_srid.world_points
  USING gist
  (geog_point);

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

Best Answer

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.

Related Question