Closed ronnyhdez closed 3 months ago
Errors:
TypeError: 'FeatureCollection' object is not iterable
Then, converting to list:
TypeError: 'List' object is not iterable
Please send me the link to notebook you are using and make sure GEE collections of sites are accessible to all.
If I transform the feature collection to just ee.Geometry, it returns a different error:
EEException: Cannot convert a computed geometry to GeoJSON. Wrap a getInfo() call in json.dumps instead.
The function sampleSites
only accepts assets from GEE. The errors above were mainly because I was calling the asset and transforming it to a FeatureCollection
. The reason is that I need to filter by the intersecting features in the asset.
In GEE console I filtered the intersecting polygons, and then obtained the biggest 100 polygons by area, and then saved them as an asset.
From the notebook, I ran the LEAFtoolbox and it worked! This is part of the output
print(sitesDictionaryL08SR.values())
[863 rows x 25 columns]}, {'feature': {'area': 26643.913687916036, 'area_ha': 2.678175878285475, 'disp_nm': '', 'fetr_ty': 'WELL-ABAND', 'fieldnm': '', 'frst_spd_d': 1087801200000, 'frst_spd_y': 2004, 'hfi_id': '{BDB0B961-B79E-48E7-A397-96873FF0DD3B}', 'intersects_industrial': 0, 'intersects_industrial_buffer': 0, 'intersects_reservoirs': 0, 'intersects_reservoirs_buffer': 0, 'intersects_residential': 0, 'intersects_residential_buffer': 0, 'intersects_roads': 0, 'intersects_roads_buffer': 0, 'intersects_waterbodies': 0, 'intersects_waterbody_buffer': 0, 'lcu_id': '', 'mn_npr_': 2004, 'mx_bnd_': 2016, 'mx_ls__': 2005, 'nmbr_wl': 2, 'plygn_s': 9, 'prd_x__': 2, 'rclmtn_c': 1, 'rclmtn_d': 2021, 'rclmtn_s': 'reclaimed', 'shape_r': 26781.758782854748, 'shp_lng': 837.7389418259842, 'source': 'AHFMP', 'visible': 2, 'wll_stt': 1, 'wllst__': 151928, 'year': 2004}, 'leaftoolbox.SL2PV0': SR_B1 SR_B2 SR_B3 SR_B4 SR_B5 SR_B6 SR_B7 SR_QA_AEROSOL ST_B10 \
0 9919 10845 12307 13925 17113 21607 18207 96 45530
1 9900 10760 12239 13814 16957 21376 18115 96 45520
2 9862 10769 12237 13795 16829 21285 18056 160 45469
3 9875 10730 12196 13718 16815 21353 18114 96 45400
4 9890 10839 12348 13936 17116 21602 18232 160 45536
.. ... ... ... ... ... ... ... ... ...
696 8685 9471 11172 13049 18583 16849 12789 96 44500
697 8652 9461 11190 13042 18698 16729 12694 96 44374
698 8642 9436 11170 13025 18602 16774 12705 160 44403
699 8617 9430 11118 13059 18598 16930 12800 128 44411
700 8625 9410 11139 12938 18683 16693 12697 96 44418
ST_ATRAN ... ST_TRAD ST_URAD QA_PIXEL QA_RADSAT date \
0 9389 ... 9772 317 21824 0 1620066160433
1 9389 ... 9758 317 21824 0 1620066160433
2 9388 ... 9733 317 21824 0 1620066160433
3 9389 ... 9702 317 21824 0 1620066160433
4 9389 ... 9775 317 21824 0 1620066160433
.. ... ... ... ... ... ... ...
696 8454 ... 9239 1168 21824 0 1662920626208
697 8452 ... 9238 1169 21824 0 1662920626208
698 8451 ... 9235 1170 21824 0 1662920626208
699 8452 ... 9238 1169 21824 0 1662920626208
700 8452 ... 9242 1169 21824 0 1662920626208
longitude latitude cosVZA cosSZA cosRAA
0 -110.999399 53.341314 9979 7755 0
1 -110.998949 53.341314 9979 7755 0
2 -110.998498 53.341314 9979 7755 0
3 -110.998047 53.341314 9979 7755 0
4 -110.999399 53.341584 9979 7755 0
.. ... ... ... ... ...
696 -110.996696 53.342932 9981 6379 0
697 -110.998047 53.343202 9981 6379 0
698 -110.997597 53.343202 9981 6379 0
699 -110.997146 53.343202 9981 6379 0
700 -110.996696 53.343202 9981 6379 0
For those 100 polygons, the running time is between 1 hour and 2 (didn't take the time accurately)
sitesDictionaryL08SR = LEAF.sampleSites(
site,
imageCollectionName="LANDSAT/LC08/C02/T1_L2",
algorithm=SL2PV0,
variableName="Surface_Reflectance",
maxCloudcover=90,
outputScaleSize=30,
inputScaleSize=30,
bufferSpatialSize=0,
bufferTemporalSize=["2021-04-01", "2022-10-01"],
subsamplingFraction=0.99,
)
Execution time sitesDictionaryL08SR: 4276.814430475235 seconds
sitesDictionaryL09SR = LEAF.sampleSites(
site,
imageCollectionName="LANDSAT/LC09/C02/T1_L2",
algorithm=SL2PV0,
variableName="Surface_Reflectance",
outputScaleSize=30,
inputScaleSize=30,
bufferSpatialSize=0,
bufferTemporalSize=["2021-04-01", "2022-10-01"],
subsamplingFraction=0.99,
)
Execution time sitesDictionaryL09SR: 2787.4890642166138 seconds
Yes - you need a saved gee asset that is a feature collection. Make sure each feature has a correct 'system:time_start" property as this is used to guide sampling times.
Ref #88
After the flagging and filtering, I need to test the leaf toolbox on the selected polygons