Ask Your Question

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

asked 2014-09-26 06:52:24 -0500

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 08:48:44 -0500 )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 14:46:26 -0500 )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 04:07:37 -0500 )edit

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

Melanie gravatar imageMelanie ( 2014-10-08 04:40:15 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2014-10-13 08:20:08 -0500

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 06:52:24 -0500

Seen: 579 times

Last updated: Oct 13 '14