I am very new to QGIS, so please bear with me.
I have a ".shp" file, which is contains a set of boundaries for suburbs of Australia. I opened it to QGIS and I would like to export it into a CSV file so that the final file would be like following.
POSTCODE, LATITUDE, LONGITUDE
When I select "Layer> Open attribute table" I can see the "postcode" column.
I had a look at a similar question here
Getting list of coordinates for points in layer using QGIS?
Which told me to simply go to "Layer> Save as" and then type "GEOMETRY=AS_XY" or "GEOMETRY=AS_XYZ" in the "Layer" section of the "OGR creation options".
I followed exactly, but the latitude and longitude values are not being returned.
5 Answers 5
I see 2 solutions: 1st you could create 2 attributes to store your lon/lat:
- select your layer
- toggle to edit mode
- open the attribute table
- open the attribute calculator (ctrl+i)
- name your column, choose the predefined geometry function $x, $y (in that dialog)
second solution (works for all gemetry types)
- select your shp layer
- save as ...
- choose txt format
- put GEOMETRY=AS_WKT in the OGR layer option
you will end up with a text file with the layer attributes and geometry as WKT
-
I just see the title of the post, so consider only the second solution :-)user14131– user141312013年01月10日 15:45:12 +00:00Commented Jan 10, 2013 at 15:45
-
These do not seem to work in version 3.03. Following the first solution, QGIS gives only null values in the new field. For the second solution, there seems to be no option for saving as .txt format.Agus camacho– Agus camacho2018年06月21日 23:15:42 +00:00Commented Jun 21, 2018 at 23:15
You're looking at the right question, just not the right answer! The reason that that worked for the answer you were looking at is that the data was only in points. Since your data is in polygons, it won't work.
BWill's answer further down is what you need. It will copy all the co-ordinates describing each polygon into WKT format, which is a standard format, although you may need to do some cleaning up depending on your purpose.
Now there is a great plugin produced by Michael Minn that does exactly what you're looking for. Just update your plugin repository and install MMQGIS. I just tried it out and it worked great.
to provide a visual guidance(applicable to QGIS version 3.10.1-A:)
- Navigate to Layer --> Save As
- On the Format dropdown, select 'comma Separated Value [CSV]'
- Provide the filename to save to
- In the lower section, expand 'Layer Options' if not expanded (scroll down if required
- Select 'AS_WKT' for 'Geometry'
- Click OK
(You may want to play around withthe many options based on your needs) Save geometry as CSV
-
In QGIS 3.40.3 you need to select Export->Save Features As.influent– influent2025年01月29日 17:25:45 +00:00Commented Jan 29 at 17:25
You could also use the MMQGIS plugin to export the geometry and the other layer attributes to a CSV file.
-
This answer seems to be near identical to your only other one at gis.stackexchange.com/a/245507/1152017年06月27日 11:19:00 +00:00Commented Jun 27, 2017 at 11:19
GEOMETRY=AS_XY
will silently fail. You can can fix this by processing the layer with 'Multipart to singleparts'