Interpolate the potential energy of 12 yrs


In [2]:
import pandas as pd
import numpy as np
import gdal
from IPython import display

In [3]:
def restot(raster_path, grid_res=1000, null_value=-9999, band=1):
    """
    Calculate the total energy resources in a given area
    ====================================================
    
    Arguments:
    ----------
    raster_path: the path to input raster (all format supported by GDAL)
    grid_res: resolution of raster, default is 1000 meters
    null_value: null value in the raster file, default is -9999
    band: raster band, default is 1
    
    
    Example:
    --------
    >>> restot(raster_path='path/to/your/raster.file', grid_res=1000, null_value=-9999)
    510000000
    
    Return:
    -------
    numeric value
    """
    rast_obj = gdal.Open(raster_path)
    rast = rast_obj.GetRasterBand(band)
    # convert to pandas DataFrame
    df = pd.DataFrame(rast.ReadAsArray())
    df = df.replace(null_value, np.nan)
    unit_area = ( grid_res**2 )
    output = ( df * unit_area ).sum().sum()
    return(output)

In [4]:
solar_r = 'figures/interpolated_maps/pe12_IDW_1000_solar_r.img'
solar_maxp = 'figures/interpolated_maps/pe12_IDW_1000_solar_maxp.img'
wind_r2 = 'figures/interpolated_maps/pe12_IDW_1000_wind_r2.img'
wind_maxp2 = 'figures/interpolated_maps/pe12_IDW_1000_wind_maxp2.img'

In [5]:
res1 = ( restot(solar_r),restot(solar_maxp), restot(wind_r2), restot(wind_maxp2) )

太陽能年資源量(kWh/yr)


In [6]:
res1[0]


Out[6]:
51437854906000.0

In [7]:
display.Image('figures/pe12_solar.png', height=300, width=300)


Out[7]:

太陽能年最大裝置發電量(kWh/yr)


In [ ]:
res1[1]

In [ ]:

風能年資源量(kWh/yr)


In [ ]:
res1[2]

風能年最大裝置發電量(kWh/yr)


In [ ]:
res1[3]

In [ ]: