-
Notifications
You must be signed in to change notification settings - Fork 0
fsm python Tute 3 Graphics Renderer
Often, it is important to allow the user to view the grid data in the context of the paddocks. This will allow the user to make decisions about what layers to data in the tools. For instance, if there is not much variation in the elevation, the user may decide not to use that layer as it is unlikely to provide any utility to the analysis.
In this tutorial, we will create images of NDVI and elevation. This tutorial follows on from the previous tutorial where we learnt how to make a paddock.
In this lesson, we will learn about the "buildResult" and how to use it to create images. Generally, the tools and processors will produce build results as their outputs and they can cover a range of output information, including sample locations and layer data. The buildResults are used by the GraphicsRenderer tool to produce images.
We can convert a paddock to a PaddockBuildResult using the paddockToPaddockBuildResult function:
from fsm.utils.paddockConverters import paddockToPaddockBuildResult
p_brs = [paddockToPaddockBuildResult(p) for p in paddocks]Now we can add these build results to the GraphicsRenderer tool:
from fsm.graphicsRenderer import GraphicsRenderer
gr = GraphicsRenderer(p_brs)To run each tool, we use the .build() method which takes a corresponding config object. Here we will learn about the GradientConfig and how to adjust the settings to get the desired result. The gradient config has the following inputs
-
attribute: str - name of theLayerin the paddock -
gradient: Gradient - the type of color graident to use -
output_dir: str - where to save the file -
fit_to_data: bool = field(default=False) - ifTruethe graident will be stretched to fit the range of the values
from fsm.models.gradients import farmSoilMappingGradients
grad = farmSoilMappingGradients.NDVI
graphics_config = GradientConfig(
attribute=NDVI,
gradient=grad,
output_dir="./tests/temp",
fit_to_data=True)Finally, we run the GraphicsRenderer using the .build method.
gr.build(graphics_config) To provide a user with meaningful data, you will need some metadata about the output. This can be found in the stats property of the buildResults. The stats object includes:
# Take one br for instance
br = p_brs[0].buildResults[0]
br.paddock_id
br.uid
br.stats.max #attribute value
br.stats.min #attribute value
br.stats.max_lat
br.stats.min_lat
br.stats.max_lon
br.stats.min_lonFrom this metadata, you can create your bounding box and provide the user with range information.
You may also want to get the colors of the value ranges:
RGB
grad.get(br.stats.max)
grad.get(br.stats.min)HEX
grad.get_hex(br.stats.max)
grad.get_hex(br.stats.min)This will output the following dirs and files:
- [name]
- boundary geojson files
- [method]
- geojson
- svg
- png
- npy (for numpy)
- colors json
- stats json
- error geojson(s) -if applicable-
Paper: A conditioned Latin hypercube method for sampling in the presence of ancillary information
Minasny, Budiman, and Alex B. McBratney. 2006. “A Conditioned Latin Hypercube Method for Sampling in the Presence of Ancillary Information.” Computers & Geosciences 32 (9): 1378–88.
Paper: Predicting and Mapping the Soil Available Water Capacity of Australian Wheatbelt.
Padarian, J., B. Minasny, A. B. McBratney, and N. Dalgliesh. 2014. “Predicting and Mapping the Soil Available Water Capacity of Australian Wheatbelt.” Geoderma Regional 2-3 (November): 110–18.
Paper (non-journaled thesis): Provision of soil water retention information for biophysical modelling: an example for Australia
Padarian, J. 2014. "Provision of soil water retention information for biophysical modelling: an example for Australia". Provision of soil information for biophysical modelling: 19-50. Faculty of Agriculture and Environment. The University of Sydney
Paper: Inverse meta-modelling to estimate soil available water capacity at high spatial resolution across a farm
Florin, M. J., A. B. McBratney, B. M. Whelan, and B. Minasny. 2011. “Inverse Meta-Modelling to Estimate Soil Available Water Capacity at High Spatial Resolution across a Farm.” Precision Agriculture 12 (3): 421–38.
Paper: Modelling soil attribute depth functions with equal-area quadratic smoothing splines
Bishop, T. F. A., A. B. McBratney, and G. M. Laslett. 1999. “Modelling Soil Attribute Depth Functions with Equal-Area Quadratic Smoothing Splines.” Geoderma 91 (1): 27–45.
Paper: Validation of digital soil maps at different spatial supports
Bishop, T. F. A., A. Horta, and S. B. Karunaratne. 2015. “Validation of Digital Soil Maps at Different Spatial Supports.” Geoderma 241-242 (March): 238–49.
Paper: Boundaryline analysis of fieldscale yield response to soil properties
Shatar, T. M., and A. B. McBratney. 2004. “Boundary-Line Analysis of Field-Scale Yield Response to Soil Properties.” The Journal of Agricultural Science 142: 553.
Paper: A segmentation algorithm for the delineation of agricultural management zones
Pedroso, Moacir, James Taylor, Bruno Tisseyre, Brigitte Charnomordic, and Serge Guillaume. 2010. “A Segmentation Algorithm for the Delineation of Agricultural Management Zones.” Computers and Electronics in Agriculture 70 (1): 199–208.
Paper: Spatially explicit seasonal forecasting using fuzzy spatiotemporal clustering of long-term daily rainfall and temperature data
Plain, M. B., B. Minasny, A. B. McBratney, and R. W. Vervoort. 2008. “Spatially Explicit Seasonal Forecasting Using Fuzzy Spatiotemporal Clustering of Long-Term Daily Rainfall and Temperature Data.” https://hal.archives-ouvertes.fr/hal-00298949/.
Paper: Spatiotemporal monthly rainfall forecasts for south-eastern and eastern Australia using climatic indices
Montazerolghaem, Maryam, Willem Vervoort, Budiman Minasny, and Alex McBratney. 2016. “Spatiotemporal Monthly Rainfall Forecasts for South-Eastern and Eastern Australia Using Climatic Indices.” Theoretical and Applied Climatology 124 (3): 1045–63.