atreebangalore / jaltol

a QGIS python plugin to make typology-specific Rural Water Security Plans. These plans help lead the user from data to decisions
MIT License
4 stars 3 forks source link

SPS SW & Crop Name errors #8

Open balakumaran247 opened 1 year ago

balakumaran247 commented 1 year ago

Describe the bug Vidhya getting Water Budget data for SPS regions, resulted in SW error and Crop Name not matching error.

To Reproduce If using a custom shapefile please upload ZIP of the same to project google drive folder GISLayers and add link below.

Steps to reproduce the behavior:

  1. Select the feature using select tool
  2. in Water budget tab under agriculture - click calculate
  3. in water availability tab under surface water - click calculate

Expected behavior Water Budget Calculation - get amount of water required for crop Water Availability Calculation - get Surface water available and Map of the SW layer

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context 2023-02-20T12:05:39 WARNING Traceback (most recent call last): File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\jaltol\gui\jt_waterbudget_widget.py", line 205, in initSWaterAvailability self.popSWA() File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\jaltol\gui\jt_waterbudget_widget.py", line 258, in popSWA WaterBodiesS1 = self.S1.calcNoWaterBodies(self.year,self.geometry) File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\jaltol\libs\jaltol_surfacewater.py", line 116, in calcNoWaterBodies Map.addLayer(self.s1EMwbv,{},'Water Bodies Vector') File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\Map.py", line 25, in addLayer add_or_update_ee_layer(eeObject, visParams, name, shown, opacity) File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\utils.py", line 158, in add_or_update_ee_layer update_ee_layer_properties(layer, eeObject, visParams, shown, opacity) File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\utils.py", line 26, in update_ee_layer_properties layer.dataProvider().set_ee_object(eeObject) AttributeError: 'QgsRasterDataProvider' object has no attribute 'set_ee_object'

2023-02-20T12:06:23 WARNING Traceback (most recent call last): File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\jaltol\gui\jt_waterbudget_widget.py", line 358, in initCropWaterRequirement self.calcCropWaterRequirement() File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\jaltol\gui\jt_waterbudget_widget.py", line 371, in calcCropWaterRequirement self.crop_details = self.crops_dict.get_crop_details(5) # 5 is no. of crops needed for a season File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\jaltol\libs\jaltol_cropwaterrequirement.py", line 86, in get_crop_details self.get_kc_list(row['crop']), File "C:\Users/ATREE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\jaltol\libs\jaltol_cropwaterrequirement.py", line 146, in get_kc_list return kc_dict[crop] KeyError: 'Moong(GreenGram)'

balakumaran247 commented 1 year ago

@craigdsouza replace the crop_details.py with the https://github.com/atreebangalore/jaltol/blob/main/libs/crop_details.py this should solve the errors due to crop names.

balakumaran247 commented 1 year ago

@craigdsouza the surface water error is due to adding it as a layer using Map.addLayer, error may be due to non availability of the SW in the region, comment out the Map.addLayer to ignore the error.