Bug report #10335

PostGIS layers extent in QGIS vector metadata seems wrong

Added by Harrissou Santanna almost 10 years ago. Updated almost 5 years ago.

Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:18757


New Description:

Extent of PostGIS layers seems wrong in QGIS vector metadata. This affects tools like the ftools "polygon from layer extent".

Example of values (for same layer) obtained in different ways:

551495.02397676 4246118.16591276,624045.947523758 4320105.86514626

postgis db manager
551495.02398, 4246118.16591 - 624045.94752, 4320105.86515

postgis qgis metadata
xMin,yMin 551132.25,4245748.00 : xMax,yMax 624408.75,4320476.00

shapefile qgis metadata
xMin,yMin 551495.02,4246118.17 : xMax,yMax 624045.95,4320105.87

ogrinfo postgis
Extent: (551495.023977, 4246118.165913) - (624045.947524, 4320105.865146)

ogrinfo shapefile
Extent: (551495.023977, 4246118.165913) - (624045.947524, 4320105.865146)

When using "Polygon from Layer Extent" tool, you don't get the same output whether you use postgis table or shapefiles.
I have a postgis table that i save as shapefile or mapInfo tab. When i use the tool from QGIS Geoalgorithms > vector General Tools > Polygon from Layer Extent, with the aim to get only one geometry for all my rows :
- on shp or tab files, i got a bounding box that matches the extent of my data
- on the postgis table, the output is a little wider

In the attached files, the green rectangle is the one generated for shp or tab files and the red one rely to the postgis data. As you can see, it is wider than the first one.

Running QGIS 2.2, Processing 2.2.0-2 on Windows 7 (or 8), Postgresql 9.2/Postgis 2.1

polygon_extent.jpg (107 KB) Harrissou Santanna, 2014-05-23 11:52 AM

polygon_extent2.jpg (22.4 KB) Harrissou Santanna, 2014-05-23 11:52 AM


#1 Updated by Giovanni Manghi almost 10 years ago

  • Crashes QGIS or corrupts data set to No
  • Project changed from 78 to QGIS Application
  • Category deleted (61)
  • Affected QGIS version set to 2.2.0

#2 Updated by Giovanni Manghi almost 10 years ago

  • Resolution set to invalid
  • Affected QGIS version changed from 2.2.0 to master
  • Priority changed from High to Normal
  • Assignee deleted (Victor Olaya)
  • Status changed from Open to Closed
  • Category set to 44

The same happens with the "original" tool, the one in the vector menu. But anyway there is no issue as the tool does exactly what is expected.

You can see in "vector properties -> metadata" that the same vector when imported in postgis has a slightly different extent, ex:

xMin,yMin 1553648.00,4677080.50 : xMax,yMax 1772750.12,4926008.50

xMin,yMin 1554732.66,4678313.00 : xMax,yMax 1771665.41,4924775.96

#3 Updated by Harrissou Santanna almost 10 years ago

  • Status changed from Closed to Reopened

I understand what you say but you can't ignore that there's an issue somewhere. For the same data, you can't get two different extents.
And after checking, you'll see that the extent displayed by QGIS in the metadata is not the same you got in Postgis with an "select box2d(st_union(geom))". In my case, i have a table in Postgis whose extent in Postgis is
xMin,yMin 371168.64,6659251.65 : xMax,yMax 492180.20,6753998.33 (also displayed in DB Manager metadata).

When i open this table in QGIS (through DBManager), its extent displayed in "Properties > metadata" becomes
xMin,yMin 370563.56,6658778.00 : xMax,yMax 492785.28,6754472.00

When i save as shp this table, its extent is
xMin,yMin 371168.64,6659251.66 : xMax,yMax 492180.20,6753998.34, the same one I obtained in Postgis.

With "Polygon from layer Extent" on these layers, I obtain a layer that matches the information shown in Properties > metadata, that's why the geometries are different.

Reimporting the shp above into Postgis shows
xMin,yMin 371168.64,6659251.66 : xMax,yMax 492180.20,6753998.34 in DBManager.

It seems that when a postgis table is opened in QGIS, it doesn't get it's exact extent.

#4 Updated by Giovanni Manghi almost 10 years ago

  • Resolution deleted (invalid)
  • Category changed from 44 to Vectors

#5 Updated by Giovanni Manghi almost 10 years ago

  • Subject changed from Polygon from layer Extent : output doesn't match the bounding box of the postgis data to PostGIS layers extent in QGIS vector metadata seems wrong

#6 Updated by Giovanni Manghi almost 7 years ago

  • Easy fix? set to No
  • Regression? set to No

#7 Updated by Giovanni Manghi almost 5 years ago

  • Status changed from Reopened to Closed
  • Resolution set to end of life

Also available in: Atom PDF