API Documentation
geoutils.LandsatGLAD module
- geoutils.LandsatGLAD.main()
The function can be used to download the Landsat Analysis Ready Data (GLAD ARD)
- Parameters
path_aoi – Path for AOI geojson.
out_path – The list of available products.
start_month – start month in specific year based on the code e.g. 24-May 2000 > 838 (int)
end_month – end month in specific year based on code e.g. 12-Sep 2000 > 844 (int)
count_years – how many years would like to download (int)
username – username for GDAL account
password – password for GDAL account
- Returns
The saved images in the disk
geoutils.cube module
- class geoutils.cube.cube(rast_list)
Bases:
object- generate_cube(start_date: str, freq: str)
Generate a data cube from the list of the xarray.DataArray
- Parameters
start_date – The first raster acqusition date
start_date – Frequency to collect the image
- Returns
xarray.DataArray
- generate_mosaic()
Generate the mosaic with calculation median over time from the list of the xarray.DataArray
- Returns
xarray.DataArray
- geoutils.cube.get_imgs(img_list: List[str], chunks: Set[int] = (1000, 1000)) List[xarray.core.dataarray.DataArray]
Opens the rasters as Dask dataArray
- Parameters
img_list – The list of the image name/path
chunks – The chunk size
- Returns
list of the opend images (list)
- geoutils.cube.to_tif(file: xarray.core.dataarray.DataArray, path: str, crs: int = 4326, cell_size: Optional[int] = None)
Save the generated cube or mosaic to GeoTIFF format
- Parameters
file – xarray.DataArray
path – The path to save the file
crs – The coordinate system to save image
cell_size – The cell size for resampling
- Returns
The saved GeoTiff file on the disk
geoutils.dataClean module
- geoutils.dataClean.remove_whitespace(df: pandas.core.frame.DataFrame, skip_rows: Optional[str] = None)
- Parameters
df – Datafrrame whcih should be checked for white space
skip_rows – list of the columns which should be ignored
- Returns
remove the white space from columns if exists
- geoutils.dataClean.rename_column_name(df: pandas.core.frame.DataFrame, old_column_list: List[str], new_column_list: List[str])
- Parameters
df – Datafrmae which want to change the name of the columns
old_column_list – List of the old columns’ name
new_column_list – List of the new columns’ name
- Returns
change the name of the columns in the datafrme
- geoutils.dataClean.transla(name_row: List[str], language_1: List[str], language_2: List[str])
- Parameters
name_row – The name in row
language_1 – List of the first language
language_2 – List of the second language
- Returns
translated name for each row
Usage: gdf[‘type_eng’] = gdf[‘type’].apply(transla,args=(lst_1,lst_2))
geoutils.dataExtraction module
- geoutils.dataExtraction.extract_class(image: Union[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], codes: List[int], new_code: int)
This function split different high-level classes based on the sub-classes
- Parameters
image – The original image to extract the groups
codes – The list of the codes which should be extracted
new_code – The code which should be determined to the new class
- Returns
npt.ArrayLike
- geoutils.dataExtraction.extract_geotif_to_point(rast_path: str, date: str, gdf_path: str, resample_size, stats: str = 'mean', mask: bool = False, nodata: int = 0) geopandas.geodataframe.GeoDataFrame
The function extract the values for each date from GeoTIFF raster image
- Parameters
rast_path – (file object or pathlib.Path object)
date – when the raster collected (Form: dd_mm_yyyy). it is important for time series data
gdf_path – (str, file object or pathlib.Path object)
resample_size – The buffer around the points. For the the point zero should be used
stats – The statistics should be used for aggregation
mask – The nodata value would be masked; default:False
nodata – value which should be consider as NoData value, default:0
- Returns
gpd.GeoDataFrame
- geoutils.dataExtraction.extract_netcdf_to_point(ds_path: str, gdf_path: str, resample_size: int, stats: str = 'mean', mask: bool = False, nodata: int = - 9999) geopandas.geodataframe.GeoDataFrame
The function extract the values for each date from NetCDF. Since the NetCDF files usually are multi-temporal it is decided to use multi process for each bands which can save a lot of time.
- Parameters
rast_path – (str, file object or pathlib.Path object)
gdf_path – (str, file object or pathlib.Path object)
resample_size – The buffer around the points. For the the point zero should be used
stats – The statistics should be used for aggregation
mask – The nodata value would be masked; default:False
nodata – value which should be consider as NoData value, default:0
- Returns
gpd.GeoDataFrame
geoutils.grid module
- geoutils.grid.generate_BID(gdf: geopandas.geodataframe.GeoDataFrame, coords: Optional[str] = None, cell: Optional[int] = None, x: Optional[float] = None, y: Optional[float] = None, circularity: bool = False)
The function generate ID for each cells in the grid
- Parameters
gdf – Geopandas Data Frame
coords – the name of the coordinate column
x – optional: if the center of the cells are available could be determined with y
y – optional
circularity – Determine roundness of polygon https://gis.stackexchange.com/questions/374053/determine-roundness-of-polygon-in-qgis
- Returns
The unique ID for each cell in the grid
- class geoutils.grid.grid(xmin: float, xmax: float, ymin: float, ymax: float, cell_size: float, crs: int = 4326)
Bases:
object- cells_within_polygon(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame
Generate cells inside the polygons
- Returns
The geo-dataframe of cells inside the polygons
- generate_grid() geopandas.geodataframe.GeoDataFrame
The function generate the Grid based on the bbox received from user
- Returns
-> gpd.GeoDataFrame
- generate_point(center: bool = True) geopandas.geodataframe.GeoDataFrame
The function generate the points based on the bbox received from user
- Parameters
center – whether to generate point for center of the grid or not
- Returns
gpd.GeoDataFrame
geoutils.image module
- geoutils.image.exract_boundry(original_img: str, source_img: str, out_path: str, crs: str)
The function allign the original image with source image
- Parameters
original_img – The image should be mapped to the source image
source_image – The image which should not be changed
out_path – Output path to save the image
crs – the output image projection
- Returns
The saved image in the disk
- geoutils.image.mosaic_from_tiles(in_put_path: str, out_put_path: str, dtype: str = 'float32', nodata: int = - 9999, mask: Optional[int] = None, format: str = 'GeoTiff')
The function generate a mosaic from the tiles. All the tiles should be in the same projection
- Parameters
in_put_path – The path to tiles
out_put_path – Output path to save the generated mosaic
dtype – data type
nodata – NAN value which should be assigned
format – Image format can be GeoTIFF or NetCDF
- Returns
The saved image in the disk
geoutils.modisAPI module
- geoutils.modisAPI.main()
Download MODIS and VIIRS Land Product Subsets RESTful Web Service
- Parameters
satellite – The list of available products.
product – Available band names for a product.
band – Name of data layer.
startDate – Name of data layer. (YYYY-MM-DD’)
endDate – Name of data layer. (YYYY-MM-DD’)
path_aoi – Path for AOI geojson.
crs_aoi – CRS for AOI geojson. Default: 4326
ouput_crs – CRS for output. Default: 4326
ouput_cellsize – out put image cellsize. Default: 250
number_chunks – There is a limit of a maximum ten modis dates per reques. Default: 10
- Returns
The saved images in the disk
geoutils.utils module
- geoutils.utils.chunk(l: int, n: int)
- geoutils.utils.convert_to_NetCDF(subsets, coords, ouput_crs, ouput_cellsize)
- geoutils.utils.extract_point(b, rc)
Extract the value for the points
- geoutils.utils.extract_point_buffer(b, rc, s)
Extract the value based on the surrounded buffer
- geoutils.utils.extract_point_buffer_mask(b, rc, s, nd)
Extract the value based on the surrounded buffer and mask the nodata value in calculation
- geoutils.utils.geometry_from_geojson(filepath: str)
- geoutils.utils.getSubsetURL(url: str, prod: str, lat: float, lon: float, band: int, sd: str, ed: str, ab: float, lr: float)
- geoutils.utils.list_files(dirpath: str, endswith: Optional[str] = None)
- geoutils.utils.list_files_with_absolute_paths(dirpath: str, endswith: Optional[str] = None)