def close(self): """Close the map""" libraster.Rast_close(self._fd) # update rows and cols attributes self._rows = None self._cols = None self._fd = None
def close(self): """Function to close the raster""" self.rowio.release() libraster.Rast_close(self._fd) # update rows and cols attributes self._rows = None self._cols = None self._fd = None
def close(self): if self.is_open(): self.rowio.release() libraster.Rast_close(self._fd) # update rows and cols attributes self._rows = None self._cols = None self._fd = None else: warning(_("The map is already close!"))
def close(self): """Close the map""" if self.is_open(): libraster.Rast_close(self._fd) # update rows and cols attributes self._rows = None self._cols = None self._fd = None else: warning(_("The map is already close!"))
def close(self, rm_temp_files=True): """Close the map, copy the segment files to the map. :param rm_temp_files: if True all the segments file will be removed :type rm_temp_files: bool """ if self.mode == "w" or self.mode == "rw": self.segment.flush() self.segment2map() if rm_temp_files: self.segment.close() else: self.segment.release() libraster.Rast_close(self._fd) # update rows and cols attributes self._rows = None self._cols = None self._fd = None
def close(self, rm_temp_files=True): """Close the map, copy the segment files to the map. Parameters ------------ rm_temp_files: bool If True all the segments file will be removed. """ if self.is_open(): if self.mode == "w" or self.mode == "rw": self.segment.flush() self.segment2map() if rm_temp_files: self.segment.close() else: self.segment.release() libraster.Rast_close(self._fd) # update rows and cols attributes self._rows = None self._cols = None self._fd = None else: warning(_("The map is already close!"))
def open(self, mode=None, mtype=None, overwrite=None): """Open the map, if the map already exist: determine the map type and copy the map to the segment files; else, open a new segment map. :param mode: specify if the map will be open with read, write or read/write mode ('r', 'w', 'rw') :type mode: str :param mtype: specify the map type, valid only for new maps: CELL, FCELL, DCELL :type mtype: str :param overwrite: use this flag to set the overwrite mode of existing raster maps :type overwrite: bool """ # read rows and cols from the active region self._rows = libraster.Rast_window_rows() self._cols = libraster.Rast_window_cols() self.mode = mode if mode else self.mode self.mtype = mtype if mtype else self.mtype self.overwrite = overwrite if overwrite is not None else self.overwrite if self.exist(): self.info.read() self.cats.mtype = self.mtype self.cats.read() self.hist.read() if ((self.mode == "w" or self.mode == "rw") and self.overwrite is False): str_err = _("Raster map <{0}> already exists. Use overwrite.") fatal(str_err.format(self)) # We copy the raster map content into the segments if self.mode == "rw" or self.mode == "r": self._fd = libraster.Rast_open_old(self.name, self.mapset) self._gtype = libraster.Rast_get_map_type(self._fd) self.mtype = RTYPE_STR[self._gtype] # initialize the segment, I need to determine the mtype of the # map # before to open the segment self.segment.open(self) self.map2segment() self.segment.flush() self.cats.read() self.hist.read() if self.mode == "rw": #warning(_(WARN_OVERWRITE.format(self))) # Close the file descriptor and open it as new again libraster.Rast_close(self._fd) self._fd = libraster.Rast_open_new(self.name, self._gtype) # Here we simply overwrite the existing map without content copying elif self.mode == "w": #warning(_(WARN_OVERWRITE.format(self))) self._gtype = RTYPE[self.mtype]['grass type'] self.segment.open(self) self._fd = libraster.Rast_open_new(self.name, self._gtype) else: if self.mode == "r": str_err = _("Raster map <{0}> does not exist") raise OpenError(str_err.format(self.name)) self._gtype = RTYPE[self.mtype]['grass type'] self.segment.open(self) self._fd = libraster.Rast_open_new(self.name, self._gtype)