Take the 2-minute tour ×
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 am a beginner with Quantum GIS and with no previous experience or expertise in Geography or GIS. I have an ESRI shapefile of New Zealand census area units (CAUs). My goal is to obtain distances between a selected CAU within the CBD of Auckland city and centroids of surrounding CAUs. There appears to be something wrong with linkage between the displayed map and the attribute table. When I select a CAU, the highlighted one in the attribute table is clearly not the CAU in question. For example, I clicked on a CAU in downtown central Auckland city and the highlighted CAU is a rural CAU about 150 kms away. I tried creating a distance matrix; while some of the computed distances were plausible others were clearly wrong.

I thought that you would want me to attach the files but don't see any such facility on this web page.


Thank you for your replies.

To address some points raised, firstly in the attribute table I don’t see a ‘show selected only’ option, but there is a ‘move selection to top’ option. Secondly yes I was using one of the selection tools - the ‘select features by polygon’ one. Thirdly I realise that what I have is polygons and that only distances between points of the polygons can be measured. The distance matrix was being calculated on centroids.

There are two ways to select the area I am interested in. (i) Go to View menu > select > select features by polygon. Then go to Layer menu > save selection as vector file. Change shapefiles by using ‘remove layer’ / add layer’ functions. With selected area now loaded, go to Vector menu > Geometry tools > Polygon Centroids > create centroids file. Add new layer to the TOC. Then Vector menu > analysis tools > distance matrix. (ii) Since I already knew which CAUs I wanted to calculate distances for, the alternative was to edit the (whole country) DBF file in a spreadsheet, deleting all but the Auckland region.

If the choice is (i), then the selected area looks right in the map, but the areas in the attribute table are wrong. If the choice is (ii), then the attribute table is correct, but the areas depicted in the map are discrete or discontinuous parts of the whole country, instead of the Auckland region.

I presume by ‘manually selecting the layer’ you mean clicking on (highlighting) the correct layer in the layer panel of the GUI (which the User Guide calls the map legend).

I removed polygon layer, retaining the centroids layer, and performed multiparts to singleparts conversion. The feature count was the same.

If you need to know, coordinate reference system is set as NZGD2000/New Zealand Transverse Mercator 2000.

So after addressing all the above points I still don't have a resolution.

BM

share|improve this question
    
in the left corner of the attribute table, there is a "Show Selected only" option..enable it and try if the same thing happens.. –  vinayan Apr 19 '12 at 4:31
    
Barry, did you intend to post this as a new question? It looks like a response to another comment, and would be more appropriate in that thread. If you have a specific question, it would be helpful to restate in the form of a question. –  Get Spatial Apr 19 '12 at 23:04
    
Sorry, I you are right it is meant to be an addition to an existing thread, but I didn't see how to add to it. I saw an "add comment" panel, but it wouldn't take all the text (as above) so the only thing I could think of was to post a new question. I didn't see a "response" panel - what is it I am not understanding? –  Barry Martin Apr 20 '12 at 1:50
    
One way to handle it would be to edit your original question, or answer if you posted one, and reformat what is above here, to provide more context. The other option would be to split what is above into two parts and add it as two separate comments. Then, I would come back and delete this question. Hope that helps. –  Get Spatial Apr 20 '12 at 6:40
    
Do NOT tamper with the DBF file! If you delete rows from there, everything gets screwed up. The order of rows in the DBF file is essential to linking feature geometry and attributes. –  underdark Apr 20 '12 at 10:29
add comment

1 Answer

Vinayan's suggestion is a good check to see what's going on because QGIS highlights the first row in green and it can look like it is your selection, when it isn't. However, the computation of search distances suggests it is more than a simple misunderstanding going on here. I don't think this is a bug in QGIS, as I have always found it to be reliable in this regard and this function has been around and stable for a long time.

At the risk of patronising you terribly (please forgive me if I am reading too much into your self-proclaimed novice status!), but how are you selecting the features? You say you are clicking on them. Are you using one of the selection tools or does your cursor have a little 'i' next to it? That is the 'identify' tool and doesn't select a feature. Whatever selection you had previously will remain (for instance if you highlighted something in the attribute table). Expand the toolbar with the Identify icon on it and choose one of the selection tools (I am really sorry if I have just insulted your intelligence!) .

The next thing that raised a warning flag for me was your statement that you were computing a distance matrix for your CAUs. The distance matrix tool is for points only and your CAUs are presumably polygons, so what are you actually measuring here? See here for more discussion on the distance matrix tool.

Assuming you have some point representation of your CAUs, remember that tools in QGIS do not automatically identify any layers you have selected in the layer-list. You must always make sure to manually select the layer(s) you want to work on before running the tool. I know that sounds obvious but this is a little 'gotcha' that can easily trip even experienced people up if you are in a hurry.

After that, if you are still not getting the right results, I would next check to see if your features are not multiparts (Vector->Geometry Tools->Multipart to singleparts). You could well get erroneous distances and apparently incorrect selections if some of your CAU's are aggregated into a multipart feature. You can see if there were multiparts because your new layer should have more features than the original one. If the feature count is the same then there were no multiparts.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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