Ask Your Question

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

asked 2014-09-26 13:52:24 +0200

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 


That gives

ImportError: read_shp requires OGR:

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

edit retag flag offensive close merge delete


Looks like this requires a special library to be loaded.

calc314 gravatar imagecalc314 ( 2014-09-27 15:48:44 +0200 )edit

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

Dima gravatar imageDima ( 2014-09-27 21:46:26 +0200 )edit

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 ( 2014-09-28 11:07:37 +0200 )edit

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

Melanie gravatar imageMelanie ( 2014-10-08 11:40:15 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2014-10-13 15:20:08 +0200

try 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.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2014-09-26 13:52:24 +0200

Seen: 829 times

Last updated: Oct 13 '14