I add my own road vector data on top of Google map using open layers plugin with QGIS. The vector layer is generated using PostgreSQL DB.
Is there any way to extract co-ordinates of a road segment ?
|
|
|
The easiest solution is to select the road segment(s) on the map or in attribute table and copy-paste (Ctrl-C - Ctrl-V) them into a text editor. You'll get the WKT string of the geometry with all its node coordinates. If you want to export the whole layer, an easy solution is to use "Save as ..." to CSV and specify OGR creation option "GEOMETRY=AS_XYZ" or "GEOMETRY=AS_XY". The OGR creation option is important. If it is not specified only the attribute table is exported. |
||||
|
|
|
Yes, in three stages. Firstly, select the lines (or features) of interest and save the selection as a shapefile. Then load the shapefile and go Vector -> Geometry Tools -> Extract nodes. Then load the 'nodes' shapefile layer and add the coordinates for the points to the shapefile's attribute table, Vector -> Geometry Tools -> Export/Add geometry columns. There must be a simpler way. Nick. |
||||
|
|
|
In fact, it is very easy in the Python console
|
|||
|
|
|
Sure and there are multiple ways. The most coarse is to just hover over the segment and read the coordinates, but that's not exact at all. You can use the Split Feature plugin to split multilinestrings into linestrings and then clicking on the segment with the identify tool to get the coordinates of the start and end point (in the (derived) section). If for some reason you want the segment centers, you could use Polygon Centroids from the vector menu. Alternatively you could do it with PostGIS (ST_Dump, ST_StartPoint, ST_EndPoint), since you already have the data in there. |
|||
|
|
|
Another way would be to save your line to a shapefile in qgis and then save the shapefile as a kml file. That will give you all your coordinates. After that you might want to remove the kml header and have line of coords arranged into columns (to turn it into a csv file), with a simple bash script. NOTE: You will need to open your kml with a text editor and make a newline after the word ' kml_to_csv:
Where: The kml file is named 'test-track', you will need to edit the script with your own file name or rename your file 'test-track.kml' for the script to work. |
|||||||||||||||
|