Skip to content

Commit

Permalink
Merge pull request #49 from ghidalgo3/main
Browse files Browse the repository at this point in the history
Support NAIP 2022 and later data
  • Loading branch information
lossyrob authored Jan 17, 2024
2 parents ecffe81 + 3d5d9f8 commit 29fd7cd
Show file tree
Hide file tree
Showing 10 changed files with 597 additions and 68 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project attempts to match the major and minor versions of [stactools](https://github.com/stac-utils/stactools) and increments the patch number as needed.

## [Unreleased]

### Added

- Support for NAIP 2022

### Changed

- Updated repository structure to match [stactools](https://github.com/stac-utils/stactools)

## [v0.4.0] - 2023-05-18

### Added
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ FROM stactools-naip:latest
RUN conda install -c conda-forge pandoc

COPY . /src/stactools-naip
RUN pip install -r /src/stactools-naip/requirements-dev.txt
WORKDIR /src/stactools-naip
RUN pip install .[dev]

39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
[project]
name = "stactools-naip"
dynamic = ["version"]
description = "STAC item creation tools for NAIP dataset."
readme = "README.md"
authors = [{name = "stac-utils", email = "[email protected]"}]
keywords = ["stactools", "pystac", "catalog", "STAC"]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
]
requires-python = ">=3.8"
dependencies = [
"stactools>=0.4.3",
"pystac>=1.5"
]

[tool.setuptools.dynamic]
version = { attr = "stactools.naip.__version__" }

[project.urls]
homepage = "https://github.com/stactools-naips/stactools-naip"
documentation = "https://stactools-naip.readthedocs.io/en/latest/"

[project.optional-dependencies]
dev = [
"black~=23.3",
"codespell~=2.2",
"coverage~=7.4.0",
"pre-commit~=3.3",
"flake8~=7.0.0",
"pytest-cov~=3.0",
"pytest~=7.3",
]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
Expand Down
7 changes: 0 additions & 7 deletions requirements-dev.txt

This file was deleted.

3 changes: 1 addition & 2 deletions scripts/update
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
usage
else
python -m pip install --upgrade pip
pip install . --no-binary rasterio
pip install -r requirements-dev.txt
pip install -e '.[dev]'
fi
fi
35 changes: 0 additions & 35 deletions setup.cfg

This file was deleted.

42 changes: 19 additions & 23 deletions src/stactools/naip/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,25 @@ def create_item(
)

if fgdc_metadata_href:
if year in ["2020", "2021"]:
if year < "2020":
fgdc_metadata_text = read_text(fgdc_metadata_href)
fgdc = parse_fgdc_metadata(fgdc_metadata_text)
try:
resource_desc = fgdc["Distribution_Information"]["Resource_Description"]
dt = str_to_datetime(
fgdc["Identification_Information"]["Time_Period_of_Content"][
"Time_Period_Information"
]["Single_Date/Time"]["Calendar_Date"]
)
except KeyError:
res = maybe_extract_id_and_date(cog_href)
if res is not None:
resource_desc, dt = res
else:
raise Exception(
f"Failed to extract item resource_desc and dt: {cog_href}"
)
else:
first_xpath = "gmd:fileIdentifier/gco:CharacterString"

second_xpath = "idinfo/citation/citeinfo/title"
Expand All @@ -171,28 +189,6 @@ def create_item(
raise Exception(
f"Failed to extract item resource_desc and dt: {cog_href}"
)

elif year < "2020":
fgdc_metadata_text = read_text(fgdc_metadata_href)
fgdc = parse_fgdc_metadata(fgdc_metadata_text)
try:
resource_desc = fgdc["Distribution_Information"]["Resource_Description"]
dt = str_to_datetime(
fgdc["Identification_Information"]["Time_Period_of_Content"][
"Time_Period_Information"
]["Single_Date/Time"]["Calendar_Date"]
)
except KeyError:
res = maybe_extract_id_and_date(cog_href)
if res is not None:
resource_desc, dt = res
else:
raise Exception(
f"Failed to extract item resource_desc and dt: {cog_href}"
)
else:
raise Exception(f"Metadata for year {year} is not supported.")

else:
res = maybe_extract_id_and_date(cog_href)
if res is not None:
Expand Down
Binary file not shown.
Loading

0 comments on commit 29fd7cd

Please sign in to comment.