Tuesday 22 September 2015

PostGIS Geography data type not displaying in QGIS


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





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...