Select to view content in your preferred language

How to create raster dataset from Esri ASCII Grid with different cell width and height (rectangular pixels) using ArcGIS Pro SDK for .NET?

133
3
Jump to solution
a week ago
Muhammadkhalid
Occasional Contributor

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:

  1. Specify different cell width and height when creating a raster dataset from an Esri ASCII Grid file?

  2. 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!

0 Kudos
1 Solution

Accepted Solutions
Muhammadkhalid
Occasional Contributor

I have solved my problem by using Rescale geoprocessing tool.

View solution in original post

0 Kudos
3 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You can use Resample geoprocessing tool. Tool name "management.Resample"

0 Kudos
Muhammadkhalid
Occasional Contributor

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

 

Muhammadkhalid_0-1744789591868.png

 

0 Kudos
Muhammadkhalid
Occasional Contributor

I have solved my problem by using Rescale geoprocessing tool.

0 Kudos