This project is read-only.

Create new Raster Layer

Oct 4, 2010 at 8:32 AM

Hello,

I would like to create new raster layer in order to add this layer into my aplication. I would like to create raster with values=2 with size 1098x725 and cellsize=500m 

I try it with this code:

       
   double xllcorner = 3267132.224761;
            double yllcorner = 5326939.203029;
            int ncols = 1098;
            int nrows = 725;
            double cellsize = 500;
            double x2 = xllcorner + (cellsize * ncols);
            double y2 = yllcorner + (cellsize * nrows);
            DotSpatial.Topology.IEnvelope myExtent = new DotSpatial.Topology.Envelope(xllcorner, x2, yllcorner, y2);
            DotSpatial.Data.Raster output = new DotSpatial.Data.Raster();
            output.CreateNew(@"D:\test.BGD", "", ncols, nrows, 1, typeof(double), new[] { "" });
            output.Bounds = new RasterBounds(nrows,ncols,myExtent);

            output.NoDataValue = -9999;
            int mRow = output.Bounds.NumRows;
            int mCol = output.Bounds.NumColumns;
            
             // fill all cells to value=2 only for testing
           for (int row = 0; row < mRow; row++)
            {
                for (int col = 0; col < mCol; col++)
                {
                    output.Value[row, col] = 2d;
                    
                   
                }
            }
         //   output.Save();

            double v = output.Value[10,10];  // Exception occured here
            
           
Thank you for any help.

Martin




Oct 4, 2010 at 4:21 PM

This is probably a bug.  I will post this to the issue list and see if we can't replicate the error and get to the bottom of it.  Thanks for reporting this.

Ted