Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a Postgis table that I open with QGis. My problem is related to feature Ids: they are not the same so, for example, feature with id 123 in the database is not the same geometry 123 that I can reach in QGis "Attribute Table". It seems that QGis reindex table features. Is there a way to avoid this or to reorder QGis indexes?

share|improve this question
Do you mean row 1 doesn't equal the same row 1 data in QGIS? – Nathan W Aug 1 '12 at 10:07
Exactly! And so on for the rest of the rows...QGis ignore Postgis ids (which in my case are serial integers starting from 1) and creates its own ids. – caneta Aug 1 '12 at 10:11
1  
QGIS doesn't ignore columns as far as I am aware. Never has for me. – Nathan W Aug 1 '12 at 10:42
I dont'know...in my case it does...any suggestions? – caneta Aug 1 '12 at 10:43
Can you post a pick of the QGIS attribute table, and of a sample from PostGIS. – Nathan W Aug 1 '12 at 10:47
show 1 more comment

closed as too localized by underdark Aug 1 '12 at 16:13

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

2 Answers

I discovered that querying the loaded data using "Query..." window, I get the correct features. For example, if in this window I put in "SQL where clause" field the string "id IN (12700, 11250,11824)", I get visualized the corresponding features that have those ids in Postgis database. But in "Attribute Table", these ids does not match, probably because QGis re-organizes these table with its own ids, as guessed. In other words: problem solved, I can retrieve features using database ids through QGis.

share|improve this answer
1  
are you just saying that the rows are just not ordered by id in the attribute table? Which column seems to show a different id? – jef Aug 1 '12 at 12:55
Yes, I'm saying that. Which columns? I do not understand: ids refers to rows (features), not to columns. I have just one column (identifying feature category by an integer). Every row (not column) of "Attribute Table" has a different id if compared to the database ones. – caneta Aug 1 '12 at 13:17
I meant the column, that you think shows the "qgis id". I assumed, that you are simply mistaking the row header for an id. As QGIS doesn't fetch the features in an particular order, the rows in the attribute table are just in the - rather arbitrary - order the database returned them. – jef Aug 1 '12 at 22:05
Yes, you are right: it was not clear to me that the extremely left column of Attribute Table was not the Postgis id column. But I can manage Postgis ids through QGis as I reported in my answer, even if they are not showed in Attribute Table. – caneta Aug 2 '12 at 10:17

I think your Postgis database is missing a primary key. I have filled my database with OpenStreetMap data, and the column "osm_id" (which serves as primary key) is automatically added to the attribute table in Quantum GIS. The row number in pgAdmin is something completely different, depending on sorting etc.

share|improve this answer
No, my table has a column named id, which is my primary key. Its definition follows: CREATE TABLE land_cover ( id serial NOT NULL, cat integer, the_geom geometry, CONSTRAINT land_cover_pkey PRIMARY KEY (id ), CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2), CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 900913) ) – caneta Aug 2 '12 at 10:18

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