Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -14,7 +14,7 @@ repos:
args: [--allow-missing-credentials]
- id: detect-private-key
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
rev: v0.43.0
hooks:
- id: markdownlint
name: Markdownlint
Expand All @@ -24,14 +24,14 @@ repos:
"--disable=MD033", # no-inline-html
]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files
additional_dependencies: [tomli]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.9.1
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand Down
2 changes: 1 addition & 1 deletion notebooks/ZON_DECAT_NTL_from_AWS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
"inD = inD.to_crs(\"epsg:4326\")\n",
"\n",
"for cur_tif in ntl_files:\n",
" file = f'{cur_tif.split(\"/\")[-1]}.tif'\n",
" file = f\"{cur_tif.split('/')[-1]}.tif\"\n",
" out_file = os.path.join(os.path.join(viirs_folder, \"%s\" % file))\n",
" curR = rasterio.open(cur_tif)\n",
" if not os.path.exists(out_file):\n",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies = [
"python-dotenv>=0.5.1",
"rasterio",
"s3fs",
"seaborn",
"seaborn",
"tqdm",
"xarray"
]
Expand Down
37 changes: 22 additions & 15 deletions src/GOSTrocks/dataMisc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def aws_search_ntl(
:type verbose: bool, optional
"""
if unsigned:
s3client = boto3.client("s3", verify=False, config=Config(signature_version=UNSIGNED))
s3client = boto3.client(
"s3", verify=False, config=Config(signature_version=UNSIGNED)
)
else:
s3client = boto3.client("s3", verify=False)

Expand Down Expand Up @@ -151,16 +153,22 @@ def get_fathom_vrts(return_df=False):
return vrt_pd
return all_vrts

def get_worldcover(df, download_folder, worldcover_vrt='WorldCover.vrt',
version='v200',
print_command=False, verbose=False):
""" Download ESA globcover from AWS (https://aws.amazon.com/marketplace/pp/prodview-7oorylcamixxc)

def get_worldcover(
df,
download_folder,
worldcover_vrt="WorldCover.vrt",
version="v200",
print_command=False,
verbose=False,
):
"""Download ESA globcover from AWS (https://aws.amazon.com/marketplace/pp/prodview-7oorylcamixxc)

Parameters
----------
df : geopandas.GeoDataFrame
Data frame used to select tiles to download; selects tiles based on the data frame unary_union
download_folder : string
download_folder : string
path to folder to download tiles
worldcover_vrt : str, optional
name of the VRT file to create, by default 'WorldCover.vrt'
Expand All @@ -172,23 +180,23 @@ def get_worldcover(df, download_folder, worldcover_vrt='WorldCover.vrt',
verbose : bool, optional
Print more updates during processing, by default False
"""
bucket='esa-worldcover'
esa_file_geojson = 'esa_worldcover_grid.geojson'
s3 = boto3.client('s3', verify=False, config=Config(signature_version=UNSIGNED))

bucket = "esa-worldcover"
esa_file_geojson = "esa_worldcover_grid.geojson"
s3 = boto3.client("s3", verify=False, config=Config(signature_version=UNSIGNED))
tiles_geojson = os.path.join(download_folder, esa_file_geojson)

if not os.path.exists(tiles_geojson):
s3.download_file(bucket, esa_file_geojson, tiles_geojson)

tile_path = "{version}/2021/map/ESA_WorldCover_10m_2021_v200_{tile}_Map.tif"

in_tiles = gpd.read_file(tiles_geojson)
sel_tiles = in_tiles.loc[in_tiles.intersects(df.unary_union)]

all_tiles = []
for idx, row in sel_tiles.iterrows():
cur_tile_path = tile_path.format(tile=row['ll_tile'], version=version)
cur_tile_path = tile_path.format(tile=row["ll_tile"], version=version)
cur_out = os.path.join(download_folder, f"WorldCover_{row['ll_tile']}.tif")
all_tiles.append(cur_out)
if not os.path.exists(cur_out):
Expand All @@ -199,12 +207,11 @@ def get_worldcover(df, download_folder, worldcover_vrt='WorldCover.vrt',
if not os.path.exists(cur_out):
if verbose:
print(f"Downloading {cur_tile_path} to {cur_out}")
s3.download_file(bucket,cur_tile_path, cur_out)
s3.download_file(bucket, cur_tile_path, cur_out)
else:
if verbose:
print(f"File {cur_out} already exists")
out_vrt = os.path.join(download_folder, worldcover_vrt)
gdal.BuildVRT(out_vrt, all_tiles, options=gdal.BuildVRTOptions())

return(all_tiles)

return all_tiles
1 change: 1 addition & 0 deletions src/GOSTrocks/infra/aggregator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The following module contains a number of functions to aggregate geospatial outputs into tables for InfraSAP analytics.
"""

import geopandas as gpd
import pandas as pd
import rasterio as rio
Expand Down
2 changes: 1 addition & 1 deletion src/GOSTrocks/rasterMisc.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def project_raster(srcRst, dstCrs, output_raster=""):
dstCrs (int): crs to project to
output_raster (string): file to write to, defaults to '', which writes nothing

"""
"""
if dstCrs.__class__ == int:
dstCrs = CRS.from_epsg(dstCrs)

Expand Down