Commit a1b63ab5 authored by Benjamin Pillot's avatar Benjamin Pillot
Browse files

Add new methods:

* Polygonize raster
* Apply sieve filter
parent d0a7f10c
......@@ -8,6 +8,7 @@ More detailed description.
import multiprocessing as mp
import warnings
import ogr
import pyproj
from pyrasta.io_.files import _copy_to_file
from import _op, _raster_calculation
......@@ -16,8 +17,10 @@ from import _resample_raster, _padding, _rescale_raster
_align_raster, _extract_bands, _merge_bands, _read_array, _xy_to_2d_index, _read_value_at, \
_project_raster, _array_to_raster
from pyrasta.exceptions import RasterBaseError
from import _sieve
from import _raster_mask
from import _merge
from import _polygonize
from import _rasterize
from import _histogram, _zonal_stats
from import _windowing
......@@ -285,6 +288,29 @@ class RasterBase:
return _padding(self, pad_x, pad_y, value)
def polygonize(self, filename, band=1, layer_name="layer", field_name="unknown",
ogr_driver=ogr.GetDriverByName("ESRI Shapefile"),
is_8_connected=False, progress_bar=False):
""" Polygonize raster
filename: str
band: int
layer_name: str
field_name: str
ogr_driver: ogr.Driver
is_8_connected: bool
progress_bar: bool
return _polygonize(self, filename, band, layer_name,
field_name, ogr_driver, is_8_connected,
def rasterize(cls, layer, projection, x_size, y_size, geo_transform,
burn_values=None, attribute=None,
......@@ -451,6 +477,21 @@ class RasterBase:
return _rescale_raster(self, r_min, r_max)
def sieve_filter(self, threshold=1, connectedness=4, progress_bar=False):
""" Apply sieve filter
threshold: int
connectedness: int
progress_bar: bool
return _sieve(self, threshold, connectedness, progress_bar)
def to_crs(self, crs):
""" Re-project raster onto new CRS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment