First time here? Check out the FAQ!

Ask Your Question
1

Sage: How to import a graph from a shapefile into Sage?

asked 10 years ago

Melanie gravatar image

I would like to import a graph and afterwards use functions from the networkx library in the Sage Notebook. Python is totally new for me and I have not that much experience with programming. How to transfer a shapefile into Sage? I tried

import networkx as nx 

g=nx.read_shp(rD:\Useres\...\ver06_l.shp’)

That gives

ImportError: read_shp requires OGR: http://www.gdal.org/

Unfortunately, this link doesn’t help me. Thank you in advance

Preview: (hide)

Comments

Looks like this requires a special library to be loaded.

calc314 gravatar imagecalc314 ( 10 years ago )

Well, it's not clear how exactly you run Sage. Do you run it in a VM on Windows?

Dima gravatar imageDima ( 10 years ago )
1

installing gdal is not easy. You might be better off doing a conversion of shapfiles into networkx graphs in an installation of Python with gdal installed, and writing these graphs into files; and then read the latter files in Sage.

Dima gravatar imageDima ( 10 years ago )

Yes, I run it in the Oracle VM. Thanks for your answers!

Melanie gravatar imageMelanie ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 10 years ago

try https://github.com/GeospatialPython/p... to import shapefiles. At least it goes around the gdal. I don't know how to hook it up with networkx, but it's a start.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 10 years ago

Seen: 877 times

Last updated: Oct 13 '14