コード例 #1
0
ファイル: DataAccessorPy.py プロジェクト: shakenbaby216/isce2
    def createAccessor(self):
        if (not self.filename and hasattr(self, 'metadatalocation')
                and self.metadatalocation
                and not self.accessMode.lower().count('write')):
            #it will only keep going if all ok
            self.filename = self.checkLocation()
        caster = '' or self.caster
        filename = self.filename
        scheme = self.scheme
        self.extraFilename = self.filename + '.' + self._extra_reader

        if self._accessor is None:  #to avoid creating duplicates
            selection = self.methodSelector()
            if selection == 'api':
                size = DA.getTypeSize(self.dataType)
                #to optimize bip access per band we read in memory all bands and then
                #set the right band and write the content back leaving the other bands untouched
                #this requires a read and write which only works if the file is opened in
                #writeread (or readwrite) mode and not just write
                if (self.accessMode.lower() == 'write'):
                    #if(self.scheme.lower() == 'bip' and self.accessMode.lower() == 'write'):
                    self.accessMode = 'writeread'
            elif selection == self._extra_reader:
                size = self.getGDALDataTypeId(self.dataType)
                filename = self._extraFilename
                #GDALAccessor handles all the different scheme in the same way since it reads
                #always in BSQ scheme regardless of the under laying scheme
                scheme = 'GDAL'
            else:
                print('Cannot select appropruiate image API')
                raise Exception
            self._accessor, self._factory = DA.createAccessor(
                filename, self.accessMode, size, self.bands, self.width,
                scheme, caster, self._extraInfo)
        return None
コード例 #2
0
 def createAccessor(self):
     if self._accessor is None:  #to avoid to creating duplicates
         size = DA.getTypeSize(self.dataType)
         caster = '' or self.caster
         self._accessor, self._factory = DA.createAccessor(
             self.filename, self.accessMode, size, self.bands, self.width,
             self.scheme, caster)
     return None