RiskChanges / RiskChangesDesktop

Desktop version of RiskChanges Library
MIT License
3 stars 3 forks source link

Exposure code works for polygon but not for lines and points #1

Open shakyaanice opened 2 years ago

shakyaanice commented 2 years ago

image

shakyaanice commented 2 years ago

AttributeError Traceback (most recent call last) in () 7 admin_unit=combination["Admin Unit"] 8 agg_col=combination["Aggregation Column"] ----> 9 Exposure.ComputeExposure(ear, hazard, ear_key, outputdir, outputformat)

9 frames /usr/local/lib/python3.7/dist-packages/RiskChangesDesktop/Exposure.py in ComputeExposure(ear, hazard, ear_key, outputdir, outputformat) 175 df.drop('geometry',axis=1).to_csv(outputname+".csv") 176 def ComputeExposure(ear,hazard,ear_key,outputdir,outputformat="csv"): --> 177 exposure=Exposure(ear, hazard,ear_key) 178 #import geopandas as gpd 179 ear=gpd.read_file(ear)

/usr/local/lib/python3.7/dist-packages/RiskChangesDesktop/Exposure.py in Exposure(input_zone, input_value_raster, Ear_Table_PK, agg_col) 27 28 elif(geometrytype=='LINESTRING' or geometrytype=='MULTILINESTRING'): ---> 29 return zonalPoint(lyr,input_value_raster,Ear_Table_PK,agg_col=agg_col) 30 def zonalPoly(input_zone_data,input_value_raster,Ear_Table_PK,agg_col): 31 raster=rasterio.open(input_value_raster)

/usr/local/lib/python3.7/dist-packages/RiskChangesDesktop/Exposure.py in zonalPoint(lyr, input_value_raster, Ear_Table_PK, agg_col) 150 return df 151 def zonalPoint(lyr,input_value_raster,Ear_Table_PK,agg_col): --> 152 df=gpd.read_file(lyr) 153 src=rasterio.open(input_value_raster) 154 print("Calculating via centroid")

/usr/local/lib/python3.7/dist-packages/geopandas/io/file.py in _read_file(filename, bbox, mask, rows, kwargs) 199 200 with fiona_env(): --> 201 with reader(path_or_bytes, kwargs) as features: 202 203 # In a future Fiona release the crs attribute of features will

/usr/local/lib/python3.7/dist-packages/fiona/env.py in wrapper(*args, kwargs) 406 def wrapper(*args, *kwargs): 407 if local._env: --> 408 return f(args, kwargs) 409 else: 410 if isinstance(args[0], str):

/usr/local/lib/python3.7/dist-packages/fiona/init.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, **kwargs) 259 path = ParsedPath(path, archive, scheme) 260 else: --> 261 path = parse_path(fp) 262 263 if mode in ('a', 'r'):

/usr/local/lib/python3.7/dist-packages/fiona/path.py in parse_path(path) 130 return UnparsedPath(path) 131 --> 132 elif path.startswith('/vsi'): 133 return UnparsedPath(path) 134

/usr/local/lib/python3.7/dist-packages/osgeo/ogr.py in (self, name) 1395 for _s in [MajorObject]: 1396 swig_getmethods__.update(getattr(_s, 'swig_getmethods', {})) -> 1397 getattr = lambda self, name: _swig_getattr(self, Layer, name) 1398 1399 def init__(self, *args, **kwargs):

/usr/local/lib/python3.7/dist-packages/osgeo/ogr.py in _swig_getattr(self, class_type, name) 72 73 def _swig_getattr(self, class_type, name): ---> 74 return _swig_getattr_nondynamic(self, class_type, name, 0) 75 76

/usr/local/lib/python3.7/dist-packages/osgeo/ogr.py in _swig_getattr_nondynamic(self, class_type, name, static) 67 return method(self) 68 if (not static): ---> 69 return object.getattr(self, name) 70 else: 71 raise AttributeError(name)

AttributeError: type object 'object' has no attribute 'getattr'