[GRASS-user] How to make a conversion of ERSI Grid ASCII==>USGS DEM?

Illidan illidan.modeler at gmail.com
Mon Mar 2 03:18:46 EST 2009


I'm not lucky enough with a successful gdal_translate.

> gdal_translate -of USGSDEM srtm_60_04.asc srtm_60_04.dem --debug on
GDAL: GDALOpen(srtm_60_04.asc) succeeds as AAIGrid.
Input file size is 6000, 6000
ERROR 1: DEM Default Setup: Importing source dataset projection failed
GDAL: GDALClose(srtm_60_04.asc)
GDAL: GDALDeregister_GTiff() called.

I wonder if my data is not valid, so I also try a DTED conversion by
"gdal_translate -of DTED srtm_60_04.asc srtm_60_04.dem --debug on".

The output is even worse, crashing with a complain

"GDAL: GDALOpen(srtm_60_04.asc) succeeds as AAIGrid.
Input file size is 6000, 6000
0Warning 1: The source does not appear to be a properly formatted cell.
Warning 1: The corner coordinates of the source are not properly
aligned on plain latitude/longitude boundaries.
...10...20...30...40...50...60...70...80...90...100 - done.
*** buffer overflow detected ***: gdal_translate terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb787b558]
/lib/tls/i686/cmov/libc.so.6[0xb7879680]
/lib/tls/i686/cmov/libc.so.6[0xb7878d68]
/lib/tls/i686/cmov/libc.so.6(_IO_default_xsputn+0xc8)[0xb77eea18]
/lib/tls/i686/cmov/libc.so.6(_IO_vfprintf+0xf4a)[0xb77c18da]
/lib/tls/i686/cmov/libc.so.6(__vsprintf_chk+0xa7)[0xb7878e17]
/lib/tls/i686/cmov/libc.so.6(__sprintf_chk+0x2d)[0xb7878d5d]
/usr/lib/libgdal1.5.0.so.1[0xb7b36ed1]
/usr/lib/libgdal1.5.0.so.1(_ZN10GDALDriver10CreateCopyEPKcP11GDALDatasetiPPcPFidS1_PvES6_+0x67)[0xb7c6c767]
/usr/lib/libgdal1.5.0.so.1(GDALCreateCopy+0x4f)[0xb7c6c86f]
gdal_translate[0x804b6b1]
gdal_translate[0x804b9eb]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7797685]
gdal_translate(GDALTermProgress+0x65)[0x8049721]
"

The source of my data is (which covers a large portion of the world
and supports ESRI ASCII output):

http://srtm.csi.cgiar.org/SELECTION/inputCoord.asp


My gdal_translate is a 1.5.2 on ubuntu 8.10.

$ gdal_translate --version
GDAL 1.5.2, released 2008/05/29



On Mon, Mar 2, 2009 at 2:55 PM, Hamish <hamish_b at yahoo.com> wrote:
>
> Illidan wrote:
>> By now I'm successful with importing the ESRI ASC by r.in.arc
>>
>> > r.in.arc input=srtm_60_04.asc output=beijing
>> CREATING SUPPORT FILES FOR beijing
>>
>> However, when I try
>>
>>  r.out.gdal input=beijing output=beijing.dem format=USGSDEM
>>
>> it replies with "Error: value <USGSDEM> out of
>> range for parameter <format>
>>        Legal range:
>> AAIGrid,BMP,BSB,DTED,ELAS,ENVI,FIT,GIF,GTiff,HFA,JPEG,MEM,MFF,MFF2,
>> NITF,PAux,PNG,PNM,VRT,XPM
>> ''
>>
>> In fact when I run it with "-l" option as
>> "r.out.gdal input=beijing
>> output=beijing.dem -l'', it responses with a
>> listing including
>> 'USGSDEM' that looks like:
>>
>>   FIT: FIT Image
>>   RMF: Raster Matrix Format
>>   RST: Idrisi Raster A.1
>>   INGR: Intergraph Raster
>>   GSAG: Golden Software ASCII Grid (.grd)
>>   GSBG: Golden Software Binary Grid (.grd)
>>   USGSDEM: USGS Optional ASCII DEM (and CDED)
>>   ADRG: ARC Digitized Raster Graphics
>>
>>
>> So I'm confused whether USGSDEM is valid or not.
>
> mmph. problem with r.out.gdal. there is a switch somewhere called
> __ALLOW_DYNAMIC_OPTIONS__. For me it is true and my format= list of
> supported format is the full one. If that wasn't set when the program
> was compiled it just falls back on a short list someone put in there
> some time ago.
>
> The '-l' flag talks to gdal unconditionally so you always get the full
> list.
>
> with new versions of GDAL, more and more formats are supported but
> r.in.gdal's fail-over format= list hasn't been updated.
>
>
> for me using modern gdal 1.5.2 from DebianGIS I get a lot more formats
> than the fail-over list:
>
> $ gdalinfo --formats | grep '\(rw\)' |cut -f1 -d'(' | sed -e '1d' | \
>    awk '{print $1}' | sort -f | tr '\n' ','
>
> AAIGrid,ADRG,BMP,BT,DTED,EHdr,ELAS,ENVI,ERS,FIT,GIF,GMT,GSAG,GSBG,
> GTiff,HDF4Image,HFA,IDA,ILWIS,INGR,JPEG,JPEG2000,Leveller,MEM,MFF,
> MFF2,netCDF,NITF,PAux,PCIDSK,PCRaster,PNG,PNM,RMF,RST,SRTMHGT,
> Terragen,USGSDEM,XPM
>
>
>
>
> So: if you have the source code just //comment out the
>  format->options = gdal_formats;
> line in main.c and rebuild. if you are working from an installer package
> you will have to bug the person who made the package to enable the
> __ALLOW_DYNAMIC_OPTIONS__ switch or use gdal_translate (see below).
>
> dev: probably if dynamic options is not set it should be left blank
> instead of using a hard-coded list which will always out of date or
> refer to someone else's gdal.
>
>
> Another option as this is raster->raster is to bypass GRASS altogether
> and use the gdal_translate utility program to convert directly from Arc
> ASCII GRID to USGSDEM.
>
> something like:
>  gdal_translate -of USGSDEM  map_arc.grid  map_usgs.dem
>
>
> Hamish
>
>
>
>
>
>



-- 
Illidan
Networking System Modeler
Northern Capital, Republic of Pandaren
http://illidan.go.3322.org


More information about the grass-user mailing list