In [1]:
import sys
import os

sys.path.append(os.path.abspath('..'))
import libpysal

In [2]:
w = libpysal.weights.lat2W(5,5)

In [3]:
w.n


Out[3]:
25

In [4]:
w.pct_nonzero


Out[4]:
12.8

In [5]:
w.neighbors[0]


Out[5]:
[5, 1]

In [6]:
w.neighbors[5]


Out[6]:
[0, 10, 6]

In [7]:
libpysal.examples.available()


Out[7]:
['georgia',
 '__pycache__',
 'tests',
 'newHaven',
 'Polygon_Holes',
 'nat',
 'Polygon',
 '10740',
 'berlin',
 'rio_grande_do_sul',
 'sids2',
 'sacramento2',
 'burkitt',
 'arcgis',
 'calemp',
 'stl',
 'virginia',
 'geodanet',
 'desmith',
 'book',
 'nyc_bikes',
 'Line',
 'south',
 'snow_maps',
 'Point',
 'street_net_pts',
 'guerry',
 '__pycache__',
 'baltim',
 'networks',
 'us_income',
 'taz',
 'columbus',
 'tokyo',
 'mexico',
 '__pycache__',
 'chicago',
 'wmat',
 'juvenile',
 'clearwater']

In [8]:
libpysal.examples.explain('baltim')


Out[8]:
{'name': 'baltim',
 'description': 'Baltimore house sales prices and hedonics 1978',
 'explanation': ['* baltim.dbf: attribute data. (k=17)',
  '* baltim.shp: Point shapefile. (n=211)',
  '* baltim.shx: spatial index.',
  '* baltim.tri.k12.kwt: kernel weights using a triangular kernel with 12 nearest neighbors in KWT format.',
  '* baltim_k4.gwt: nearest neighbor weights (4nn) in GWT format.',
  '* baltim_q.gal: queen contiguity weights in GAL format.',
  '* baltimore.geojson: spatial weights in geojson format.']}

In [9]:
pth = libpysal.examples.get_path('baltim.shp')

In [10]:
pth


Out[10]:
'/home/serge/Dropbox/p/pysal/src/subpackages/libpysal/libpysal/examples/baltim/baltim.shp'

In [11]:
shp_file = libpysal.io.open(pth)

In [12]:
shapes = [shp for shp in shp_file]

In [13]:
shapes[0]


Out[13]:
(907.0, 534.0)

In [14]:
w = libpysal.io.open(libpysal.examples.get_path('baltim_q.gal')).read()

In [15]:
w.n


Out[15]:
211