Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import rasterio
- src = rasterio.open('../image.tif', mode='r')
- data_mask = src.read_masks(1)
- data = src.read(1)
- array([[255, 255, 255, ..., 254, 255, 255],
- [255, 255, 255, ..., 254, 255, 255],
- [255, 255, 255, ..., 254, 255, 255],
- ...,
- [255, 255, 255, ..., 248, 252, 248],
- [254, 254, 254, ..., 255, 235, 253],
- [255, 255, 255, ..., 255, 255, 245]], dtype=uint8)
- array([[255, 255, 255, ..., 255, 255, 255],
- [255, 255, 255, ..., 255, 255, 255],
- [255, 255, 255, ..., 255, 255, 255],
- ...,
- [255, 255, 255, ..., 255, 255, 255],
- [255, 255, 255, ..., 255, 255, 255],
- [255, 255, 255, ..., 255, 255, 255]], dtype=uint8)
- gdal_translate -b mask -of vrt -a_nodata 0 test.tif test.vrt
- gdal_translate -b 1 -of vrt -a_nodata 0 test.vrt test2.vrt
- gdal_polygonize.py -q -8 test2.vrt -b 1 -f "ESRI Shapefile" testdata.shp
- gdalwarp -dstnodata 0 -dstalpha -of GTiff foo1 foo2
- gdal_polygonize.py foo2 -b 2 -f "ESRI Shapefile" foo3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement