ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 13 Oct 2014 15:20:08 +0200Sage: How to import a graph from a shapefile into Sage?https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/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
Fri, 26 Sep 2014 13:52:24 +0200https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/Comment by Dima for <p>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 </p>
<pre><code>import networkx as nx
g=nx.read_shp(r‘D:\Useres\...\ver06_l.shp’)
</code></pre>
<p>That gives </p>
<pre><code>ImportError: read_shp requires OGR: http://www.gdal.org/
</code></pre>
<p>Unfortunately, this link doesn’t help me. Thank you in advance</p>
https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24314#post-id-24314Well, it's not clear how exactly you run Sage. Do you run it in a VM on Windows?Sat, 27 Sep 2014 21:46:26 +0200https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24314#post-id-24314Comment by calc314 for <p>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 </p>
<pre><code>import networkx as nx
g=nx.read_shp(r‘D:\Useres\...\ver06_l.shp’)
</code></pre>
<p>That gives </p>
<pre><code>ImportError: read_shp requires OGR: http://www.gdal.org/
</code></pre>
<p>Unfortunately, this link doesn’t help me. Thank you in advance</p>
https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24311#post-id-24311Looks like this requires a special library to be loaded.Sat, 27 Sep 2014 15:48:44 +0200https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24311#post-id-24311Comment by Dima for <p>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 </p>
<pre><code>import networkx as nx
g=nx.read_shp(r‘D:\Useres\...\ver06_l.shp’)
</code></pre>
<p>That gives </p>
<pre><code>ImportError: read_shp requires OGR: http://www.gdal.org/
</code></pre>
<p>Unfortunately, this link doesn’t help me. Thank you in advance</p>
https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24319#post-id-24319installing 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.Sun, 28 Sep 2014 11:07:37 +0200https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24319#post-id-24319Comment by Melanie for <p>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 </p>
<pre><code>import networkx as nx
g=nx.read_shp(r‘D:\Useres\...\ver06_l.shp’)
</code></pre>
<p>That gives </p>
<pre><code>ImportError: read_shp requires OGR: http://www.gdal.org/
</code></pre>
<p>Unfortunately, this link doesn’t help me. Thank you in advance</p>
https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24435#post-id-24435Yes, I run it in the Oracle VM. Thanks for your answers!Wed, 08 Oct 2014 11:40:15 +0200https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?comment=24435#post-id-24435Answer by Dima for <p>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 </p>
<pre><code>import networkx as nx
g=nx.read_shp(r‘D:\Useres\...\ver06_l.shp’)
</code></pre>
<p>That gives </p>
<pre><code>ImportError: read_shp requires OGR: http://www.gdal.org/
</code></pre>
<p>Unfortunately, this link doesn’t help me. Thank you in advance</p>
https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?answer=24475#post-id-24475try https://github.com/GeospatialPython/pyshp 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. Mon, 13 Oct 2014 15:20:08 +0200https://ask.sagemath.org/question/24300/sage-how-to-import-a-graph-from-a-shapefile-into-sage/?answer=24475#post-id-24475