Plotting linesegments with Pysal in a map
<p>I am using Pysal to visualize geospatial data. I want to plot segments between individuals (network) but I don't know how to plot my list of LineSegment shapes (lc). So how can I display those LineSegment in my map ?
(Below, the plotting code)</p>

<pre><code>data_table = ps.pdio.read_files("cartes/departements/DEPARTEMENT.shp")
dt = data_table[data_table.apply(lambda x:x["CODE_DEPT"][0:2] in ["75","92","93","94"],axis=1)]["geometry"]
bbox = [min([i.bbox[0] for i in dt]),min([i.bbox[1] for i in dt]),max([i.bbox[2] for i in dt]),max([i.bbox[3] for i in dt])]
fig = figure(figsize=(15,12))
base = maps.map_poly_shp(dt,bbox=bbox)
base.set_facecolor("#e1e1e1")
base.set_linewidth(0.5)
base.set_edgecolor('black')

pts_r = scatter([i[0] for i in data],[i[0] for i in data],s=10,alpha=0.5)
pts_r.set_color('red')

lc = [LineSegment(i[0],i[1]) for i in lines]

ax = maps.setup_ax([base,pts_i], [bbox,bbox])
fig.add_axes(ax)
</code></pre>

<p>Thanks !</p>

<h2>Solved</h2>

<p>I didn't use correctly the pysal plotting framework. The only thing needed was to use the LineCollection(l,alpha=0.1) method, and then add it to the setup_ax.</p>

<pre><code>from pysal.contrib.viz import mapping as maps

data_table = ps.pdio.read_files("cartes/departements/DEPARTEMENT.shp")
dt = data_table[data_table.apply(lambda x:x["CODE_DEPT"][0:2] in ["75","92","93","94"],axis=1)]["geometry"]
bbox = [min([i.bbox[0] for i in dt]),min([i.bbox[1] for i in dt]),max([i.bbox[2] for i in dt]),max([i.bbox[3] for i in dt])]
fig = figure(figsize=(15,12))

base = maps.map_poly_shp(dt,bbox=bbox)
base.set_facecolor("#e1e1e1")
base.set_linewidth(0.5)
base.set_edgecolor('black')

pts_r = scatter([i[0] for i in data],[i[1] for i in data],s=10,alpha=0.5)
pts_r.set_color('red')

lc = maps.LineCollection(lines,alpha=0.1)

ax = maps.setup_ax([base,pts_i,lc], [bbox,bbox,bbox])

fig.add_axes(ax)
</code></pre>

python networking gis pysal