Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import rasterio
  2. src = rasterio.open('../image.tif', mode='r')
  3. data_mask = src.read_masks(1)
  4. data = src.read(1)
  5.  
  6. array([[255, 255, 255, ..., 254, 255, 255],
  7. [255, 255, 255, ..., 254, 255, 255],
  8. [255, 255, 255, ..., 254, 255, 255],
  9. ...,
  10. [255, 255, 255, ..., 248, 252, 248],
  11. [254, 254, 254, ..., 255, 235, 253],
  12. [255, 255, 255, ..., 255, 255, 245]], dtype=uint8)
  13.  
  14. array([[255, 255, 255, ..., 255, 255, 255],
  15. [255, 255, 255, ..., 255, 255, 255],
  16. [255, 255, 255, ..., 255, 255, 255],
  17. ...,
  18. [255, 255, 255, ..., 255, 255, 255],
  19. [255, 255, 255, ..., 255, 255, 255],
  20. [255, 255, 255, ..., 255, 255, 255]], dtype=uint8)
  21.  
  22. gdal_translate -b mask -of vrt -a_nodata 0 test.tif test.vrt
  23. gdal_translate -b 1 -of vrt -a_nodata 0 test.vrt test2.vrt
  24. gdal_polygonize.py -q -8 test2.vrt -b 1 -f "ESRI Shapefile" testdata.shp
  25.  
  26. gdalwarp -dstnodata 0 -dstalpha -of GTiff foo1 foo2
  27. gdal_polygonize.py foo2 -b 2 -f "ESRI Shapefile" foo3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement