Skip to content

Commit

Permalink
Update core.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ElcoK committed Jan 27, 2019
1 parent 8921095 commit 05ee88f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/damagescanner/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def RasterScanner(landuse_map,inun_map,curve_path,maxdam_path,centimeters=False,
return None

# set cellsize:
if isinstance(landuse_map,str) & isinstance(inun_map,str):
if isinstance(landuse_map,str) | isinstance(inun_map,str):
cellsize = src.res[0]*src.res[1]
else:
cellsize = kwargs['cellsize']
Expand All @@ -114,11 +114,11 @@ def RasterScanner(landuse_map,inun_map,curve_path,maxdam_path,centimeters=False,

#Load maximum damages
if isinstance(maxdam_path, pandas.DataFrame):
maxdam = maxdam_path.values #dict(zip(maxdam['landuse'],maxdam['damage']))
maxdam = maxdam_path.values
elif isinstance(maxdam_path, numpy.ndarray):
maxdam = maxdam_path
elif maxdam_path.endswith('.csv'):
maxdam = pandas.read_csv(maxdam_path,skiprows=1).values#dict(zip(pd.read_csv(maxdam_path)['landuse'],pd.read_csv(maxdam_path)['damage']))
maxdam = pandas.read_csv(maxdam_path,skiprows=1).values

# Speed up calculation by only considering feasible points
if centimeters:
Expand Down Expand Up @@ -298,4 +298,4 @@ def VectorScanner(landuse,inun_file,curve_path,maxdam_path,landuse_col='landuse'
new_gdf['damaged'] = new_gdf.progress_apply(lambda x : get_losses(x,curves,maxdam),axis=1)

# And return the GeoDataFrame with all unique shapes
return gdf.groupby(landuse_col).sum()[['area_m2','damaged']]
return gdf.groupby(landuse_col).sum()[['area_m2','damaged']]

0 comments on commit 05ee88f

Please sign in to comment.