In [12]:
import binning
import pysal as ps
import time

Examining shape per bin settings: US counties


In [14]:
sf = ps.examples.get_path("nat.shp")
w = binning.bin_shapefile(sf, shapeDensity=4) # for consistency check

for density in range(1,201):
    t1 = time.time()
    wd = bin_shapefile(sf, shapeDensity = density)
    t2 = time.time()
    if wd['potential_neighbors'] != w['potential_neighbors']:
        print 'Error: ', wd
    results[density] = t2 - t1

In [15]:
density = results.keys()
seconds = results.values()
plot(density, seconds)
ylabel('Seconds')
xlabel('shape density')
title('US counties')


Out[15]:
<matplotlib.text.Text at 0x10b099150>

In [16]:
density[0:5]


Out[16]:
[1, 2, 3, 4, 5]

In [17]:
seconds[0:5]


Out[17]:
[0.5543379783630371,
 0.5879201889038086,
 0.7307839393615723,
 0.6314120292663574,
 0.5037860870361328]

Artificial Lattice 1000x10


In [18]:
sf = "1000x10.shp"
w = binning.bin_shapefile(sf, shapeDensity=4) # for consistency check

for density in range(1,101):
    t1 = time.time()
    wd = bin_shapefile(sf, shapeDensity = density)
    t2 = time.time()
    if wd['potential_neighbors'] != w['potential_neighbors']:
        print 'Error: ', wd
    results[density] = t2 - t1

In [19]:
density = results.keys()
seconds = results.values()
plot(density, seconds)
ylabel('Seconds')
xlabel('shape density')
title('Regular Lattice 1000x10')


Out[19]:
<matplotlib.text.Text at 0x10d2e0410>

In [ ]: