# notebook dependencies
import geopandas as gpd
import rasterio as rio
import xarray as xr
import pyproj
from rasterio.mask import mask
We use a 2003 USGS shapefile of the shores of Lake Mead. This is located in aux_files/lakebnds
. We will write a new shapefile aux_files/bufferlakebnds.shp
. We also load in one DSWx GeoTIFF as a reference image.
shapepath = 'aux_files/lakebnds/lakebnds.shp'
bufferpath = 'aux_files/bufferlakebnds/bufferlakebnds.shp'
filepath = 's3://opera-pst-rs-pop1/products/OPERA_L3_DSWx-HLS_T11SQA_20201002T180918Z_20230118T203131Z_L8_30_v0.0/OPERA_L3_DSWx-HLS_T11SQA_20201002T180918Z_20230118T203131Z_L8_30_v0.0_B01_WTR.tif'
We reproject the shapefile to the same coordinate system as DSWx, create a 500 pixel buffer, and write to a new shapefile.
df = gpd.read_file(shapepath)
df_new = gpd.GeoDataFrame(columns=['BNDTYPE', 'geometry'], geometry='geometry')
f = xr.open_rasterio(filepath)
df_new['BNDTYPE'] = df['BNDTYPE']
df_new['geometry'] = df.geometry.to_crs(pyproj.CRS.to_epsg(pyproj.CRS.from_proj4(f.crs))).buffer(4000,join_style=2)
df_new.to_file(bufferpath)
The new shapefile aux_files/bufferlakebnds.shp
is already provided as part of this repository.