Commit ef7da783 authored by Cresson Remi's avatar Cresson Remi
Browse files

ADD: securize sources + update docstring

1 merge request!12ENH: S2A and S3A support
Pipeline #33676 passed with stages
in 2 minutes and 52 seconds
Showing with 13 additions and 11 deletions
+13 -11
...@@ -51,7 +51,7 @@ class Source(pyotb.Output): ...@@ -51,7 +51,7 @@ class Source(pyotb.Output):
:return: drilled source :return: drilled source
""" """
if utils.open_vector_layer(msk_vec_file): if utils.open_vector_layer(msk_vec_file):
# Cloud mask is not empty # Vector data not empty
rasterization = pyotb.Rasterization({"in": msk_vec_file, rasterization = pyotb.Rasterization({"in": msk_vec_file,
"im": self, "im": self,
"mode": "binary", "mode": "binary",
...@@ -64,7 +64,7 @@ class Source(pyotb.Output): ...@@ -64,7 +64,7 @@ class Source(pyotb.Output):
""" """
Return the source masked from an uint8 binary raster (0 or 1..255). Return the source masked from an uint8 binary raster (0 or 1..255).
Pixels are set to "nodata" where the mask values are 0. Pixels are set to "nodata" where the mask values are 0.
:param binary_mask: input vector data filename :param binary_mask: input mono-band binary raster filename
:param nodata: nodata value for rejected values :param nodata: nodata value for rejected values
:return: masked source :return: masked source
""" """
...@@ -74,7 +74,7 @@ class Source(pyotb.Output): ...@@ -74,7 +74,7 @@ class Source(pyotb.Output):
"mode.apply.ndval": nodata}) "mode.apply.ndval": nodata})
return self.new_source(binary_mask, manage_nodata) return self.new_source(binary_mask, manage_nodata)
def resample_over(self, ref_img, interpolator="nn", nodata=0): def resample_over(self, ref_img, interpolator="bco", nodata=0):
""" """
Return the source superimposed over the input image Return the source superimposed over the input image
:param ref_img: reference image :param ref_img: reference image
...@@ -82,10 +82,11 @@ class Source(pyotb.Output): ...@@ -82,10 +82,11 @@ class Source(pyotb.Output):
:param nodata: no data value :param nodata: no data value
:return: resampled image source :return: resampled image source
""" """
return self.new_source(pyotb.Superimpose({"inm": self, superimpose = pyotb.Superimpose({"inm": self,
"inr": ref_img, "inr": ref_img,
"interpolator": interpolator, "interpolator": interpolator,
"fv": nodata})) "fv": nodata})
return self.new_source(ref_img, superimpose)
def clip_over_img(self, ref_img): def clip_over_img(self, ref_img):
""" """
...@@ -93,9 +94,10 @@ class Source(pyotb.Output): ...@@ -93,9 +94,10 @@ class Source(pyotb.Output):
:param ref_img: reference image :param ref_img: reference image
:return: ROI clipped source :return: ROI clipped source
""" """
return self.new_source(pyotb.ExtractROI({"in": self, extract_roi = pyotb.ExtractROI({"in": self,
"mode": "fit", "mode": "fit",
"mode.fit.im": ref_img})) "mode.fit.im": ref_img})
return self.new_source(ref_img, extract_roi)
def clip_over_vec(self, ref_vec): def clip_over_vec(self, ref_vec):
""" """
...@@ -107,7 +109,7 @@ class Source(pyotb.Output): ...@@ -107,7 +109,7 @@ class Source(pyotb.Output):
"mode": "fit", "mode": "fit",
"mode.fit.vec": ref_vec})) "mode.fit.vec": ref_vec}))
def reproject(self, epsg, interpolator="nn"): def reproject(self, epsg, interpolator="bco"):
""" """
Reproject the source into the specified EPSG Reproject the source into the specified EPSG
:param epsg: EPSG (int) :param epsg: EPSG (int)
......
Supports Markdown
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