-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpullNAIPforSubGridValidatiaon.py
More file actions
executable file
·79 lines (67 loc) · 2.24 KB
/
pullNAIPforSubGridValidatiaon.py
File metadata and controls
executable file
·79 lines (67 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import ee
import geemap
import pandas as pd
import geopandas as gpd
# ee.Authenticate(auth_mode = 'notebook')
ee.Initialize(project='agroforestry2023')
m2 = gpd.read_file("data/products/two_sq_grid.gpkg")
# redefine for 2010 match run
grids = [22746, 23046, 23347, 23349]
# export
for i in range(len(grids)):
print(i)
val = grids[i]
year = "2010"
# select subgrid
grid = m2.loc[m2['FID_two_grid'] == val]
subgrid = grid.iloc[0,0]
gee1 = geemap.gdf_to_ee(grid)
# select naip and export for each grid
naip1 = geemap.get_annual_NAIP(year).filterBounds(gee1).mosaic()
# description
description = "subgrid_" + str(subgrid)+"_year_"+str(year)
# export image to asset
task = ee.batch.Export.image.toDrive(
image=naip1,
description=description,
folder=str(year),
region=gee1.geometry(),
scale=1,
crs= naip1.projection(),
maxPixels=1e13
)
task.start()
# initial attempt
# read in all grid feature
# grids = pd.read_csv("data/products/selectedSubGrids/allSelectedGrids.csv")
# # read in 2 mile grid
# m2 = gpd.read_file("data/products/two_sq_grid.gpkg")
# # ee.Authenticate(auth_mode = 'notebook')
# ee.Initialize(project='agroforestry2023')
# # read in all grid feature
# grids = pd.read_csv("data/products/selectedSubGrids/allSelectedGrids.csv")
# # # read in 2 mile grid
# #
# for i in range(len(grids)):
# row = grids.iloc[i]
# model = row.iloc[0]
# year = row.iloc[1]
# for j in range(2,6):
# grid = m2.loc[m2['FID_two_grid'] == row.iloc[j]]
# subgrid = grid.iloc[0,0]
# gee1 = geemap.gdf_to_ee(grid)
# # select naip and export for each grid
# naip1 = geemap.get_annual_NAIP(year).filterBounds(gee1).mosaic()
# # description
# description = model + "_" + "subgrid_" + str(subgrid)+"_year_"+str(year)
# # export image to asset
# task = ee.batch.Export.image.toDrive(
# image=naip1,
# description=description,
# folder=str(year),
# region=gee1.geometry(),
# scale=1,
# crs= naip1.projection(),
# maxPixels=1e13
# )
# task.start()