GenSimPlot

GenSimPlot is a QGIS plugin designed and developed for generating spatially optimized plots used in the simulation and analysis of geographic processes. Plugin enable to create squared, circular, rectangular, and eliptical plots maximazing overlap with the source polygons, enhancing the accuracy and representativeness of simulations.

By automating plot generation, point grid creation, and raster data extraction, GenSimPlot enhances spatial analysis workflows within QGIS, making it a versatile tool for both research and applied geographic studies.

GenSimPlot is designed to support a wide range of spatial analysis and simulation tasks, including:

Key Features

Plot Shape Generation

Regular Point Grid Creation

Raster Data Extraction

Technical Requirements

GenSimPlot is developed as a QGIS plugin and requires QGIS version 3.0 or higher to run. The plugin is written in Python and uses the PyQt5 library for the user interface. The plugin is compatible with Windows, macOS, and Linux operating systems.

Installation

GenSimPlot can be installed from the QGIS Plugin Repository or by downloading the source code from the GitHub repository.

The plugin will be available in the QGIS Vector menu after installation.

License

The plugin is licensed under the EUPL v1.2 (European Union Public License).

Generate Simulation Plots

The "Generate Simulation Plots" dialog provides an interface for creating simulation plots over a selected set of polygons from an input shapefile.
This tool supports generating various plot shapes — such as squares, circles, rectangles, and ellipses — with configurable positioning and placement options to align each plot with the underlying geometry of the polygon.
This dialog enables flexible plot positioning based on attributes like the bounding box, centroid, and mean coordinates of each polygon.
Additionally, random transformations such as translations, rotations, and resizing can be applied to maximize spatial overlap with source polygons, improving representativeness for spatial analyses.

Parameters:

Example of generated square simulation plots with optimal spatial placement for maximal overlap with source polygons:

Example of generated simulation plots optimized using the 'best' option:

Generate Point Grids for Simulation Plots

The "Generate Point Grids for Simulation Plots" dialog allows users to create a regular grid of points over the bounding rectangle of each simulation plot in a selected shapefile.
The grid can be customized in density and alignment, with an option to clip points to fit precisely within the plot boundaries.
Users can select an input shapefile containing simulation plots, specify the number of points along the shorter side of the bounding rectangle to control grid density, and define an output shapefile to store the generated points.
The grid aligns with each plot’s transformation, ensuring accurate representation within simulation plot geometries.

Parameters:

Example of a regularly spaced point grid generated within square simulation plots:

Example of a point grid generated within simulation plots optimized using the 'best' option:

Raster Value Statistics by Plot Points

The "Raster Value Statistics by Plot Points" dialog enables users to calculate summary statistics of raster values for multiple points within each simulation plot.
Users can specify an input shapefile containing simulation plots, a shapefile with points positioned inside each plot, and a raster file representing an environmental variable.
After setup, the dialog extracts raster values at each point within the plots and calculates summary statistics (minimum, maximum, and mean) for each plot.
These statistics are then stored in the simulation plot attribute table as new fields.

Parameters:

Raster Value by Plot Centroid

The "Extract Values By Centroid" dialog allows users to extract raster values at the centroids of simulation plots stored in an input shapefile.
Users can specify both an input simulation plot shapefile and a raster file, and designate an output field where the extracted raster values will be saved in the simulation plot attribute table.
This dialog simplifies the assignment of spatially relevant raster data to simulation plots, enabling efficient and accurate data integration for analysis.

Parameters:

Scripting

The GenSimPlot library provides classes and functions for automating the generation of simulation plots, creation of point grids, and extraction of raster values.
These tools can be executed from the QGIS Python console or integrated into custom Python workflows for streamlined spatial analysis.

Example usage of GenSimPlotLib classes:

            
                from GenSimPlotLib import PlotGenerator, PointsGenerator, SimulationPlotVariables
                from GenSimPlotUtilities import GProgressDialog

                #Initialize the progress dialog
                progressDlg = GProgressDialog()
                progressDlg.show()

                #Define input parameters
                workingFolder = "c:\\data\\"
                inputShp = workingFolder + "forest_stands.shp"
                polygonID = "id"
                plotsShp = workingFolder + "plots.shp"
                pointsShp = workingFolder + "points.shp"
                nPoints = 10
                clipPoints = True
                demRaster = workingFolder + "dem\\dem"
                slopeRaster = workingFolder + "dem\\slope"

                #Generate optimized simulation plots
                plotGen = PlotGenerator()
                plotGen.generateBestPlots(inputShp, polygonID, plotsShp, progressDlg)

                #Generate a grid of points within the plots
                pointsGen = SimulationPlotVariables()
                pointsGen.generatePoints(plotsShp, polygonID, pointsShp, nPoints, clipPoints, progressDlg)

                #Extract raster values for each point within plots and calculate plot-level statistics
                rasterStats = SimulationPlotVariables()
                rasterStats.valueFromPoints(plotsShp, polygonID, pointsShp, "elev", demRaster, progressDlg)

                #Extract raster values for each plot centroid
                rasterCentroid = SimulationPlotVariables()
                rasterCentroid.valueFromCentroid(plotsShp, "slope", slopeRaster, progressDlg)

                #Close the progress dialog
                progressDlg.close()