This module provides a set of functions for pyotb.
all(*inputs)
¶
Check if value is different than 0 everywhere along the band axis.
For only one image, this function checks that all bands of the image are True (i.e. !=0) and outputs a singleband boolean raster For several images, this function checks that all images are True (i.e. !=0) and outputs a boolean raster, with as many bands as the inputs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
inputs can be 1) a single image or 2) several images, either passed as separate arguments or inside a list |
required |
Returns:
Type | Description |
---|---|
AND intersection |
Source code in pyotb/functions.py
any(*inputs)
¶
Check if value is different than 0 anywhere along the band axis.
For only one image, this function checks that at least one band of the image is True (i.e. !=0) and outputs a single band boolean raster For several images, this function checks that at least one of the images is True (i.e. !=0) and outputs a boolean raster, with as many bands as the inputs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
inputs can be 1) a single image or 2) several images, either passed as separate arguments or inside a list |
required |
Returns:
Type | Description |
---|---|
OR intersection |
Source code in pyotb/functions.py
clip(a, a_min, a_max)
¶
Clip values of image in a range of values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
input raster, can be filepath or any pyotb object |
required | |
a_min |
minimum value of the range |
required | |
a_max |
maximum value of the range |
required |
Returns:
Type | Description |
---|---|
raster whose values are clipped in the range |
Source code in pyotb/functions.py
define_processing_area(*args, window_rule='intersection', pixel_size_rule='minimal', interpolator='nn', reference_window_input=None, reference_pixel_size_input=None)
¶
Given several inputs, this function handles the potential resampling and cropping to same extent.
WARNING: Not fully implemented / tested
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
list of raster inputs. Can be str (filepath) or pyotb objects |
()
|
|
window_rule |
Can be 'intersection', 'union', 'same_as_input', 'specify' (Default value = 'intersection') |
'intersection'
|
|
pixel_size_rule |
Can be 'minimal', 'maximal', 'same_as_input', 'specify' (Default value = 'minimal') |
'minimal'
|
|
interpolator |
Can be 'bco', 'nn', 'linear' (Default value = 'nn') |
'nn'
|
|
reference_window_input |
Required if window_rule = 'same_as_input' (Default value = None) |
None
|
|
reference_pixel_size_input |
Required if pixel_size_rule = 'same_as_input' (Default value = None) |
None
|
Returns:
Type | Description |
---|---|
list of in-memory pyotb objects with all the same resolution, shape and extent |
Source code in pyotb/functions.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
|
run_tf_function(func)
¶
This function enables using a function that calls some TF operations, with pyotb object as inputs.
For example, you can write a function that uses TF operations like this : ```python @run_tf_function def multiply(input1, input2): import tensorflow as tf return tf.multiply(input1, input2)
# Then you can use the function like this :
result = multiply(pyotb_object1, pyotb_object1) # this is a pyotb object
```
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
function taking one or several inputs and returning one output |
required |
Returns:
Name | Type | Description |
---|---|---|
wrapper | a function that returns a pyotb object |
Source code in pyotb/functions.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
where(cond, x, y)
¶
Functionally similar to numpy.where. Where cond is True (!=0), returns x. Else returns y.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cond |
condition, must be a raster (filepath, App, Operation...). If cond is monoband whereas x or y are multiband, cond channels are expanded to match x & y ones. |
required | |
x |
value if cond is True. Can be float, int, App, filepath, Operation... |
required | |
y |
value if cond is False. Can be float, int, App, filepath, Operation... |
required |
Returns:
Type | Description |
---|---|
an output where pixels are x if cond is True, else y |