I am working with the ArcGIS Pro SDK.NET and trying to create a raster dataset from an Esri ASCII Grid (.text) file using the CopyRaster tool.
The input Esri ASCII Grid file follows the standard format, for example:
ncols 1000
nrows 1000
xllcorner 1694348.454673
yllcorner 14700917.952848
cellsize 31.70
NODATA_value -9999
43 2 1 4 5 ...
The problem is that the ASCII Grid format only supports a single cellsize parameter, which results in square pixels. However, my requirement is to create a raster dataset with rectangular pixels (i.e., different cell width and height).
I’ve written the following code to use CopyRaster and create a raster dataset in a file geodatabase:
string inputRaster = @"C:\data\input.txt";
string gdbPath = @"C:\data\output.gdb";
string outputRaster = gdbPath + "\\Raster_1";
var parameters = Geoprocessing.MakeValueArray(
inputRaster,
outputRaster,
"", // config_keyword
null, // background_value
-9999.0, // NODATA value
"NONE", // onebit_to_eightbit
"NONE", // colormap_to_RGB
"", // pixel_type
"NONE", // scale_pixel_value
"NONE", // RGB_to_Colormap
"GRID", // format
"NONE", // transform
"CURRENT_SLICE", // process_as_multidimensional
"NO_TRANSPOSE" // build_multidimensional_transpose
);
var result = await Geoprocessing.ExecuteToolAsync("management.CopyRaster", parameters);
This code works fine, but it respects the cellsize from the .text file and produces a raster with square cells.
Question:
Is there a way to:
Specify different cell width and height when creating a raster dataset from an Esri ASCII Grid file?
Or alternatively, convert/import the ASCII Grid into a raster dataset and then resample or transform it to have rectangular pixels?
Any help or guidance would be appreciated.
Thanks!
Solved! Go to Solution.
I have solved my problem by using Rescale geoprocessing tool.
Hi,
You can use Resample geoprocessing tool. Tool name "management.Resample"
Thanks for the response but its not working for me. I have used Resample geoprocessing tool in arcgis pro for testing as you can see I have changed x,y values for output, but the output is also the same width and height of input
I have solved my problem by using Rescale geoprocessing tool.