Landis.Extension.BaseHarvest.PrescriptionMaps.WriteMap C# (CSharp) Method

WriteMap() public method

Writes an output map of prescriptions that harvested each active site.
public WriteMap ( int timestep ) : void
timestep int /// Timestep to use in the map's name. ///
return void
        public void WriteMap(int timestep)
        {
            string path = MapNames.ReplaceTemplateVars(nameTemplate, timestep);
            using (IOutputRaster<ShortPixel> outputRaster = PlugIn.ModelCore.CreateRaster<ShortPixel>(path, PlugIn.ModelCore.Landscape.Dimensions))
            {
                ShortPixel pixel = outputRaster.BufferPixel;
            
                foreach (Site site in PlugIn.ModelCore.Landscape.AllSites)
                {
                    if (site.IsActive) {
                        Prescription prescription = SiteVars.Prescription[site];
                        if (prescription == null)
                            pixel.MapCode.Value = 1;
                        else
                            pixel.MapCode.Value = (short)(prescription.Number + 1);
                    }
                    else {
                        //  Inactive site
                        pixel.MapCode.Value = 0;
                    }
                    outputRaster.WriteBufferPixel();
                }
            }
        }