Skip to content

Commit 1d4de13

Browse files
committed
Add option to limit to state
1 parent e67e329 commit 1d4de13

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

embeddings/all-naip.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
EMBEDDINGS_BUCKET = "clay-embeddings-naip"
3131

3232

33-
def open_scene_list():
33+
def open_scene_list(limit_to_state=None):
3434
"""
3535
Read the naip-analytic manifest file and extract a list of NAIP
3636
scenes as tif files to process.
@@ -42,7 +42,13 @@ def open_scene_list():
4242
data = f.readlines()
4343
data = [Path(dat.rstrip()) for dat in data if "rgbir_cog"]
4444
data = [dat for dat in data if dat.suffix == ".tif"]
45+
4546
logger.debug(f"Found {len(data)} NAIP scenes in manifest")
47+
48+
if limit_to_state is not None:
49+
data = [dat for dat in data if str(dat).startswith(limit_to_state)]
50+
logger.debug(f"Found {len(data)} NAIP scenes for state {limit_to_state}")
51+
4652
return data
4753

4854

@@ -110,8 +116,9 @@ def process():
110116
index = int(os.environ.get("AWS_BATCH_JOB_ARRAY_INDEX", 0))
111117
items_per_job = int(os.environ.get("ITEMS_PER_JOB", 2))
112118
batchsize = int(os.environ.get("EMBEDDING_BATCH_SIZE", 50))
119+
limit_to_state = os.environ.get("LIMIT_TO_STATE", None)
113120

114-
scenes = open_scene_list()
121+
scenes = open_scene_list(limit_to_state)
115122
clay = load_clay()
116123

117124
for i in range(index * items_per_job, (index + 1) * items_per_job):

0 commit comments

Comments
 (0)