POV-Ray : Newsgroups : povray.binaries.utilities : Problem DEM2POV/DEM2TGA? Server Time
1 Nov 2024 11:14:38 EDT (-0400)
  Problem DEM2POV/DEM2TGA? (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: STUDENT
Subject: Problem DEM2POV/DEM2TGA?
Date: 17 Apr 1998 04:56:57
Message: <35371959.29D1B861@student.canberra.edu.au>
I have been trying to use DEM data for Eastern Australia found at
http://edcwww.cr.usgs.gov/landdaac/gtopo30/gtopo30.html.  Unfortunately
all
the dem2tga & dem2pov converter's do not seem to like it.

Would anyone be able to:
a) direct me to alternate data for this region which does work,
b) direct me to a converter that will work, or
c) tell me where I am going wrong. Below is a summary of the process I
am now
using and the error messages. (It appears the DEM file type is
unsuitable?)

Any help would be greatly appreciated.

Roger.
---------------------------------------------------------------------------------

1) Download e140s10.tar.
2) Use dos TAR extraction utility called untgz (by Tillmann Steinbrecher
found at
http://www.isjm.com/tst/untgz.htm) to extract *.dem file.
3)Use dem2tga (by Jon Larimer at http://www.alltel.net/~jonl/dem.html)
and get the following ouput:

D:\temp\dem2tga>dem2tga e140s10.dem my.tga
dem2tga v1.0 (c) 1997 Jon Larimer
This program is public domain.

Quad name field:




Exiting due to signal SIGSEGV
General Protection Fault at eip=000016a1
eax=00000000 ebx=00000000 ecx=00000000 edx=00000000 esi=0004f120
edi=0004dac4
ebp=f1d8f1d8 esp=0004da06 program=D:\TEMP\DEM2TGA\DEM2TGA.EXE
cs: sel=00af  base=82a70000  limit=0005ffff
ds: sel=00b7  base=82a70000  limit=0005ffff
es: sel=00b7  base=82a70000  limit=0005ffff
fs: sel=0087  base=0000ecc0  limit=0000ffff
gs: sel=00c7  base=00000000  limit=ffffffff
ss: sel=00b7  base=82a70000  limit=0005ffff

Call frame traceback EIPs:
  0x000016a1


5)I have tried the DEM2POV utility found at The Povray HomePage.
It causes a gpf after the following output.

D:\temp\dem2pov>dem2pov e140s10.dem my.tga
DEM to POV height-field v1.1c by W. D. Kirby 4/18/95
  based on DEM to x,y,z ascii file, ver 3.1, 1-95 -- Sol Katz, BLM
Map label:



[ 2] DEMlevel:  0
[ 3] elevation Pattern: 0  (=>?0?   )
[ 4] planimetric reference system: 0 (=>georgraphic)
 [ 5] ground Zone: 0
[ 6] proj:       0.0000000       0.0000000       0.0000000
[ 6] proj:       0.0000000       0.0000000       0.0000000
[ 6] proj:       0.0000000       0.0000000       0.0000000
[ 6] proj:       0.0000000       0.0000000       0.0000000
[ 6] proj:       0.0000000       0.0000000       0.0000000
[ 7] plane Unit Of Measure: 0 (=>radians )
[ 8] elevation measurement units code: 0 (=>?0?   )
[ 9] polygon Sides: 0
[10] ground coordinates
     NW (       0.00000,        0.00000)  NE (       0.00000,
0.00000)
     SW (       0.00000,        0.00000)  SE (       0.00000,
0.00000)
[11] Elev. Min:         0.00000, Max:         0.00000, Accuracy code: 0
[14] Spatial Resolution:         0.00000,         0.00000,
0.00000
[15] map size is 0 x 0 (row x columns)

-----------------------------------------------------------------------------


Post a reply to this message

From: Vahur Krouverk
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 17 Apr 1998 13:57:01
Message: <353797ED.BDD028E8@fv.aetec.ee.nospam>
STUDENT wrote:

> I have been trying to use DEM data for Eastern Australia found at
> http://edcwww.cr.usgs.gov/landdaac/gtopo30/gtopo30.html.  Unfortunately
> all
> the dem2tga & dem2pov converter's do not seem to like it.
>
> Would anyone be able to:
> a) direct me to alternate Oz data,
> b) direct me to a converter that will work, or
> c) tell me where I am going wrong. Below is a summary of the process I
> am now
> using and the error messages. (It appears the DEM file type is
> incompatible?)
>
> Any help would be greatly appreciated.
>
> Roger.

