Spaces:
Runtime error
Runtime error
caching prev dates to persistatent memory
Browse files- process.py +3 -3
- utils.py +3 -3
process.py
CHANGED
|
@@ -12,7 +12,7 @@ config.sh_client_secret = 'LEyvAXIGIsHh6iFZaZ1u4uCmpYgcyWwf'
|
|
| 12 |
|
| 13 |
def Download_image_in_given_date(clientName, metric, df, field, date, mime_type = MimeType.TIFF):
|
| 14 |
sen_obj = SenHub(config, mime_type = mime_type)
|
| 15 |
-
download_path = f'./{clientName}/raw/{metric}/{date}/field_{field}/'
|
| 16 |
bbox = utils.calculate_bbox(df, field)
|
| 17 |
evalscript = utils.Scripts[metric]
|
| 18 |
sen_obj.set_dir(download_path)
|
|
@@ -28,7 +28,7 @@ def mask_downladed_image(clientName, metric, df, field, date):
|
|
| 28 |
field_geom = field_vals.geometry
|
| 29 |
crs = field_vals.crs
|
| 30 |
clipped = im.rio.clip(field_geom, crs, drop=True)
|
| 31 |
-
save_dir_path = f'./{clientName}/processed/{metric}/{date}/field_{field}/'
|
| 32 |
os.makedirs(save_dir_path, exist_ok=True)
|
| 33 |
save_tiff_path = save_dir_path + 'masked.tiff'
|
| 34 |
clipped.rio.to_raster(save_tiff_path)
|
|
@@ -38,7 +38,7 @@ def convert_maske_image_to_geodataframe(clientName, metric, df, field, date, crs
|
|
| 38 |
imagePath = utils.get_masked_location_img_path(clientName, metric, date, field)
|
| 39 |
im = rx.open_rasterio(imagePath)
|
| 40 |
gdf = utils.tiff_to_geodataframe(im, metric, date, crs)
|
| 41 |
-
save_dir_path = f'./{clientName}/curated/{metric}/{date}/field_{field}/'
|
| 42 |
os.makedirs(save_dir_path, exist_ok=True)
|
| 43 |
save_geojson_path = save_dir_path + 'masked.geojson'
|
| 44 |
gdf.to_file(save_geojson_path, driver='GeoJSON')
|
|
|
|
| 12 |
|
| 13 |
def Download_image_in_given_date(clientName, metric, df, field, date, mime_type = MimeType.TIFF):
|
| 14 |
sen_obj = SenHub(config, mime_type = mime_type)
|
| 15 |
+
download_path = f'./data/{clientName}/raw/{metric}/{date}/field_{field}/'
|
| 16 |
bbox = utils.calculate_bbox(df, field)
|
| 17 |
evalscript = utils.Scripts[metric]
|
| 18 |
sen_obj.set_dir(download_path)
|
|
|
|
| 28 |
field_geom = field_vals.geometry
|
| 29 |
crs = field_vals.crs
|
| 30 |
clipped = im.rio.clip(field_geom, crs, drop=True)
|
| 31 |
+
save_dir_path = f'./data/{clientName}/processed/{metric}/{date}/field_{field}/'
|
| 32 |
os.makedirs(save_dir_path, exist_ok=True)
|
| 33 |
save_tiff_path = save_dir_path + 'masked.tiff'
|
| 34 |
clipped.rio.to_raster(save_tiff_path)
|
|
|
|
| 38 |
imagePath = utils.get_masked_location_img_path(clientName, metric, date, field)
|
| 39 |
im = rx.open_rasterio(imagePath)
|
| 40 |
gdf = utils.tiff_to_geodataframe(im, metric, date, crs)
|
| 41 |
+
save_dir_path = f'./data/{clientName}/curated/{metric}/{date}/field_{field}/'
|
| 42 |
os.makedirs(save_dir_path, exist_ok=True)
|
| 43 |
save_geojson_path = save_dir_path + 'masked.geojson'
|
| 44 |
gdf.to_file(save_geojson_path, driver='GeoJSON')
|
utils.py
CHANGED
|
@@ -104,7 +104,7 @@ def get_downloaded_location_img_path(clientName, metric, date, field, extension=
|
|
| 104 |
'''
|
| 105 |
Get the path of the downloaded image in TIFF based on the:
|
| 106 |
'''
|
| 107 |
-
date_dir = f'./{clientName}/raw/{metric}/{date}/field_{field}/'
|
| 108 |
print(f'True Color Date Dir: {date_dir}')
|
| 109 |
os.makedirs(date_dir, exist_ok=True)
|
| 110 |
intermediate_dirs = os.listdir(date_dir)
|
|
@@ -122,7 +122,7 @@ def get_masked_location_img_path(clientName, metric, date, field):
|
|
| 122 |
'''
|
| 123 |
Get the path of the downloaded image after applying the mask in TIFF based on the:
|
| 124 |
'''
|
| 125 |
-
date_dir = f'./{clientName}/processed/{metric}/{date}/field_{field}/'
|
| 126 |
imagePath = date_dir + 'masked.tiff'
|
| 127 |
return imagePath
|
| 128 |
|
|
@@ -130,7 +130,7 @@ def get_curated_location_img_path(clientName, metric, date, field):
|
|
| 130 |
'''
|
| 131 |
Get the path of the downloaded image after applying the mask and converting it to geojson formay based on the:
|
| 132 |
'''
|
| 133 |
-
date_dir = f'./{clientName}/curated/{metric}/{date}/field_{field}/'
|
| 134 |
imagePath = date_dir + 'masked.geojson'
|
| 135 |
|
| 136 |
if os.path.exists(imagePath):
|
|
|
|
| 104 |
'''
|
| 105 |
Get the path of the downloaded image in TIFF based on the:
|
| 106 |
'''
|
| 107 |
+
date_dir = f'./data/{clientName}/raw/{metric}/{date}/field_{field}/'
|
| 108 |
print(f'True Color Date Dir: {date_dir}')
|
| 109 |
os.makedirs(date_dir, exist_ok=True)
|
| 110 |
intermediate_dirs = os.listdir(date_dir)
|
|
|
|
| 122 |
'''
|
| 123 |
Get the path of the downloaded image after applying the mask in TIFF based on the:
|
| 124 |
'''
|
| 125 |
+
date_dir = f'./data/{clientName}/processed/{metric}/{date}/field_{field}/'
|
| 126 |
imagePath = date_dir + 'masked.tiff'
|
| 127 |
return imagePath
|
| 128 |
|
|
|
|
| 130 |
'''
|
| 131 |
Get the path of the downloaded image after applying the mask and converting it to geojson formay based on the:
|
| 132 |
'''
|
| 133 |
+
date_dir = f'./data/{clientName}/curated/{metric}/{date}/field_{field}/'
|
| 134 |
imagePath = date_dir + 'masked.geojson'
|
| 135 |
|
| 136 |
if os.path.exists(imagePath):
|