Skip to content

Commit

Permalink
Update names
Browse files Browse the repository at this point in the history
  • Loading branch information
dindiarto committed Jun 24, 2024
1 parent cd98b6a commit dcc6e82
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: ALSA
Title: Agricultural Land Suitability Analysis (ALSA)
Package: LaSEM
Title: Land Suitability Evaluation Module (LaSEM)
Version: 0.0.0.9000
Authors@R:
person("Dony", "Indiarto", , "d.indiarto@cifor-icraf.org", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9546-8201"))
Description: The Agricultural Land Suitability Analysis (ALSA) is a modular R-based Shiny app for decision-support system for producing and sourcing agricultural commodities. The first version of the Shiny app aims for the suitability analysis for the biophysical factors. The application guides users in collecting and preparing data to visualize suitability maps of certain crops on an interactive map, thus bundling the workflows into a single, streamlined interface. The main feature of ALSA is its spatially-explicit functionality and streamlined interface which allows it to automatically evaluate land suitability based on biophysical factors of specific areas using the FAO framework. This application is built upon the theory of land evaluation and suitability assessment (i.e., FAO 1976, 2007).
Description: Land Suitability Evaluation Module (LaSEM) is a modular R-based Shiny app for decision-support system for producing land suitability maps of food, horticulture, and estate crop commodities. The first version of the Shiny app aims for the suitability analysis for the biophysical factors. The application guides users in collecting and preparing data to visualize suitability maps of certain crops on an interactive map, thus bundling the workflows into a single, streamlined interface. The main feature of LaSEM is its spatially-explicit functionality and streamlined interface which allows it to automatically evaluate land suitability based on biophysical factors of specific areas using the FAO framework. This application is built upon the theory of land evaluation and suitability assessment (i.e., FAO 1976, 2007).
License: GPL (>= 3)
Imports:
dplyr,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(ALSA_app)
export(LaSEM_app)
export(classify_and_stack_suitability_factors)
export(classify_suitability_predictors)
export(concat_rasters)
Expand Down
Empty file added R/plot_raster_layers.R
Empty file.
44 changes: 32 additions & 12 deletions R/sm_suitability_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ suitabilityAnalysisUI <- function(id) {
)
),
tabsetPanel(
tabPanel("Suitability Map", leafletOutput(NS(id, "suitabilityMap"))),
tabPanel("Suitability Map", withSpinner(leafletOutput(NS(id, "suitabilityMap")))),
tabPanel("Suitability Map by Factors",
fluidRow(
column(12,
Expand All @@ -40,7 +40,10 @@ suitabilityAnalysisUI <- function(id) {
)
),
tabPanel("Attribute Table", DTOutput(NS(id, "suitabilityPolygon"))),
tabPanel("Download Results", downloadButton(NS(id, "downloadResults"), "Download Results"))
tabPanel("Download Results",
downloadButton(NS(id, "downloadShapefile"), "Download Shapefile"),
downloadButton(NS(id, "downloadRaster"), "Download Raster"),
downloadButton(NS(id, "downloadTable"), "Download Attribute Table"))
)
)
}
Expand Down Expand Up @@ -223,25 +226,42 @@ suitabilityAnalysisServer <- function(id, submittedData) {
datatable(suitability_polygon)
})

# Provide an option to download the suitability analysis results
output$downloadResults <- downloadHandler(
# Provide options to download different sets of files
output$downloadShapefile <- downloadHandler(
filename = function() {
paste("suitability_results", Sys.Date(), ".zip", sep = "_")
paste("suitability_map", Sys.Date(), ".zip", sep = "_")
},
content = function(file) {
# Save the suitability analysis results to a temporary directory
# Save the suitability map to a temporary directory
tempdir <- tempdir()

# Save the suitability map, polygon, and other results to the temporary directory
browser()
suitability_map <- suitabilityResults()$suitability_polygon
write_sf(suitability_map, file.path(tempdir, "suitability_map.shp"))

suitability_by_factors <- suitabilityResults()$suitability_by_factors
writeRaster(suitability_by_factors, file.path(tempdir, "suitability_by_factors.tif"))
st_write(suitability_map, file.path(tempdir, "suitability_map.shp"),
append = FALSE)

# Zip the temporary directory and write it to the specified file
zip(file, tempdir)
}
)

output$downloadRaster <- downloadHandler(
filename = function() {
paste("suitability_by_factors", Sys.Date(), ".tif", sep = "_")
},
content = function(file) {
suitability_by_factors <- suitabilityResults()$suitability_by_factors
writeRaster(suitability_by_factors, file, overwrite = TRUE)
}
)

output$downloadTable <- downloadHandler(
filename = function() {
paste("suitability_attr", Sys.Date(), ".csv", sep = "_")
},
content = function(file) {
suitability_attr <- suitabilityResults()$suitability_attr
write_csv(suitability_attr, file)
}
)
})
}
8 changes: 4 additions & 4 deletions man/ALSA_app.Rd → man/LaSEM_app.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dcc6e82

Please sign in to comment.