Exemplo n.º 1
0
    def read(self, rast, mapset=None, mtype=None):
        """Read categories from a raster map

        The category file for raster map name in mapset is read into the
        cats structure. If there is an error reading the category file,
        a diagnostic message is printed.

        int Rast_read_cats(const char * 	name,
                           const char * 	mapset,
                           struct Categories * 	pcats
                           )
        """
        if type(rast) == str:
            mapname = rast
            if mapset is None or mtype is None:
                raise TypeError(_('Mapset and maptype must be specify'))
        else:
            mapname = rast.name
            mapset = rast.mapset
            mtype = rast.mtype

        self.mtype = mtype
        self.reset()
        err = libraster.Rast_read_cats(mapname, mapset,
                                       ctypes.byref(self._cats))
        if err == -1:
            raise GrassError("Can not read the categories.")
        # copy from C struct to list
        self._read_cats()
Exemplo n.º 2
0
    def read(self):
        """Read categories from a raster map

        The category file for raster map name in mapset is read into the
        cats structure. If there is an error reading the category file,
        a diagnostic message is printed.

        int Rast_read_cats(const char * 	name,
                           const char * 	mapset,
                           struct Categories * 	pcats
                           )
        """
        self.reset()
        err = libraster.Rast_read_cats(self.name, self.mapset,
                                       ctypes.byref(self.c_cats))
        if err == -1:
            raise GrassError("Can not read the categories.")
        # copy from C struct to list
        self._read_cats()