Guest User

Untitled

a guest
Jan 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import rasterio
  2. import rasterio.features
  3. import os
  4. import fiona
  5. import rasterio.mask
  6. with fiona.open("C:/Doy2000/Pivos/shp2001.shp", "r") as shapefile:
  7. shapes = [feature["geometry"] for feature in shapefile]
  8.  
  9. with rasterio.open("D:/projetp/2001/MOD13Q1.006__250m_16_days_EVI_doy2001017_aid0001.tif") as src:
  10. out_image, out_transform = rasterio.mask.mask(src, shapes, crop=True)
  11. out_meta = src.meta.copy()
  12.  
  13. out_meta.update({"driver": "GTiff",
  14. "height": out_image.shape[1],
  15. "width": out_image.shape[2],
  16. "transform": out_transform})
  17.  
  18. with rasterio.open("2001.tif", "w", **out_meta) as dest:
  19. dest.write(out_image)
Add Comment
Please, Sign In to add comment