Ask Your Question
1

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 

g=nx.read_shp(r‘D:\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

edit retag flag offensive close merge delete

Comments

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
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 ( 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
0

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

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.

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

Stats

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

Seen: 806 times

Last updated: Oct 13 '14