Hi!
I guess I'm able for options b and c ;-)
I've run to this problem as well. As it appears, there is at least 2 different file
types with same extensions: in GTOPO DEM file is pure binary stuff and information
about DEM file (size, origin data etc) is contained in supplemental files (HDR,
e.g.), other files are textual with header in the beginning and height data
following. DEM2POV works with textual file, seems like DEM2TGA does same (though I
haven't tried it).
In order to solve this, I wrote little program, named DEMTOTGA, which converts these
GTOPO files to 16-bit TGA (compatible with POV-Ray height field ones). I attach my
program for trial. It is intended for Windows, if You have other platform and C
compiler, then mail me and I'll send source code.


Post a reply to this message


Attachments:
Download 'demtotga.zip' (39 KB)

From: Roger
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 4 May 1998 11:33:41
Message: <354DDFD6.253@student.canberra.edu.au>
After doing some more work with demtotga I found that there appears to
be a problem with the calculation of normalization.  When I tried to use
it on an area around the Jordan Valley (Middle East) the normalisation
value came up as 0. I believe this was because the low point and high
point values are equal in this region. (The Jordan valley is the lowest
land on earth.)  At a guess I would say that the problem is that the low
point needs to be made absolute before using it in the normalisation
calculation?

Could you please make the source code available so that I can study the
code.  I am considering customising it specifically for my needs.

Thanks
Roger.


Post a reply to this message

From: Vahur Krouverk
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 9 May 1998 12:42:00
Message: <35548758.265F2F5B@fv.aetec.ee.nospam>
Roger wrote:

> After doing some more work with demtotga I found that there appears to
> be a problem with the calculation of normalization.  When I tried to use
> it on an area around the Jordan Valley (Middle East) the normalisation
> value came up as 0. I believe this was because the low point and high
> point values are equal in this region. (The Jordan valley is the lowest
> land on earth.)  At a guess I would say that the problem is that the low
> point needs to be made absolute before using it in the normalisation
> calculation?
>
> Could you please make the source code available so that I can study the
> code.  I am considering customising it specifically for my needs.

Sorry for such long delay. I had no time to visit povray newsgroups.I
haven't  tested my program very much, it suited my needs and therefore it is
quite basic.
As I recall, USGS site said, that the sea level has height 0, all lands have
height at least 1 meter and I used this assumption.  This is indeed problem
for rendering areas, which are below sea level. I don't know, what is
contained in the DEM file in this case. Solution could be to use  height
source information  ( from file with .SRC extension, I believe).
BTW, I suspect, that there are areas in the DEM files, which could be
corrupted. At least I found during rendering some areas with inaccurate
height field information. I am not sure, whether this is caused by
inappropriate data, by error during decompression or during my conversion.
If You found any errors, then I'd like to hear about them.

Here is code. Nothing special, but it may be good start to poke around.
/****************************************************************************

*
*  FILE:      demtotga.c
*
*  PURPOSE:   File reads binary dem file and outputs it to targa file.
*
*  AUTHOR:    Vahur Krouverk (vah### [at] fvaetecee)
*             Parts of this program are derived from DEM2POV
*
*  REVISIONS:
*    #1   VK 08.11.97 : Initial revision
*
****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// size of dem file
int yrows = 6000;
int xcols = 4800;


void writeHeader(FILE *outputFile, int width, int height);

// coordinates for rectangle to convert
int starty=0;
int endy=0;

int startx=0;
int endx=0;

int min_val=32767;
int max_val=-32768;

int coeff=0;

main(int argc, char *argv[])
{

   FILE *inf=0, *outf=0, *headerf=0;
   char *ptr;
   char filename[_MAX_PATH];
   char outfilename[_MAX_PATH];
   char headerfilename[_MAX_PATH];

   int nodataVal=-9999;
   int xcount=0, ycount=0;
   short val;
   char *valptr=(char *)&val;
   char *buf;
   char *sourcebuf;
   int Argshift=0;
   int bigEndian=1;

   if (argc < 3) {

     (void) fprintf(stderr, "DEMTOTGA v0.9: reads binary .DEM file and
converts it to 16-bit .TGA.\n");
     (void) fprintf(stderr, "Written by Vahur Krouverk
(vah### [at] fvaetecee)\n");
     (void) fprintf(stderr, "Based on DEM2POV  v1.1c by W. D. Kirby\n");
     (void) fprintf(stderr, "\nUsage: demtotga [-h headerfile] dem_file
tga_file\n\n");
     (void) fprintf(stderr, " -h headerfile specifies headerfile (.HDR) for
.DEM file. \n");
     exit(1);
   }
   if(0==strcmp(argv[1],"-h")){
     int result;
     char line[100];
     if ((headerf = fopen(argv[2], "r")) == NULL) {
       fprintf(stderr,"Error opening header file %s\n",argv[2]);
       exit(1);
     }

     while((result = fgets(line, sizeof(line), headerf)) != NULL){
       int pos=0;
       if(pos=strstr(line, "NROWS")){
         yrows=atoi(pos+strlen("NROWS"));
       }
       else if(pos=strstr(line, "NCOLS")){
         xcols=atoi(pos+strlen("NCOLS"));
       }
       else if(pos=strstr(line, "NODATA")){
         nodataVal=atoi(pos+strlen("NODATA"));
       }
     }
     fclose(headerf);
     Argshift=2;
   }

   strcpy(filename, argv[1+Argshift]);
   strcpy(outfilename, argv[2+Argshift]);

   if ((inf = fopen(filename, "r")) == NULL) {
   fprintf(stderr,"Error opening input file %s\n",filename);
     exit(1);
   }

   if ((outf = fopen(outfilename, "wb")) == NULL) {
     fprintf(stderr,"Error opening output file %s\n", outfilename);
     exit(1);
   }

   buf=malloc(xcols*2);
   sourcebuf=malloc(xcols);

/*   fprintf(stdout, ".DEM file width = %d, height = %d\n", xcols, yrows);*/

   fprintf(stdout,"Enter start column x1   ( 1  <= x1 <= %d  ) :", xcols);
   fflush(stdout);
   scanf("%d",&startx);
   fprintf(stdout,"Enter end   column x2   ( x1 <= x2 <= %d  ) :", xcols);
   fflush(stdout);
   scanf("%d",&endx);
   fprintf(stdout,"Enter start row    y1   ( 1  <= y1 <= %d  ) :", yrows);
   fflush(stdout);
   scanf("%d",&starty);
   fprintf(stdout,"Enter end   row    y2   ( y1 <= y2 <= %d  ) :", yrows);
   fflush(stdout);
   scanf("%d",&endy);

   if(startx<1 || startx>xcols){
     fprintf(stderr, "ERROR in start column range [ 1 <= start column <=
%d]\n", xcols);
     exit(1);
   }
   if(starty<1 || starty>yrows){
     fprintf(stderr, "ERROR in start row range [ 1 <= start row <= %d]\n",
yrows);
     exit(1);
   }
   if( endx<startx || endx>xcols){
     fprintf(stderr, "ERROR in end column range [ start column <= end column
<= %d]\n", xcols);
     exit(1);
   }
   if( endy<starty || endy>yrows){
     fprintf(stderr, "ERROR in end row range [ start row <= end row <=
%d]\n", yrows);
     exit(1);
   }
   /* convert area to 0 base for dealing with arrays */
   startx--;
   endx;
   starty--;
   endy;
/*
printf(" %d, %d, %d, %d\n",startx, endx, starty, endy);
*/
   fprintf(stderr, "Starting scan ...\n");
   /*
      read min-max values from specified part of dem file to normalize this
      part (minimum value goes as 1, maximum value goes as 2**16)
      sea level gets value 0
   */
   /*  go to data set start */
   fseek(inf, starty*xcols*2, SEEK_SET);
   for(ycount=starty; ycount< endy; ++ycount){
     fread(buf, xcols*2, 1, inf);
     /* find y start */
     ptr=buf+startx*2;
     for(xcount=startx; xcount<endx; xcount+=1, ptr+=2){
       swab(ptr, (char*)&val, 2);
       //check for sea level
       if(val!=nodataVal){
         if(val<min_val)
           min_val=val;
         if(val>max_val)
           max_val=val;
       }
     }
   }

   fprintf(stderr, "Min value was %d, max value was %d \n", min_val,
max_val);
   if( min_val == 32767 && max_val == -32768){
     fprintf(stderr, " Warning: Nodata area (probably sea) conversion!\n");
     coeff=1;
   }
   else{
     /* calc coefficent */
     coeff=(65535.0)/(max_val-min_val+1);
   }
   fprintf(stderr, "Coefficent for normalization is %d \n", coeff);

   writeHeader(outf, endx-startx, endy-starty);
   fprintf(stderr, "Starting conversion...\n");

   /*  go to data set start */
   fseek(inf, starty*xcols*2, SEEK_SET);

   for(ycount=starty;ycount< endy; ++ycount){
/*     fprintf(stderr, "Working with line %d ", ycount); */

     fread(buf, xcols*2, 1, inf);
     /* find start position in current line*/
     ptr=buf+startx*2;
     for(xcount=startx; xcount<endx; xcount+=1, ptr+=2){
       swab(ptr, &val, 2);
       putc((char)0, outf);                       /* Blue  empty     */
       if(val==nodataVal){
         // sea level, put this pixel as black
         putc((char)(0), outf); /* Green low byte  */
         putc((char)(0), outf); /* Red   high byte */
       }
       else{
         val=(val-min_val)*coeff;
         putc((char)(*(valptr) ),outf); /* Green low byte  */
         putc((char)(*(valptr+1)), outf); /* Red high byte */
       }
     }
   }
   fprintf(stderr, "Done!\n");
   fclose(outf);
   fclose(inf);
   free(buf);
   free(sourcebuf);
   return 0;
}


