Oscarafone77 wrote:
This method doesn't work correctly. I special a cell size of 5, but the raster I got has a cell height of 4.69xxxx, and a cell width of 4.99xxxxx.
Here is my code:
You should have a look at the DotSpatial.Analysis.VectorToRaster.ToRaster method and the parameters it requires and the work is doneHi
Oscar
This method doesn't work correctly. I special a cell size of 5, but the raster I got has a cell height of 4.69xxxx, and a cell width of 4.99xxxxx.
Here is my code:
string shpFile = @"E:\Project\TestData\UpCatchment.shp";
double xMin = 82292.591;
double yMin = 81549.981;
double xMax = 82851.763;
double yMax = 81599.988;
double cellsize = 5;
IFeatureSet fs = FeatureSet.Open(shpFile);
fs.FillAttributes();
fs.DataTable.Columns.Add("myField");
for (int i = 0; i < fs.Features.Count; i++)
{
fs.Features[i].DataRow.BeginEdit();
fs.Features[i].DataRow["myField"] = 1;
fs.Features[i].DataRow.EndEdit();
}
Extent extent = new Extent(new double[] {xMin, yMin, xMax,yMax});
IRaster raster = VectorToRaster.ToRaster(fs, cellsize, "myField", "output.bgd", "", new string[] { }, null);