pysits 1.5.3.dev0__tar.gz → 1.5.3.dev2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/PKG-INFO +4 -2
  2. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/README.md +3 -1
  3. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pyproject.toml +1 -1
  4. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/__init__.py +8 -3
  5. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/backend/loaders.py +18 -3
  6. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/backend/pkgs.py +11 -10
  7. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/tibble_arrow.py +5 -1
  8. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/settings.py +6 -1
  9. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/context.py +5 -7
  10. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/cube.py +6 -0
  11. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/ml.py +2 -0
  12. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/tiles.py +7 -0
  13. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/utils.py +1 -1
  14. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/visualization/base.py +2 -1
  15. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_models.py +2 -0
  16. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/uv.lock +1 -1
  17. pysits-1.5.3.dev0/examples/apply.py +0 -80
  18. pysits-1.5.3.dev0/examples/classification.py +0 -120
  19. pysits-1.5.3.dev0/examples/cube-copy.py +0 -58
  20. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2013-09-14.jp2 +0 -0
  21. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2013-10-16.jp2 +0 -0
  22. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2013-11-17.jp2 +0 -0
  23. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2013-12-19.jp2 +0 -0
  24. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-01-17.jp2 +0 -0
  25. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-02-18.jp2 +0 -0
  26. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-03-22.jp2 +0 -0
  27. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-04-23.jp2 +0 -0
  28. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-05-25.jp2 +0 -0
  29. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-06-26.jp2 +0 -0
  30. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-07-28.jp2 +0 -0
  31. pysits-1.5.3.dev0/examples/data/cube/TERRA_MODIS_012010_NDVI_2014-08-29.jp2 +0 -0
  32. pysits-1.5.3.dev0/examples/data/samples/samples_deforestation.rds +0 -0
  33. pysits-1.5.3.dev0/examples/data/samples/samples_sinop_crop.csv +0 -19
  34. pysits-1.5.3.dev0/examples/list-collections.py +0 -31
  35. pysits-1.5.3.dev0/examples/predictors.py +0 -37
  36. pysits-1.5.3.dev0/examples/rds.py +0 -37
  37. pysits-1.5.3.dev0/examples/regularization.py +0 -77
  38. pysits-1.5.3.dev0/examples/segmentation.py +0 -114
  39. pysits-1.5.3.dev0/examples/xarray-conversion.py +0 -63
  40. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/.gitattributes +0 -0
  41. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/.github/workflows/ruff.yaml +0 -0
  42. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/.gitignore +0 -0
  43. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/.pre-commit-config.yaml +0 -0
  44. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/LICENSE +0 -0
  45. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/conda/meta.yaml +0 -0
  46. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/backend/__init__.py +0 -0
  47. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/backend/functions.py +0 -0
  48. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/__init__.py +0 -0
  49. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/clojure.py +0 -0
  50. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/common.py +0 -0
  51. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/decorators.py +0 -0
  52. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/dsl/__init__.py +0 -0
  53. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/dsl/base.py +0 -0
  54. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/dsl/mask.py +0 -0
  55. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/dsl/tuning.py +0 -0
  56. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/tibble.py +0 -0
  57. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/vector.py +0 -0
  58. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/conversions/xarray.py +0 -0
  59. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/docs/__init__.py +0 -0
  60. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/docs/content/sits_get_data.md +0 -0
  61. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/docs/decorators.py +0 -0
  62. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/extras/__init__.py +0 -0
  63. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/extras/earthdatalogin.py +0 -0
  64. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/extras/torch.py +0 -0
  65. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/jinja.py +0 -0
  66. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/__init__.py +0 -0
  67. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/base.py +0 -0
  68. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/__init__.py +0 -0
  69. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/accuracy.py +0 -0
  70. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/base.py +0 -0
  71. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/cube.py +0 -0
  72. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/frame.py +0 -0
  73. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/frame_accessor.py +0 -0
  74. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/matrix.py +0 -0
  75. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/table.py +0 -0
  76. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/ts.py +0 -0
  77. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/tuning.py +0 -0
  78. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/data/vector.py +0 -0
  79. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/frame.py +0 -0
  80. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/ml.py +0 -0
  81. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/models/resolver.py +0 -0
  82. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/__init__.py +0 -0
  83. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/classification.py +0 -0
  84. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/colors.py +0 -0
  85. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/config.py +0 -0
  86. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/data.py +0 -0
  87. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/exporters/__init__.py +0 -0
  88. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/exporters/files.py +0 -0
  89. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/exporters/sf.py +0 -0
  90. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/exporters/xarray.py +0 -0
  91. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/impute.py +0 -0
  92. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/segment.py +0 -0
  93. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/ts.py +0 -0
  94. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/tuning.py +0 -0
  95. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/sits/visualization.py +0 -0
  96. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/templates/cube.html +0 -0
  97. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/templates/tuning.html +0 -0
  98. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/visualization/__init__.py +0 -0
  99. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/visualization/image.py +0 -0
  100. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/visualization/leaflet.py +0 -0
  101. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/pysits/visualization/tmap.py +0 -0
  102. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/conftest.py +0 -0
  103. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_classification.py +0 -0
  104. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_conversions.py +0 -0
  105. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_cube.py +0 -0
  106. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_data.py +0 -0
  107. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_dsl.py +0 -0
  108. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_extras.py +0 -0
  109. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_geopandas.py +0 -0
  110. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_indexing.py +0 -0
  111. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_tiles.py +0 -0
  112. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_utils.py +0 -0
  113. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_validation.py +0 -0
  114. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_visualization.py +0 -0
  115. {pysits-1.5.3.dev0 → pysits-1.5.3.dev2}/tests/test_xarray.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pysits
