Beispiel #1
0
    def saveh5(self):
        """ save Ezone in hdf5 format

        Parameters
        ----------

        _fileh5

        """
        _fileh5 = self.prefix+'.h5'
        fileh5 = pyu.getlong(_fileh5,os.path.join('gis','h5'))
        # if file exists open it in append mode
        f = h5py.File(fileh5,'a')

        # create missing groups
        # extent
        # dem
        if u'dem' not in f.keys():
            dem = f.create_group(u'dem')
        else:
            dem = f[u'dem']

        if hasattr(self,'extent'):
            if 'extent' not in f:
                f['extent'] = self.extent
        if u'bldg' not in f.keys():
            bldg = f.create_group(u'bldg')
        else:
            bldg=f[u'bldg']

        if hasattr(self,'hgts'):
            if u'srtm' not in dem:
                srtm  = dem.create_group(u'srtm')
            else:
                srtm = dem[u'srtm']

            if u'hgts' not in srtm:
                srtm.create_dataset('hgts',shape=self.hgts.shape,data=self.hgts)

        if hasattr(self,'lcvs'):
            if 'lcvs' not in srtm:
                srtm.create_dataset('lcvs',shape=self.lcvs.shape,data=self.lcvs)

        if hasattr(self,'hgta'):
            if u'aster' not in dem:
                aster = dem.create_group(u'aster')
            else:
                aster = dem[u'aster']

            if 'hgta' not in aster:
                aster.create_dataset('hgta',shape=self.hgta.shape,data=self.hgta)

        if hasattr(self,'dbldg'):
            # iterating on subtiles
            for k in self.dbldg:
                # if subtile does not exist create it
                if k not in bldg:
                    bldg.create_group(k)
                bldg[k]['info'] = np.array(self.dbldg[k][0])
                bldg[k]['poly'] = self.dbldg[k][1]

        f.close()
Beispiel #2
0
    def saveh5(self):
        """ save Ezone in hdf5 format

        Parameters
        ----------

        _fileh5

        """
        _fileh5 = self.prefix+'.h5'
        fileh5 = pyu.getlong(_fileh5,os.path.join('gis','h5'))
        # if file exists open it in append mode
        f = h5py.File(fileh5,'a')

        # create missing groups
        # extent
        # dem
        if u'dem' not in f.keys():
            dem = f.create_group(u'dem')
        else:
            dem = f[u'dem']

        if hasattr(self,'extent'):
            if 'extent' not in f:
                f['extent'] = self.extent
        if u'bldg' not in f.keys():
            bldg = f.create_group(u'bldg')
        else:
            bldg=f[u'bldg']

        if hasattr(self,'hgts'):
            if u'srtm' not in dem:
                srtm  = dem.create_group(u'srtm')
            else:
                srtm = dem[u'srtm']

            if u'hgts' not in srtm:
                srtm.create_dataset('hgts',shape=self.hgts.shape,data=self.hgts)

        if hasattr(self,'lcvs'):
            if 'lcvs' not in srtm:
                srtm.create_dataset('lcvs',shape=self.lcvs.shape,data=self.lcvs)

        if hasattr(self,'hgta'):
            if u'aster' not in dem:
                aster = dem.create_group(u'aster')
            else:
                aster = dem[u'aster']

            if 'hgta' not in aster:
                aster.create_dataset('hgta',shape=self.hgta.shape,data=self.hgta)

        if hasattr(self,'dbldg'):
            # iterating on subtiles
            for k in self.dbldg:
                # if subtile does not exist create it
                if k not in bldg:
                    bldg.create_group(k)
                bldg[k]['info'] = np.array(self.dbldg[k][0])
                bldg[k]['poly'] = self.dbldg[k][1]

        f.close()