GenSimPlot: Simulation Plot Generator for QGIS
GenSimPlot is a Python script collection designed for QGIS, aimed at generating simulation plots for various applications, particularly in the context of forestry and environmental modeling. This repository contains scripts for creating and manipulating simulation plots, enhancing their visualization and analysis within the QGIS environment.
- Open QGIS Desktop v. 3.30.1 or later.
- Open the Python console from the toolbar or use Ctrl+Alt+P.
- Use the "Show Editor" button to open the script editor.
- Open "gensimplot.py" in the script editor.
Modify the script to automate the generation of your simulation plots.
# Setup Working Environment
workingDir = "C:\\simulation\\"
fstandShapeFile = "fstand.shp"
fstandIDField = "fstand_id"
simplotIDField = "fstand_id"
# Generate Optimized Simulation Plots into "simplot.shp"
rplots = gensimplot.RectangularSimulationPlot()
rplots.generatePlotsByPositionAndShape(workingDir + fstandShapeFile, fstandIDField, workingDir + "simplot.shp", simplotIDField)
# Create and Extract DEM Points for Simulation Plots (elevation stored in the raster "dem")
points = gensimplot.SimulationPlotVariables()
points.generatePoints(workingDir + "simplot.shp", simplotIDField, workingDir + "simplot_points.shp", simplotIDField, 5)
points.demPoints(workingDir + "simplot.shp", simplotIDField, workingDir + "simplot_points.shp", simplotIDField, workingDir + "dem")
# Extract Slope for the Points and Calculate Mean Slope for Simulation Plots
# Slope is extracted from the raster "slope"
points.valueFromPoints(workingDir + "simplot.shp", simplotIDField, "slopemin", "slopemax", "slopemean", workingDir + "simplot_points.shp", simplotIDField, "slope", workingDir + "slope")
# Extract Temperature at Centroids of Simulation Plots and Assign it to Corresponding Simulation Plot
# Mean temperature is extracted from the raster "mtemper"
points.valueFromCentroid(workingDir + "simplot.shp", "temperature", workingDir + "mtemper")
# Assign Other Required Environmental Variables to Simulation Plots (e.g., aspect, precipitation, solar radiation)