3
- Version: 1.5.3.dev0
3
+ Version: 1.5.3.dev2
4
4
  Summary: Python wrapper for the sits R package
5
5
  Project-URL: Homepage, https://github.com/e-sensing/pysits
6
6
  Project-URL: Issue Tracker, https://github.com/e-sensing/pysits/issues
@@ -56,6 +56,8 @@ or the development version:
56
56
  pip install git+https://github.com/e-sensing/pysits.git
57
57
  ```
58
58
 
59
+ > To use `pysits`, you must have [sits](https://github.com/e-sensing/sits) installed. For more information, refer to the [official sits documentation](https://e-sensing.github.io/sitsbook/setup.html).
60
+
59
61
  ## 🛠 Development setup (for contributors)
60
62
 
61
63
  To set up a local development environment:
@@ -108,7 +110,7 @@ ruff check .
108
110
 
109
111
  ## 📚 Learn more
110
112
 
111
- Explore the [examples](./examples) directory for usage demos and tutorials.
113
+ To learn all about `sits`, including its concepts, API, and real-world examples, we recommend accessing the [official sits book](https://e-sensing.github.io/sitsbook/). The book provides examples in both R and Python.
112
114
 
113
115
  ## 🤝 Contributing
114
116
 
@@ -16,6 +16,8 @@ or the development version:
16
16
  pip install git+https://github.com/e-sensing/pysits.git
17
17
  ```
18
18
 
