I need an export of xy-coordinates of line segments in QGIS. I found an answer to a similar question here but that concerned only xy of the first and last vertex of a line segment. But I need the coordinates of all the vertexes. Can someone help?
7 Answers 7
The Geometry Export To CSV
part of the mmqgis plugin enables you to export the node coordinates into a csv file.
This page should give you some hints on how to use the plugin:
Use extract nodes. From line to points => saved in shape file. Then save the point shape file in save as vector layer window as csv. In the layer option, change the following : create csvt = yes, geometry = as xy, separator = comma. Check the extent (current layer). Supply the file name, then click OK.
A Greek way:
A) Select the feature you want, copy it and paste onto a word processor.
B) delete the first part wkt_geom...
and the parenthesis at the end so there are only numbers.
C) Replace: ,
(comma and one space) with ^p
(MS word) or \n
(Libre office-Open office).
D) replace one space with comma. You get the list of coordinates in the X,Y format.
Have a look at the following related answered questions:
- How to export Polygons to CSV with coordinates?
- Getting list of coordinates for points in layer using QGIS?
- QGIS 3x capturing coordinates for multitude of objects at once
If those don't work for you, please provide more details.
There's a tool in the open source GIS Whitebox Geospatial Analysis Tools (http://www.uoguelph.ca/~hydrogeo/Whitebox/) called 'Extract Nodes'. It does exactly what you are looking for. It takes a shapefile of polylines or polygons and returns a vector of the node points.
enter image description here
- Use the
Extract vertices
function to create a point shapefile of the vertices. The properties of the line (such as ID) will be retained for later reference - Add the xy geometry properties in any number of ways, perhaps with the Attribute Table field calculator to add attributes named xx and yy with $x and $y in the calculation, or simply the
Add X/Y fields to layer
function, or other means. - Export the points layer as a CSV format (if needed, or whatever format you want).
In fact we do not need any plugin or special function to extract vertices from linestrings or polygons. Simply create a memory point layer (see link), copy your selected features to this layer and open the attribute table to copy the vertices to the clipboard. BTW you can always set the point layer to a different CRS if you like, coordinates are transformed automatically. For more see: Programmatically extract edge points from many polygons?