Create a table like this, and then add it as a layer to PostGIS. It has one simple geography, a line.

SELECT ST_GeogFromText(
  'LINESTRING(-122.27172 37.80345,-122.27172 37.81549)'
) AS highway;

You can even create an index on it if you think it matters,

CREATE INDEX hwidx ON foo USING gist ( highway );

You can see the line in WKT in the table,

 LINESTRING(-122.27172 37.80345,-122.27172 37.81549)

Here is the table definition,

       Table "public.foo"
 Column  |   Type    | Modifiers 
 highway | geography | 

Yet, when I Zoom to Layer in QGIS, no joy! It just shows a blank screen. I am using QGIS 2.18.2.

1 Answer 1


Looks like (as of Jan 2017) there's no support for determining the extent of a layer with geography column types. From the source in (qgspostgresprovider.cpp):

QgsRectangle QgsPostgresProvider::extent() const
  if ( mSpatialColType == sctGeography )
    return QgsRectangle( -180.0, -90.0, 180.0, 90.0 );

So for geography types the layer extent is always the entire globe. If you cast the geography to a projected geometry (even casting to a geometry in epsg:4326 should work) it will work correctly.

You can find an open bug for this filed on 4/30/2015 here., Bug report #12677 (Open): Zoom to layer on PostGIS Table with geography type.

  • 1
    Wow, bad ass job digging through the source at the speed of God to answer this. Thanks a ton. I was thinking that was the problem, but it seemed like such an omission and then again I have like no faith in my ability to use anything that has a mouse. Jan 9, 2017 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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