Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using python to build a plug-in in Qgis. I need to extract the edges of each line feature of a vector layer to create a new point layer of all edges. Someone can help me? My data input is a vector line shapefile that represent the roads of a city.

Thanks, Raffaele

share|improve this question

closed as unclear what you're asking by whuber Dec 23 '13 at 16:20

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Do you mean that you want to extract the line nodes instead of edges? Do you need start and end node or all intermediate nodes? – underdark Apr 16 '12 at 10:58

If by "edges" you think start and end nodes, you may use for a line, Shapely function "boundary" ,for instance try in the QGIS 2 Python console , respect spaces between numbers in LINESTRING():

import shapely
from shapely.wkt import loads

Line=loads('LINESTRING(0 0,2 0,2 1,5 0)')


this will return:

'MULTIPOINT (0.0000000000000000 0.0000000000000000, 5.0000000000000000 0.0000000000000000)'

in order to get all nodes you could use: list(Line.coords)

it returns in my exemple:

[(0.0, 0.0), (2.0, 0.0), (2.0, 1.0), (5.0, 0.0)]

share|improve this answer

If you want just the points (nodes/vertices) then use: Vector->Geometry Tools->Extract nodes.

Alternatively, if you want the edges between nodes (i.e. the result is a data set with lines defined by no more than two nodes, the total of which combine to represent the original line), then you want the "Split Features" plugin. Go to Plugins->Fetch Plugins. Then type 'split' into the search box and you should find it (you may have to enable 3rd party repositories). Install the plugin and then you will find it here: Plugins->Split Featutres.

share|improve this answer
I need the code in Python. THANKS! – raffalba May 21 '12 at 16:25

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