Skip to content

Commit

Permalink
fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
alpha-beta-soup committed May 19, 2023
1 parent 91874b0 commit 2adf7ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ raster2dggs h3 --resolution 13 --compression zstd --resampling nearest -a median
title={{raster2dggs}},
author={Ardo, James and Law, Richard},
url={https://github.com/manaakiwhenua/raster2dggs},
version={0.2.0},
version={0.2.1},
date={2023-02-09}
}
```

APA/Harvard

> Ardo, J., & Law, R. (2023). raster2dggs (0.2.0) [Computer software]. https://github.com/manaakiwhenua/raster2dggs
> Ardo, J., & Law, R. (2023). raster2dggs (0.2.1) [Computer software]. https://github.com/manaakiwhenua/raster2dggs
[![manaakiwhenua-standards](https://github.com/manaakiwhenua/raster2dggs/workflows/manaakiwhenua-standards/badge.svg)](https://github.com/manaakiwhenua/manaakiwhenua-standards)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "raster2dggs"
version = "0.2.0"
version = "0.2.1"
description = ""
authors = ["James Ardo <[email protected]>"]
maintainers = ["Richard Law <[email protected]>"]
Expand Down
20 changes: 15 additions & 5 deletions raster2dggs/h3.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"decimals": 1,
"warp_mem_limit": 12000,
"resampling": "average",
"tempdir": tempfile.tempdir
}

DEFAULT_PARENT_OFFSET = 6
Expand All @@ -54,7 +55,7 @@ class ParentResolutionException(Exception):
pass


def _get_parent_res(parent_res: int, resolution: int) -> int:
def _get_parent_res(parent_res: Union[None, int], resolution: int) -> int:
"""
Uses a parent resolution,
OR,
Expand All @@ -63,7 +64,7 @@ def _get_parent_res(parent_res: int, resolution: int) -> int:
Used for intermediate re-partioning.
"""
return (
parent_res
int(parent_res)
if parent_res is not None
else max(MIN_H3, (resolution - DEFAULT_PARENT_OFFSET))
)
Expand Down Expand Up @@ -110,7 +111,7 @@ def _initial_index(
raster_input: Union[Path, str],
output: Path,
resolution: int,
parent_res: int,
parent_res: Union[None, int],
warp_args: dict,
**kwargs,
) -> Path:
Expand Down Expand Up @@ -365,6 +366,12 @@ def _address_boundary_issues(
type=click.Choice(Resampling._member_names_),
help="Input raster may be warped to EPSG:4326 if it is not already in this CRS. Or, if the upscale parameter is greater than 1, there is a need to resample. This setting specifies this resampling algorithm.",
)
@click.option(
"--tempdir",
default=DEFAULTS["tempdir"],
type=click.Path(),
help="Temporary data is created during the execution of this program. This parameter allows you to control where this data will be written."
)
@click.version_option(version=__version__)
def h3(
raster_input: Union[str, Path],
Expand All @@ -379,14 +386,17 @@ def h3(
overwrite: bool,
warp_mem_limit: int,
resampling: str,
tempdir: Union[str, Path],
):
"""
Ingest a raster image and index it to the H3 DGGS.
RASTER_INPUT is the path to input raster data; prepend with protocol like s3:// or hdfs:// for remote data.
OUTPUT_DIRECTORY should be a directory, not a file, as it will be the write location for an Apache Parquet data store, with partitions equivalent to parent cells of target cells at a fixed offset. However, this can also be remote (use the appropriate prefix, e.g. s3://).
"""
if not int(parent_res) < int(resolution):
tempfile.tempdir = tempdir
print(tempfile.tempdir)
if parent_res is not None and not int(parent_res) < int(resolution):
raise ParentResolutionException(
"Parent resolution ({pr}) must be less than target resolution ({r})".format(
pr=parent_res, r=resolution
Expand Down Expand Up @@ -425,7 +435,7 @@ def h3(
raster_input,
output_directory,
int(resolution),
int(parent_res),
parent_res,
warp_args,
**kwargs,
)

0 comments on commit 2adf7ac

Please sign in to comment.