void writeHeader(FILE *outputFile, int width, int height)
{
   int i;

   fprintf(stderr,"Writing TGA header with width = %d  and height = %d \n",
width, height);

   /* Write TGA image header */
   for (i = 0; i < 10; i++){
     if (i == 2)
       putc(i, outputFile);
     else
       putc(0, outputFile);
   }
   putc(0, outputFile); /* y origin set to "First_Line" */
   putc(0, outputFile);

   putc(width % 256, outputFile);  /* write width and height */
   putc(width / 256, outputFile);
   putc(height % 256, outputFile);
   putc(height / 256, outputFile);
   putc(24, outputFile);
   putc(32, outputFile);
}


Post a reply to this message

From: Alain CULOS
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 9 May 1998 20:11:54
Message: <3554F0CA.DD56F0AF@bigfoot.com>
Hi,

Nice of you.

Just one question, where do you get DEM files that are outside the USA ?
I was not able to conclude a positive search on the web for any DEM files but USA
ones.

Thanks for any sort of pointer,
Al.

--
ANTI SPAM / ANTI ARROSAGE COMMERCIAL :

To answer me, please take out the Z from my address.


Post a reply to this message

From: Roger
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 10 May 1998 23:38:33
Message: <355672B8.506902FF@student.canberra.edu.au>
Hi,

