Ejemplo n.º 1
0
    def get_tile(self, itx, ity):
        assert 0 <= itx < self.ntilesx
        assert 0 <= ity < self.ntilesy

        fn = '%s.%02i.%02i.bin' % (self.base_fn, ity, itx)
        fpath = op.join(self.data_dir, fn)
        if not op.exists(fpath):
            self.download()

        with open(fpath, 'r') as f:
            data = num.fromfile(f, dtype=self.dtype)

        assert data.size == self.ntx * self.nty
        data = data.reshape((self.ntx, self.nty))

        return tile.Tile(self.xmin + itx * self.stx,
                         self.ymin + ity * self.sty, self.dx, self.dx, data)
Ejemplo n.º 2
0
    def get_tile(self, itx, ity):
        tn = self.tilename(itx, ity)
        if tn not in self.available_tilenames():
            return None
        else:
            fpath = self.tilepath(tn)
            if not op.exists(fpath):
                self.download_tile(tn)

            zipf = zipfile.ZipFile(fpath, 'r')
            rawdata = zipf.read(tn + '.hgt')
            zipf.close()
            data = num.fromstring(rawdata, dtype=self.dtype)
            assert data.size == self.ntx * self.nty
            data = data.reshape(self.nty, self.ntx)[::-1, ::]
            return tile.Tile(self.xmin + itx * self.stx,
                             self.ymin + ity * self.sty, self.dx, self.dx,
                             data)
Ejemplo n.º 3
0
    def get_tile(self, itx, ity):
        assert 0 <= itx < self.ntilesx
        assert 0 <= ity < self.ntilesy

        self.make_if_needed(itx, ity)

        fn = '%02i.%02i.bin' % (ity, itx)
        fpath = op.join(self.data_dir, fn)
        with open(fpath, 'r') as f:
            data = num.fromfile(f, dtype=self.dtype)

        if data.size == 0:
            return None

        assert data.size == self.ntx * self.nty
        data = data.reshape((self.ntx, self.nty))

        return tile.Tile(self.xmin + itx * self.stx,
                         self.ymin + ity * self.sty, self.dx, self.dx, data)