TransWikia.com

Exporting xy-coordinates from geodata

Geographic Information Systems Asked by NoSyu on October 3, 2020

I want to get real line segment dataset to do an experiment. So I searched it, and found the site that includes the real data: http://www.wsdot.wa.gov/mapsdata/geodatacatalog/

From this, I downloaded railroad data and opened it with QGIS. I want to get the end points of each line segment (or feature) in the data. When I click the one feature in vector layer, I can see the firstX, firstY, lastX and lastY in 'Identify Results' window. I think this information is what I needed.

However, I cannot find the way to export this information to .csv-file or text file. I searched, but all of these solutions are not working for me:

How can I export end points of each line segment in such dataset?

One Answer

A very simple solution is as follows:

  1. Open the attribute table and enable editting (yellow pencil button at the bottom of the dialog box)
  2. Click the calculate fields button (calculator icon at the bottom) and create a new field for firstX (possibly changing the output field type to decimal and setting the width and precision) and select 'xat' from the Geometry function list and change the expression to read: xat(0). This will give you the x location of the first point in your line.
  3. Repeat the above for yat(0)
  4. Repeat the above for xat(-1) to get the last x coordinate
  5. Repeat the above for yat(-1) to get the last y coordinate
  6. Save your edits
  7. Export (save as) your file to CSV

There are other approaches, but this one gives you a column for each x or y coordinate for the first and last points in your line and nothing more - which is what I understand to be your request. It also requires no coding.

Correct answer by MappaGnosis on October 3, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP