I am attempting to translate ArcInfo binary grids to USGS DEM format (.dem). I have installed the GDAL .NET bindings thru this build installer. I can get to GDAL in my C# add-in I am working on. However, it seems that I cannot create a USGS DEM:

GDAL.Dataset originalImage = Gdal.Open("C:\\65587895\\hdr.adf", GDAL.Access.GA_ReadOnly);
Driver demDriver = Gdal.GetDriverByName("USGSDEM");

int x = originalImage.RasterXSize;
int y = originalImage.RasterYSize;

Dataset dsDem = demDriver.Create("C:\\Data\\65587895\\foo.dem", x, y, 1, DataType.GDT_Int16, null);

Gives the error:

System.ApplicationException: GDALDriver::Create() ... no create method implemented for this format.

I thought the USGSDEM format was read/write...am I wrong on that? The formats list says that creation of USGSDEM is supported, but a run of demDriver.GetMetadata(null) to get the metadata from the USGSDEM driver results in no return of DCAP_CREATE=YES, only DCAP_CREATECOPY=YES, which makes me cringe, thinking that indeed the GDALDriver::Create() method is not implemented for the USGSDEM format.

Any thoughts or experience with this? Any other thoughts on translating binary grids to DEMs?


Turns out you use the CreateCopy method instead, since the Create method is indeed not implemented for the USGSDEM format:

OSGeo.GDAL.Dataset dsDem = demDriver.CreateCopy(c.outputFile, originalImage, 0, null, new Gdal.GDALProgressFuncDelegate(ProgressFunc), "Sample Data");

I must admit that after not getting many responses here, I asked this question on the gdal-dev osgeo mailing list, which is where this answer came from.


This page goes into more details, particularly on Creation Issues for USGSDEM formats.

I'm pretty sure you need to pass some creation option in the last parameter of Create where you have it set as null. The gdal_translate example at the bottom of that page might help you determine what these are, which you can explore at the command prompt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.