19
+ > To use `pysits`, you must have [sits](https://github.com/e-sensing/sits) installed. For more information, refer to the [official sits documentation](https://e-sensing.github.io/sitsbook/setup.html).
20
+
19
21
  ## 🛠 Development setup (for contributors)
20
22
 
21
23
  To set up a local development environment:
@@ -68,7 +70,7 @@ ruff check .
68
70
 
69
71
  ## 📚 Learn more
70
72
 
71
- Explore the [examples](./examples) directory for usage demos and tutorials.
73
+ To learn all about `sits`, including its concepts, API, and real-world examples, we recommend accessing the [official sits book](https://e-sensing.github.io/sitsbook/). The book provides examples in both R and Python.
72
74
 
73
75
  ## 🤝 Contributing
74
76
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  [project]
19
19
  name = "pysits"
20
- version = "1.5.3.dev0"
20
+ version = "1.5.3.dev2"
21
21
  description = "Python wrapper for the sits R package"
22
22
  readme = "README.md"
23
23
  requires-python = ">=3.10,<4"
@@ -42,6 +42,7 @@ from .sits.cube import (
42
42
  sits_confidence_sampling,
43
43
  sits_cube,
44
44
  sits_cube_copy,
45
+ sits_mosaic,
45
46
  sits_reclassify,
46
47
  sits_regularize,
47
48
  sits_texture,
@@ -71,6 +72,7 @@ from .sits.ml import (
71
72
  sits_formula_linear,
72
73
  sits_formula_logref,
73
74
  sits_kfold_validate,
75
+ sits_lightgbm,
74
76
  sits_lighttae,
75
77
  sits_mlp,
76
78
  sits_model_export,
@@ -83,7 +85,7 @@ from .sits.ml import (
83
85
  sits_xgboost,
84
86
  )
85
87
  from .sits.segment import sits_segment, sits_slic
86
- from .sits.tiles import sits_mgrs_to_roi, sits_tiles_to_roi
88
+ from .sits.tiles import sits_mgrs_to_roi, sits_roi_to_tiles, sits_tiles_to_roi
87
89
  from .sits.ts import (
88
90
  sits_cluster_clean,
89
91
  sits_cluster_dendro,
@@ -113,7 +115,7 @@ from .sits.ts import (
113
115
  )
114
116
  from .sits.tuning import sits_tuning, sits_tuning_hparams
115
117
  from .sits.utils import (
116
- load_samples_dataset,
118
+ load_samples,
117
119
  r_package_dir,
118
120
  r_set_seed,
119
121
  read_rds,
@@ -140,6 +142,7 @@ __all__ = (
140
142
  "sits_confidence_sampling",
141
143
  "sits_variance",
142
144
  "sits_texture",
145
+ "sits_mosaic",
143
146
  # Colors
144
147
  "sits_colors",
145
148
  "sits_colors_reset",
@@ -175,6 +178,7 @@ __all__ = (
175
178
  "sits_lighttae",
176
179
  "sits_svm",
177
180
  "sits_xgboost",
181
+ "sits_lightgbm",
178
182
  "sits_tae",
179
183
  "sits_kfold_validate",
180
184
  "sits_model_export",
@@ -209,6 +213,7 @@ __all__ = (
209
213
  # Tiles
210
214
  "sits_mgrs_to_roi",
211
215
  "sits_tiles_to_roi",
216
+ "sits_roi_to_tiles",
212
217
  # Segments
213
218
  "sits_segment",
214
219
  "sits_slic",
@@ -237,7 +242,7 @@ __all__ = (
237
242
  "read_rds",
238
243
  "r_package_dir",
239
244
  "r_set_seed",
240
- "load_samples_dataset",
245
+ "load_samples",
241
246
  # Package settings
242
247
  "__version__",
243
248
  )
@@ -20,10 +20,25 @@
20
20
  from collections.abc import Callable
21
21
  from typing import Any
22
22
 
23
- from rpy2.robjects import r
23
+ from rpy2.robjects import r as rpy2_r_interface
24
24
  from rpy2.robjects.packages import importr
25
25
 
26
26
 
27
+ def load_package(name: str, min_version: str | None = None) -> Any:
28
+ """Load R package."""
29
+ if min_version:
30
+ has_min_version = rpy2_r_interface(
31
+ f'packageVersion("{name}") >= "{min_version}"'
32
+ )
33
+
34
+ if not has_min_version[0]:
35
+ raise RuntimeError(
36
+ f"`{name}` must have at least version {min_version} or greater."
37
+ )
38
+
39
+ return importr(name)
40
+
41
+
27
42
  def load_data_from_package(name: str, package: str, **kwargs) -> object:
28
43
  """Load data from package.
29
44
 
@@ -36,7 +51,7 @@ def load_data_from_package(name: str, package: str, **kwargs) -> object:
36
51
 
37
52
  **kwargs: Additional arguments to pass to the function.
38
53
  """
39
- return r.data(name, package=package, **kwargs)
54
+ return rpy2_r_interface.data(name, package=package, **kwargs)
40
55
 
41
56
 
42
57
  def load_data_from_global(name: str) -> object:
@@ -47,7 +62,7 @@ def load_data_from_global(name: str) -> object:
47
62
  Args:
48
63
  name (str): Dataset name.
49
64
  """
50
- return r[name]
65
+ return rpy2_r_interface[name]
51
66
 
52
67
 
53
68
  def load_function_from_package(name: str) -> Callable[..., Any]:
@@ -17,19 +17,20 @@
17
17
 
18
18
  """backend packages."""
19
19
 
20
- from rpy2.robjects.packages import importr
20
+ from pysits.backend.loaders import load_package
21
+ from pysits.settings import __sitsver__
21
22
 
22
23
  # system pakage
23
- r_pkg_base = importr("base")
24
- r_pkg_grdevices = importr("grDevices")
24
+ r_pkg_base = load_package("base")
25
+ r_pkg_grdevices = load_package("grDevices")
25
26
 
26
27
  # sits package
27
- r_pkg_sits = importr("sits")
28
+ r_pkg_sits = load_package("sits", min_version=__sitsver__)
28
29
 
29
30
  # sits-dependencies packages
30
- r_pkg_tibble = importr("tibble")
31
- r_pkg_leaflet = importr("leaflet")
32
- r_pkg_kohonen = importr("kohonen")
33
- r_pkg_sf = importr("sf")
34
- r_pkg_htmlwidgets = importr("htmlwidgets")
35
- r_pkg_arrow = importr("arrow")
31
+ r_pkg_tibble = load_package("tibble")
32
+ r_pkg_leaflet = load_package("leaflet")
33
+ r_pkg_kohonen = load_package("kohonen")
34
+ r_pkg_sf = load_package("sf")
35
+ r_pkg_htmlwidgets = load_package("htmlwidgets")
36
+ r_pkg_arrow = load_package("arrow")
@@ -25,7 +25,7 @@ from pandas import DataFrame as PandasDataFrame
25
25
  from pandas.core.generic import NDFrame as PandasNDFrame
26
26
  from pyarrow import feather
27
27
  from rpy2.rinterface_lib.sexp import NULLType
28
- from rpy2.robjects import StrVector
28
+ from rpy2.robjects import StrVector, pandas2ri
29
29
  from rpy2.robjects import globalenv as rpy2_globalenv
30
30
  from rpy2.robjects import r as rpy2_r_interface
31
31
  from rpy2.robjects.vectors import DataFrame as RDataFrame
@@ -160,6 +160,10 @@ def _tibble_to_pandas_arrow(
160
160
  tmp_path = tmp.name
161
161
  tmp.close()
162
162
 
163
+ # Check if instance is a empty
164
+ if instance.nrow == 0:
165
+ return pandas2ri.rpy2py(instance)
166
+
163
167
  # Extract columns from the data
164
168
  data_columns = r_pkg_base.colnames(instance)
165
169
 
@@ -36,9 +36,14 @@ rpy2.rinterface_lib.callbacks.consolewrite_warnerror = lambda x: None
36
36
  #
37
37
  os.environ["TORCH_INSTALL"] = "0"
38
38
 
39
+ #
40
+ # Compatible sits version
41
+ #
42
+ __sitsver__ = "1.5.3"
43
+
39
44
  #
40
45
  # Package version
41
46
  #
42
- __version__ = "1.5.3.dev0"
47
+ __version__ = "1.5.3"
43
48
 
44
49
  __all__ = ("__version__",)
@@ -17,20 +17,18 @@
17
17
 
18
18
  """Global objects from sits."""
19
19
 
20
- from pysits.sits.utils import load_samples_dataset
20
+ from pysits.sits.utils import load_samples
21
21
 
22
22
  #
23
23
  # Samples objects
24
24
  #
25
- cerrado_2classes = load_samples_dataset("cerrado_2classes", package="sits")
25
+ cerrado_2classes = load_samples("cerrado_2classes", package="sits")
26
26
 
27
- samples_modis_ndvi = load_samples_dataset("samples_modis_ndvi", package="sits")
28
- samples_l8_rondonia_2bands = load_samples_dataset(
29
- "samples_l8_rondonia_2bands", package="sits"
30
- )
27
+ samples_modis_ndvi = load_samples("samples_modis_ndvi", package="sits")
28
+ samples_l8_rondonia_2bands = load_samples("samples_l8_rondonia_2bands", package="sits")
31
29
 
32
30
 
33
31
  #
34
32
  # Points objects
35
33
  #
36
- point_mt_6bands = load_samples_dataset("point_mt_6bands", package="sits")
34
+ point_mt_6bands = load_samples("point_mt_6bands", package="sits")
@@ -72,6 +72,12 @@ def sits_cube_copy(*args, **kwargs) -> SITSCubeModel:
72
72
  """Copy cubes."""
73
73
 
74
74
 
75
+ @function_call(r_pkg_sits.sits_mosaic, SITSCubeModel)
76
+ @attach_doc("sits_mosaic")
77
+ def sits_mosaic(*args, **kwargs) -> SITSCubeModel:
78
+ """Mosaic classified cubes."""
79
+
80
+
75
81
  #
76
82
  # Probability and metrics
77
83
  #
@@ -73,6 +73,8 @@ sits_resnet = closure_factory("sits_resnet", converters=dl_converters)
73
73
  sits_rfor = closure_factory("sits_rfor")
74
74
  sits_svm = closure_factory("sits_svm")
75
75
  sits_xgboost = closure_factory("sits_xgboost")
76
+ sits_lightgbm = closure_factory("sits_lightgbm")
77
+
76
78
 
77
79
  #
78
80
  # Extra parameters - SVM
@@ -20,6 +20,7 @@
20
20
  from pysits.backend.pkgs import r_pkg_sits
21
21
  from pysits.conversions.decorators import function_call
22
22
  from pysits.docs import attach_doc
23
+ from pysits.models.data.frame import SITSFrameSF
23
24
  from pysits.models.data.vector import SITSNamedVector
24
25
 
25
26
 
@@ -33,3 +34,9 @@ def sits_mgrs_to_roi(*args, **kwargs) -> SITSNamedVector:
33
34
  @attach_doc("sits_tiles_to_roi")
34
35
  def sits_tiles_to_roi(*args, **kwargs) -> SITSNamedVector:
35
36
  """Convert tiles to ROI."""
37
+
38
+
39
+ @function_call(r_pkg_sits.sits_roi_to_tiles, SITSFrameSF)
40
+ @attach_doc("sits_roi_to_tiles")
41
+ def sits_roi_to_tiles(*args, **kwargs) -> SITSFrameSF:
42
+ """Find tiles of a given ROI and Grid System."""
@@ -106,7 +106,7 @@ def r_package_dir(content_dir: str, package: str) -> Path | None:
106
106
  return None if not dir_path.exists() else dir_path
107
107
 
108
108
 
109
- def load_samples_dataset(name: str, package: str, **kwargs) -> SITSTimeSeriesModel:
109
+ def load_samples(name: str, package: str, **kwargs) -> SITSTimeSeriesModel:
110
110
  """Load sits data from package.
111
111
 
112
112
  Args:
@@ -104,7 +104,8 @@ def _base_plot(
104
104
  # Assuming a plot is a list of elements, we always have many elements.
105
105
  # Cases where we have a single element indicates that the plot object is
106
106
  # inside a list.
107
- while len(plots) == 1:
107
+ # This is only true when the object is not a ggplot object
108
+ while "ggplot2::ggplot" not in list(plots.rclass) and len(plots) == 1:
108
109
  plots = plots[0]
109
110
 
110
111
  # Create a temporary file
@@ -31,6 +31,7 @@ from pysits.sits.data import sits_labels, sits_select
31
31
  from pysits.sits.ml import (
32
32
  sits_formula_linear,
33
33
  sits_formula_logref,
34
+ sits_lightgbm,
34
35
  sits_lighttae,
35
36
  sits_mlp,
36
37
  sits_model_export,
@@ -55,6 +56,7 @@ ALL_MODELS = [
55
56
  sits_rfor,
56
57
  sits_svm,
57
58
  sits_xgboost,
59
+ sits_lightgbm,
58
60
  ]
59
61
 
60
62
 
@@ -1068,7 +1068,7 @@ wheels = [
1068
1068
 
1069
1069
  [[package]]
1070
1070
  name = "pysits"
1071
- version = "0.0.1"
1071
+ version = "1.5.3.dev1"
1072
1072
  source = { editable = "." }
1073
1073
  dependencies = [
1074
1074
  { name = "geopandas" },
@@ -1,80 +0,0 @@
1
- #
2
- # Copyright (C) 2025 sits developers.
3
- #
4
- # This program is free software; you can redistribute it and/or modify it
5
- # under the terms of the GNU General Public License as published by
6
- # the Free Software Foundation; either version 2 of the License, or
7
- # (at your option) any later version.
8
- #
9
- # This program is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- # GNU General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU General Public License
15
- # along with this program; if not, see <https://www.gnu.org/licenses/>.
16
- #
17
-
18
- """apply example."""
19
-
20
- import os
21
-
22
- from pysits import *
23
-
24
- #
25
- # General definition
26
- #
27
- # Output directory
28
- output_dir = "data/output/apply"
29
-
30
- # Cube directory
31
- cube_dir = "data/cube/"
32
-
33
-
34
- #
35
- # 1. Create directory
36
- #
37
- os.makedirs(output_dir, exist_ok=True)
38
-
39
-
40
- #
41
- # 2. Load cube
42
- #
43
- cube = sits_cube(
44
- source="BDC",
45
- collection="MOD13Q1-6.1",
46
- data_dir=cube_dir,
47
- )
48
-
49
-
50
- #
51
- # 3. Apply
52
- #
53
-
54
- # NDVI Median
55
- cube_apply = sits_apply(
56
- data=cube,
57
- NDVIMEDIAN="w_median(NDVI)",
58
- window_size=5,
59
- output_dir=output_dir,
60
- multicores=4,
61
- )
62
-
63
- # NDVI / 2
64
- cube_apply = sits_apply(
65
- data=cube_apply,
66
- NDVIDIV="NDVI / 2",
67
- window_size=5,
68
- output_dir=output_dir,
69
- multicores=4,
70
- )
71
-
72
- #
73
- # 4. Plot
74
- #
75
-
76
- # NDVI Median
77
- plot(cube_apply, band="NDVIMEDIAN")
78
-
79
- # NDVI / 2
80
- plot(cube_apply, band="NDVIDIV")
@@ -1,120 +0,0 @@
1
- #
2
- # Copyright (C) 2025 sits developers.
3
- #
4
- # This program is free software; you can redistribute it and/or modify it
5
- # under the terms of the GNU General Public License as published by
6
- # the Free Software Foundation; either version 2 of the License, or
7
- # (at your option) any later version.
8
- #
9
- # This program is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- # GNU General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU General Public License
15
- # along with this program; if not, see <https://www.gnu.org/licenses/>.
16
- #
17
-
18
- """classification example."""
19
-
20
- import os
21
-
22
- from pysits import *
23
-
24
- #
25
- # General definition
26
- #
27
-
28
- # Output directory
29
- output_dir = "data/output/classification"
30
-
31
- # Cube directory
32
- cube_dir = "data/cube/"
33
-
34
- # Samples file
35
- samples_file = "data/samples/samples_sinop_crop.csv"
36
-
37
-
38
- #
39
- # 1. Create directory
40
- #
41
- os.makedirs(output_dir, exist_ok=True)
42
-
43
-
44
- #
45
- # 2. Load cube
46
- #
47
- cube = sits_cube(
48
- source="BDC",
49
- collection="MOD13Q1-6.1",
50
- data_dir=cube_dir,
51
- )
52
-
53
- #
54
- # 3. Get cube bands
55
- #
56
- sits_bands(cube)
57
-
58
-
59
- #
60
- # 4. Get cube timeline
61
- #
62
- sits_timeline(cube)
63
-
64
-
65
- #
66
- # 5. Get time series
67
- #
68
- samples_ts = sits_get_data(
69
- cube=cube,
70
- samples=samples_file,
71
- )
72
-
73
-
74
- #
75
- # 6. Train model
76
- #
77
- rfor_model = sits_train(
78
- samples=samples_ts,
79
- ml_method=sits_rfor(),
80
- )
81
-
82
-
83
- #
84
- # 7. Classify cube
85
- #
86
- probs_cube = sits_classify(
87
- data=cube,
88
- ml_model=rfor_model,
89
- output_dir=output_dir,
90
- )
91
-
92
-
93
- #
94
- # 8. Smooth classification
95
- #
96
- bayes_cube = sits_smooth(
97
- cube=probs_cube,
98
- output_dir=output_dir,
99
- )
100
-
101
-
102
- #
103
- # 9. Label classification
104
- #
105
- label_cube = sits_label_classification(
106
- cube=bayes_cube,
107
- output_dir=output_dir,
108
- )
109
-
110
-
111
- #
112
- # 10. Plot
113
- #
114
- plot(label_cube)
115
-
116
-
117
- #
118
- # 11. Classification labels
119
- #
120
- sits_labels(label_cube)
@@ -1,58 +0,0 @@
1
- #
2
- # Copyright (C) 2025 sits developers.
3
- #
4
- # This program is free software; you can redistribute it and/or modify it
5
- # under the terms of the GNU General Public License as published by
6
- # the Free Software Foundation; either version 2 of the License, or
7
- # (at your option) any later version.
8
- #
9
- # This program is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- # GNU General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU General Public License
15
- # along with this program; if not, see <https://www.gnu.org/licenses/>.
16
- #
17
-
18
- """classification example."""
19
-
20
- import os
21
-
22
- from pysits import *
23
-
24
- #
25
- # General definitions
26
- #
27
- output_dir = "data/output/copy"
28
-
29
-
30
- #
31
- # 1. Create directory
32
- #
33
- os.makedirs(output_dir, exist_ok=True)
34
-
35
-
36
- #
37
- # 2. Define cube
38
- #
39
- bdc_cube = sits_cube(
40
- source="BDC",
41
- collection="CBERS-WFI-16D",
42
- tiles=["007004", "007005"],
43
- bands=["B15", "CLOUD"],
44
- start_date="2018-01-01",
45
- end_date="2018-01-12",
46
- )
47
-
48
-
49
- #
50
- # 3. Copy from remote to local
51
- #
52
- cube_local = sits_cube_copy(
53
- cube=bdc_cube,
54
- output_dir=output_dir,
55
- roi=dict(lon_min=-46.5, lat_min=-45.5, lon_max=-15.5, lat_max=-14.6),
56
- multicores=2,
57
- res=250,
58
- )
@@ -1,19 +0,0 @@
1
- id,longitude,latitude,start_date,end_date,label
2
- 1,-55.65931,-11.76267,2013-09-14,2014-08-29,Pasture
3
- 2,-55.64833,-11.76385,2013-09-14,2014-08-29,Pasture
4
- 3,-55.66738,-11.78032,2013-09-14,2014-08-29,Forest
5
- 4,-55.64747,-11.75276,2013-09-14,2014-08-29,Pasture
6
- 5,-55.65742,-11.78788,2013-09-14,2014-08-29,Forest
7
- 6,-55.63168,-11.74771,2013-09-14,2014-08-29,Forest
8
- 7,-55.68369,-11.73679,2013-09-14,2014-08-29,Soy_Corn
9
- 8,-55.69004,-11.73343,2013-09-14,2014-08-29,Soy_Corn
10
- 9,-55.67854,-11.74519,2013-09-14,2014-08-29,Soy_Corn
11
- 10,-55.64215,-11.77595,2013-09-14,2014-08-29,Soy_Corn
12
- 11,-55.63219,-11.77259,2013-09-14,2014-08-29,Soy_Corn
13
- 12,-55.62223,-11.78653,2013-09-14,2014-08-29,Soy_Corn
14
- 13,-55.75218,-11.73225,2013-09-14,2014-08-29,Cerrado
15
- 14,-55.75218,-11.68855,2013-09-14,2014-08-29,Cerrado
16
- 15,-55.68764,-11.61525,2013-09-14,2014-08-29,Cerrado
17
- 16,-55.63614,-11.63110,2013-09-14,2014-08-29,Soy_Corn
18
- 17,-55.37384,-11.71746,2013-09-14,2014-08-29,Soy_Corn
19
- 18,-55.52284,-11.58296,2013-09-14,2014-08-29,Pasture