I know similar questions have been asked several times, but none of the solutions seems suitable for my problem or don't work..

I computed flowlines using the r.flow tool from GRASS GIS, then I export these using v.out.ogr which gives me the files flowlines.dbf, flowlines.prj, flowlines.shp and flowlines.shx. The image shows the figure in GRASS of my flowlines over a DEM.

enter image description here

Now I need to read this shapefile into python and reproduce that same image in python. To read the file I downloaded the shapefile module, which seems to work fine, but after that I'm lost. I was told to use fiona module by a friend but it doesnt want to install on my ubuntu machine, not sure what's the problem, so a solution without fiona would be great..

Does anyone have good advice?


1) you don't need to export a shapefile. With the Python module GDAL (osgeo) you can read directly the layer from the GRASS folders hierarchy (look at GRASS 6 terminology)

from osgeo import ogr
# open the Grass layer shape1
ds = ogr.Open('/Users/grassdata/geol/MNT/vector/shape1/head')
layer = ds.GetLayer(0)

2) If you want to read the shapefile, you can use different modules -> look at Is it possible to look at the contents of Shapefile using Python without an ArcMap license?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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