Skip to content

Commit

Permalink
Change pc style to new style (#21)
Browse files Browse the repository at this point in the history
* strds sampling change pc style

* linting

* strds sampling geojson change pc style

* strds sampling area change pc style

* change pc styles and add superquiet

* raster_area_stats_univar new style

* examples

* remove old pc style

* remove old pc style

Co-authored-by: anikaweinmann <[email protected]>
  • Loading branch information
anikaweinmann and anikaweinmann authored Nov 24, 2022
1 parent 0bc7f2b commit 22aa8c8
Show file tree
Hide file tree
Showing 10 changed files with 1,093 additions and 608 deletions.
6 changes: 3 additions & 3 deletions examples/area2.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"coordinates": [
[
[635000.0, 220000.0],
[637000.0, 220000.0],
[637000.0, 221000.0],
[635000.0, 221000.0],
[635000.0, 225000.0],
[640000.0, 225000.0],
[640000.0, 220000.0],
[635000.0, 220000.0]
]
]
Expand Down
93 changes: 64 additions & 29 deletions src/actinia_statistic_plugin/ephemeral_raster_area_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,17 @@ def _execute(self):
dir=self.temp_file_path, delete=False
)

pc = {}
pc["1"] = {
"module": "v.import",
"inputs": {"input": gml_file.name},
"outputs": {"output": {"name": "polygon"}},
"superquiet": True,
pc = {
"list": [
{
"id": "v_import_1",
"module": "v.import",
"inputs": [{"param": "input", "value": gml_file.name}],
"outputs": [{"param": "output", "value": "polygon"}],
"superquiet": True
},
],
"version": "1",
}

# Run the import, ignore region settings
Expand All @@ -192,29 +197,59 @@ def _execute(self):
)
self._execute_process_list(process_list)

pc = {}
pc["2"] = {
"module": "g.region",
"inputs": {
"vector": "polygon",
"align": raster_name + "@" + self.mapset_name,
},
"flags": "p",
}
pc["3"] = {
"module": "r.mask",
"inputs": {"vector": "polygon"},
"superquiet": True,
}
pc["4"] = {
"module": "r.stats",
"inputs": {
"input": raster_name + "@" + self.mapset_name,
"separator": "|",
},
"outputs": {"output": {"name": result_file.name}},
"flags": "acpl",
"superquiet": True,
pc = {
"list": [
{
"id": "g_region_2",
"module": "g.region",
"inputs": [
{
"param": "vector",
"value": "polygon"
},
{
"param": "align",
"value": raster_name + "@" + self.mapset_name
}
],
"flags": "p",
"superquiet": True
},
{
"id": "r_mask_3",
"module": "r.mask",
"inputs": [
{
"param": "vector",
"value": "polygon"
}
],
"superquiet": True
},
{
"id": "r_stats_4",
"module": "r.stats",
"inputs": [
{
"param": "input",
"value": raster_name + "@" + self.mapset_name
},
{
"param": "separator",
"value": "|"
}
],
"outputs": [
{
"param": "output",
"value": result_file.name
}
],
"flags": "acpl",
"superquiet": True
},
],
"version": "1",
}

# Run the area statistics and check for correct region settings
Expand Down
106 changes: 77 additions & 29 deletions src/actinia_statistic_plugin/ephemeral_raster_area_stats_univar.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,27 @@ def _execute(self):
dir=self.temp_file_path, delete=True
)

pc = dict()
pc["1"] = {
"module": "v.import",
"inputs": {"input": gml_file.name},
"outputs": {"output": {"name": "polygon"}},
"superquiet": True,
pc = {
"list": [
{
"id": "v_import_1",
"module": "v.import",
"inputs": [
{
"param": "input",
"value": gml_file.name,
},
],
"outputs": [
{
"param": "output",
"value": "polygon",
}
],
"superquiet": True
},
],
"version": "1",
}

# Run the selected modules
Expand All @@ -187,29 +202,62 @@ def _execute(self):
)
self._execute_process_list(process_list)

pc = dict()
pc["2"] = {
"module": "g.region",
"inputs": {"vector": "polygon"},
"flags": "p",
}

pc["3"] = {
"module": "v.rast.stats",
"inputs": {
"map": "polygon",
"method": "number,minimum,maximum,range,average,median,stddev,"
"sum,variance,coeff_var",
"raster": raster_name + "@" + self.mapset_name,
"column_prefix": "raster",
},
"superquiet": True,
}

pc["4"] = {
"module": "v.db.select",
"inputs": {"map": "polygon"},
"outputs": {"file": {"name": result_file.name}},
pc = {
"list": [
{
"id": "g_region_2",
"module": "g.region",
"inputs": [
{
"param": "vector",
"value": "polygon",
},
],
"flags": "p",
},
{
"id": "v_rast_stats_3",
"module": "v.rast.stats",
"inputs": [
{
"param": "map",
"value": "polygon",
},
{
"param": "method",
"value": "number,minimum,maximum,range,average,"
"median,stddev,sum,variance,coeff_var",
},
{
"param": "raster",
"value": raster_name + "@" + self.mapset_name
},
{
"param": "column_prefix",
"value": "raster"
},
],
"superquiet": True
},
{
"id": "v_db_select_4",
"module": "v.db.select",
"inputs": [
{
"param": "map",
"value": "polygon",
},
],
"outputs": [
{
"param": "file",
"value": result_file.name,
},
],
"superquiet": True
},
],
"version": "1",
}

# Run the area statistics and check for correct region settings
Expand Down
Loading

0 comments on commit 22aa8c8

Please sign in to comment.