This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import rasterio | |
| with rasterio.open(raster_filename, 'r') as src: | |
| image = src.read_band(1) # read | |
| features = rasterio.features.polygonize(image) # no I/O! | |
| with fiona.open(vector_filename, 'w', **meta) as dst: | |
| dst.writerecords(features) # write |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /****************************************************************************** | |
| * $Id$ | |
| * Project: GDAL | |
| * Purpose: Raster to Polygon Converter | |
| * Author: Frank Warmerdam, [email protected] | |
| * | |
| ****************************************************************************** | |
| * Copyright (c) 2008, Frank Warmerdam | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> import numpy | |
| >>> from scipy.ndimage.morphology import grey_dilation | |
| >>> a = numpy.zeros((7, 7)) | |
| >>> a[3,3] = 1 | |
| >>> a | |
| array([[ 0., 0., 0., 0., 0., 0., 0.], | |
| [ 0., 0., 0., 0., 0., 0., 0.], | |
| [ 0., 0., 0., 0., 0., 0., 0.], | |
| [ 0., 0., 0., 1., 0., 0., 0.], | |
| [ 0., 0., 0., 0., 0., 0., 0.], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import rasterio | |
| with rasterio.open('input.tif') as src: | |
| source = src.read_band(1) | |
| def window_transform(transform, offset): | |
| result = transform[:] | |
| result[3] = transform[3] + offset[0]*transform[5] | |
| result[0] = transform[0] + offset[1]*transform[1] | |
| return result |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| #GPX GPX Yes Yes Yes (read support needs libexpat) | |
| ("GPX", "raw"), | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import rasterio | |
| import numpy as np | |
| src = rasterio.open('/Users/sean/code/decloud/envs/1_16/output/0_q.tif') | |
| # Fraction of elements with value > 100 at full resolution. | |
| q = src.read_band(1) | |
| ones = np.ones(q.shape) | |
| print "Full, %d pixels" % (q.shape[0]*q.shape[1]) | |
| print sum(ones[q>100])/(q.shape[0]*q.shape[1]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
