Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.AllRegister();
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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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