0

I have a shapefile with a whole lot of regions on it. I need to find the centroids for each of these regions in the shapefile (as latlons) and export this as a .csv

I have done extensive research, but no luck yet.

So far: I select the layer. I go to "Vector/Geometry Tools/Polygon centroids". hurrah, the centroids show up. BUT they are not yet added to my layer as lat lons. (although the info must be there because they are, you know, located.)

To get the lat lons added to my layer I go "Vector/Geometry Tools/ExportAdd Geometry Columns" BUT THEN when I look in my attribute table for this layer, some of the column headings have been changed (weird!) :(( The good news is that there ARE the lat lons added.

To be more descriptive:

  • The first 16 column headings remain unchanged. That's good.
  • The 17th gets truncated from SA1_testData_SA1_AREA_SQM to SA1_testDa
  • The 18th column gets changed from SA1_testData_SA1_Dwellings to SA1_test_1
  • The 19th, 20th etc columns keep incrementing by one: SA1_test_2, SA1_test_3, SA1_test_4, etc
  • And then right at the end, the last 2 columns are XCOORD and YCOORD with the lat lons in them.

Yes, I have tried both "adding to this shapefile" AND also "saving as a new shapefile"... same outcome. Why do the column headings get scrambled?

  • 1
    What software are you using? This sort of sounds like QGIS. I'd make the polygon geographical (Save As then select a geographic coordinate system like WGS84) to get geographic centroids. Fields are truncated in shapefiles due to a file limitation, there is no way to get around it. – Michael Stimson Mar 14 '16 at 4:56
  • Yes Whoops! sorry 'bout dat: I'm on QGIS 2.6.1 Windows 7 – sixD Mar 14 '16 at 5:04
  • Does gis.stackexchange.com/questions/8844/… help? After the layer is in a geographic coordinate system. – Michael Stimson Mar 14 '16 at 5:08
  • hmmmmm... thanks, i DID look at that post, but thats about getting all the points, i just want the lat lons of the centroids only.... – sixD Mar 14 '16 at 5:12
  • 1
    Can you calculate the Centroids in the field calculator before exporting? As detailed in these answers - gis.stackexchange.com/questions/45243/… – kes Mar 14 '16 at 11:20
0

The answer is that you seem have to need your column headers to have <10 characters before doing the operation. I used Table Manger Plugin to rename the headers with shorter descriptions for each column and then the headers in the table don't get scrambled. Who knew?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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