Exemplo n.º 1
0
    def test_dense(self):
        w_rook = ps.weights.Rook.from_shapefile(
            ps.examples.get_path('lattice10x10.shp'))
        polys = ps.open(ps.examples.get_path('lattice10x10.shp'))
        centroids = [p.centroid for p in polys]
        w_db = d.DistanceBand(centroids, 1, build_sp=False)

        for k in w_db.id_order:
            np.testing.assert_equal(w_db[k], w_rook[k])
Exemplo n.º 2
0
 def test_integers(self):
     """
     see issue #126
     """
     grid_integers = [
         tuple(map(int, poly.vertices[0])) for poly in self.grid_f
     ]
     self.grid_f.seek(0)
     grid_dbw = d.DistanceBand(grid_integers, 1)
     for k, v in grid_dbw:
         self.assertEquals(v, self.grid_rook_w[k])
Exemplo n.º 3
0
 def test_arcdist(self):
     arc = ps.cg.sphere.arcdist
     kdt = KDTree(self.arc_points,
                  distance_metric='Arc',
                  radius=ps.cg.sphere.RADIUS_EARTH_KM)
     npoints = self.arc_points.shape[0]
     full = np.matrix([[
         arc(self.arc_points[i], self.arc_points[j])
         for j in xrange(npoints)
     ] for i in xrange(npoints)])
     maxdist = full.max()
     w = d.DistanceBand(kdt, maxdist, binary=False, alpha=1.0)
     np.testing.assert_allclose(w.sparse.todense(), full)
Exemplo n.º 4
0
 def test_init(self):
     w = d.DistanceBand(self.grid_kdt, 1)
     for k, v in w:
         self.assertEquals(v, self.grid_rook_w[k])