[gdal-dev] Translating ArcInfo binary grid to USGS .dem in C# via GDAL

Even Rouault even.rouault at mines-paris.org
Fri May 13 13:22:26 EDT 2011


Le vendredi 13 mai 2011 19:13:32, supercooper a écrit :
> For transparency's sake, I posted this to gis.stackexchange
> (http://gis.stackexchange.com/questions/9609/translating-grid-to-usgs-dem-i
> n-c-via-gdal), but haven't heard anything that really helps, so I thought
> this might be a better place to seek help.
> 
> I am attempting to translate ArcInfo binary grids to USGS DEM format (.dem)
> for input into VUE Infinite, a 3D visualization program. I am *very* new to
> GDAL, and I have installed the GDAL .NET bindings thru a
> (http://vbkto.dyndns.org/sdk/PackageList.aspx?file=release-1500-gdal-1-8-0-
> mapserver-5-6-6.zip) build installer. I can get to GDAL in my C# solution 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;
> String[] opts = new String[] { "PRODUCT=DEFAULT,ZRESOLUTION=float" };
> 
> Dataset dsDem = demDriver.Create("C:\\Data\\65587895\\foo.dem", x, y, 1,
> DataType.GDT_Int16, opts);
> 
> Gives the error:
> 
> System.ApplicationException: GDALDriver::Create() ... no create method
> implemented for this format.

Indeed, only a small percent of drivers with write capabilities support the 
full Create() method which is indicated by the DCAP_CREATE=YES metadata. The 
majority of drivers with write capabilities, such as USGSDEM, support only 
CreateCopy() (DCAP_CREATECOPY=YES). But from what you describe above 
(translating a dataset to another format), it is just what you need.

So try instead :

Dataset dsDem = demDriver.CreateCopy("C:\\Data\\65587895\\foo.dem", 
originalImage, 0, opts);

> 
> I thought the USGSDEM format was read/write...am I wrong on that? The
> formats list (http://www.gdal.org/formats_list.html) 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 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.
> 
> I've also poked thought the source for the USGSDEM format, and don't see
> anything in there pertaining to creating a dem (although I could easily
> miss that, as I am by no means fluent in C++).

see USGSDEMCreateCopy() in frmts/usgsdem/usgsdem_create.cpp

> 
> Any thoughts or experience with this? Any other thoughts on translating
> ArcInfo binary grids (or anything for that matter) to DEMs?
> 
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Translating-ArcInfo-binary-grid-to-
> USGS-dem-in-C-via-GDAL-tp6360189p6360189.html Sent from the GDAL - Dev
> mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list