-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use native:zonalstatisticsfb in challenge 3
See r-spatial/qgisprocess#193. Thanks @florisvdh Co-Authored-By: Floris Vanderhaeghe <[email protected]>
- Loading branch information
1 parent
d2776f9
commit d9f3033
Showing
1 changed file
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,16 +149,26 @@ tmax_statistics | |
|
||
# 3 | ||
|
||
qgis_get_argument_specs("native:zonalstatistics") %>% View() | ||
qgis_search_algorithms("zonal") | ||
|
||
qgis_get_output_specs("native:zonalstatistics") | ||
qgis_get_argument_specs("native:zonalstatisticsfb") %>% View() | ||
|
||
zonal_st <- qgis_run_algorithm("native:zonalstatistics", | ||
INPUT_RASTER = land_use, | ||
RASTER_BAND = 1, | ||
INPUT_VECTOR = prot_areas, | ||
STATISTICS = c(8,9)) # Majority, Minority | ||
# Notice that the other algorithm, native:zonalstatistics, is DEPRECATED and | ||
This comment has been minimized.
Sorry, something went wrong. |
||
# works in place: the temporary file contains the solution, but | ||
# is destroyed subsequently. More info in https://github.com/r-spatial/qgisprocess/issues/193 | ||
|
||
zonal_sf_output <- qgis_extract_output(zonal_st, "INPUT_VECTOR") | ||
zonal_st <- sf::st_as_sf(zonal_st) | ||
qgis_get_output_specs("native:zonalstatisticsfb") | ||
|
||
zonalstatisticsfb <- qgis_function("native:zonalstatisticsfb") | ||
|
||
prot_areas_zonal <- zonalstatisticsfb(INPUT = prot_areas, | ||
INPUT_RASTER = land_use, | ||
RASTER_BAND = 1, | ||
COLUMN_PREFIX = "zonal_", # optional, default: "_" | ||
STATISTICS = c("Majority", "Minority")) %>% | ||
qgis_extract_output("OUTPUT") %>% | ||
This comment has been minimized.
Sorry, something went wrong.
florisvdh
Author
Member
|
||
sf::st_as_sf() | ||
|
||
View(prot_areas_zonal) # notice the two new columns: zonal_majority and zonal_minority | ||
|
||
mapview::mapview(prot_areas_zonal, zcol = "zonal_majority") |
Current dev version of {qgisprocess}, as provided by https://inbo.r-universe.dev, will not show this deprecated algorithm anymore, by default. If you'd like to still get it, you need to do
qgis_search_algorithms("zonal", include_deprecated = TRUE)
.