The Site:
http://edcwww.cr.usgs.gov/landdaac/gtopo30/gtopo30.html
Good Luck!

Alain CULOS wrote:

> Hi,
>
> Nice of you.
>
> Just one question, where do you get DEM files that are outside the USA ?
> I was not able to conclude a positive search on the web for any DEM files but USA
ones.
>
> Thanks for any sort of pointer,
> Al.
>
> --
> ANTI SPAM / ANTI ARROSAGE COMMERCIAL :

> To answer me, please take out the Z from my address.


Post a reply to this message

From: Alain CULOS
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 12 May 1998 17:19:34
Message: <3558BCE6.F609AA5B@bigfoot.com>
Hi Roger,

Thanks, that is what I was looking for for so long ...
Cherio,
Al.


> The Site:
> http://edcwww.cr.usgs.gov/landdaac/gtopo30/gtopo30.html

--
ANTI SPAM / ANTI ARROSAGE COMMERCIAL :

To answer me, please take out the Z from my address.


Post a reply to this message

From: Kent Friberg
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 15 May 1998 16:07:13
Message: <6jichn$o18$1@oz.aussie.org>
if anyone modifies the code or make another dem2tga proggy that works better
than the one at
http://www.alltel.net/~jonl/dem.html   it would be nice if you post a link
to the exe.

-Kent


Post a reply to this message

From: U  Mueller
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 27 Feb 1999 02:59:15
Message: <36D7FA3F.3121@a.com>
STUDENT wrote:
> I have been trying to use DEM data for Eastern Australia found at
> http://edcwww.cr.usgs.gov/landdaac/gtopo30/gtopo30.html.  Unfortunately
> all the dem2tga & dem2pov converter's do not seem to like it.
>
> Would anyone be able to:
> a) direct me to alternate data for this region which does work,
> b) direct me to a converter that will work, or
> c) tell me where I am going wrong. Below is a summary of the process I am now

The problem with DEM files is that there are many different formats
around...most converters (so is mine at
http://www.bielefeld.netsurf.de:8080/~u_mueller/dem2pov.html) work only
on data which includes the DEM header in the file with the DEM data and
is in ascii format...

The files you get from the above address are not in this format...the
header data is in different files...and I know of no program that can
convert these...

  See ya
    Udo


Post a reply to this message

From: Bob and Kelly Crispen
Subject: Re: Problem DEM2POV/DEM2TGA?
Date: 28 Feb 1999 12:37:03
Message: <36D97E23.964D538F@hiwaay.net>
You might want to check out 3DEM70 by Richard Horne at
http://www.monumental.com/rshorne/3dem.html

Not only does it generate Targa heightfields, it'll also generate
VRML ElevationGrids, so while you're waiting for a render you
can fly around in the VRML model to find that perfect camera
position.
--
Bob Crispen
cri### [at] hiwaaynet
'T is with our judgments as our watches,--none 
Go just alike, yet each believes his own.
-- Alexander Pope: _Essay on Criticism_


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.