Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shakyaanice opened this issue Mar 8, 2022 · 1 comment
Open

Comments

@shakyaanice
Copy link
Member

image

@shakyaanice
Copy link
Member Author


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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant