Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import rasterio
- import rasterio.features
- import os
- import fiona
- import rasterio.mask
- with fiona.open("C:/Doy2000/Pivos/shp2001.shp", "r") as shapefile:
- shapes = [feature["geometry"] for feature in shapefile]
- with rasterio.open("D:/projetp/2001/MOD13Q1.006__250m_16_days_EVI_doy2001017_aid0001.tif") as src:
- out_image, out_transform = rasterio.mask.mask(src, shapes, crop=True)
- out_meta = src.meta.copy()
- out_meta.update({"driver": "GTiff",
- "height": out_image.shape[1],
- "width": out_image.shape[2],
- "transform": out_transform})
- with rasterio.open("2001.tif", "w", **out_meta) as dest:
- dest.write(out_image)
Add Comment
Please, Sign In to add comment