accessmod/layer.py
def read(self) -> Union[np.ndarray, pd.DataFrame, gpd.GeoDataFrame]:
        """Read raster, vector or tabular data."""
        if not self.exists():
            raise FileNotFoundError(f"File {self.filepath} does not exist.")

        if self.format == Format.VECTOR:
            with tempfile.NamedTemporaryFile(suffix=f".{self.extension}") as f:
                self.fs.get(self.filepath, f.name)
                return gpd.read_file(f.name)

        with self.fs.open(self.filepath, "rb") as f:

            if self.format == Format.TABULAR:
                extension = os.path.basename(self.filepath).split(".")[-1].lower()
                if extension == "csv":
                    return pd.read_csv(f)
                elif extension in ("xls", "xlsx"):
                    return pd.read_excel(f)

            elif self.format == Format.RASTER:
                with rasterio.open(f) as src:
                    return src.read(1)

            else:
                raise ValueError("Unrecognized file format.")
Read raster, vector or tabular data.
Read raster, vector or tabular data.
Read raster vector or tabular data .
def read(self) -> Union[np.ndarray, pd.DataFrame, gpd.GeoDataFrame]:
        if not self.exists():
            raise FileNotFoundError(f"File {self.filepath} does not exist.")
        if self.format == Format.VECTOR:
            with tempfile.NamedTemporaryFile(suffix=f".{self.extension}") as f:
                self.fs.get(self.filepath, f.name)
                return gpd.read_file(f.name)
        with self.fs.open(self.filepath, "rb") as f:
            if self.format == Format.TABULAR:
                extension = os.path.basename(self.filepath).split(".")[-1].lower()
                if extension == "csv":
                    return pd.read_csv(f)
                elif extension in ("xls", "xlsx"):
                    return pd.read_excel(f)
            elif self.format == Format.RASTER:
                with rasterio.open(f) as src:
                    return src.read(1)
            else:
                raise ValueError("Unrecognized file format.")
def read ( self ) -> Union [ np . ndarray , pd . DataFrame , gpd . GeoDataFrame ] : if not self . exists ( ) : raise FileNotFoundError ( f"File {self.filepath} does not exist." ) if self . format == Format . VECTOR : with tempfile . NamedTemporaryFile ( suffix = f".{self.extension}" ) as f : self . fs . get ( self . filepath , f . name ) return gpd . read_file ( f . name ) with self . fs . open ( self . filepath , "rb" ) as f : if self . format == Format . TABULAR : extension = os . path . basename ( self . filepath ) . split ( "." ) [ - 1 ] . lower ( ) if extension == "csv" : return pd . read_csv ( f ) elif extension in ( "xls" , "xlsx" ) : return pd . read_excel ( f ) elif self . format == Format . RASTER : with rasterio . open ( f ) as src : return src . read ( 1 ) else : raise ValueError ( "Unrecognized file format." )
Read raster, vector or tabular data.
Read raster vector or tabular data .
"""Read raster, vector or tabular data."""
self