Solved

Convert DEM to GIF & keep Z values

Posted on 1998-07-21
17
441 Views
Last Modified: 2008-02-01
I have a raster image ( DEM fromat from  US Geological survey).
   This format has x,y, z(elevation data). If I want to display it in the Web,
   I have to convert it to GIF/JPG formats. In doing so, I will loose the z's values
   which I need
   to use in my calculation in Java or whatever. Is there a way to convert the DEM
   format to
    GIF but still keep the all the z values. I see on solution is to save he z values in a
   text
   file but in this case java will take too much time to download it and interact with it
   once it is loaded. I am looking for a solution. I am prepared to do whatever to find
   a
   solution to this problem. If you know, please let me know please. Thanks

   Waleed
0
Comment
Question by:waleed072098
  • 10
  • 6
17 Comments
 
LVL 1

Expert Comment

by:dryang
ID: 1227366
Have you tried compresing the contents into an archive file, specifically .JAR format
0
 
LVL 6

Accepted Solution

by:
gadio earned 50 total points
ID: 1227367
waleed, if the DEM format is close to the DTM (digital terrine model) format, then the points are not covering the surface (its not point per pixel, just grid or non ordered points) than the only thing that you can do with it is simply generate contours or slope maps. There is no built in ability in java to do that (and its not a simple task, mathematically). If however the format is pixel oriented than I would suggest you to set a transformation height <-> color and thus to represent the height through color (like a green to brown scale) .  If its a pixel oriented I can show you how to make a conversion using gif libraries. If its not (my first option) I can give you directions to how to solve such a problem, but you are in for a lot of work.
Regards,
G.


0
 

Author Comment

by:waleed072098
ID: 1227368
yes its point per pixel. Every pixel has a value but a pixel with avalue of say 000 is a pixel
with no elevation (or unidentified). I know in java there is no built in class but you can write
slope algorithm ofcourse theat read the pixel value (z) and color the the one with high degree of slope. I have done so but the problem is:

Before converting the DEM to GIF, I have to save the z values in a text file (ASCII format)
After converting the image to GIF, I need to download the file every time the applet is loaded, and this will take too much time because the file is big
This supposed to be real-time processing. You see what I mean my friend.
Waleed
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:gadio
ID: 1227369
Ok, you can do one of two things:
1. pack the file in a jar (to minimze communication) and read it over the net into the applet and perform conversion directly to the screen - without the use of gif/jpg formats.
2. perform and off line processing on the data and generate the gif/jpg outside the applet.
each of the approaches has pluses and minuses. The first is more up to date but slower. The second is faster but not up to date and requeirs a server side programming.
0
 

Author Comment

by:waleed072098
ID: 1227370
My application require fast processing ! Maybe I go for the first approach.

I ) What is jar? Jar the data file that contain z's ? and can java read it?

2) What you mean by perform conversion directly to the screen-without using gif/jpg ?

I need to display the image(gif/jpg) in my applet. Just for displaying purposes
next the result of my calculation is coloring the image (GIF) pixels with some colors.

To explain, I want to do slope algorithms according to the z values. If the slope of the pixel
is (e.g 100 then the color is balck, 90 dark gray, 0 white),
0
 
LVL 6

Expert Comment

by:gadio
ID: 1227371
1. Well, jar is pretty must the same as zip (actually unzip would work for it). Java has a built in libraries to deal with jars/zips.
2. I think that for your needs, the conversion for gif and from gif to derivatives map (slopes) is a waste of time. So my suggession is read the data in, process it on the fly while reading (depending on your algorithem but you can hold just few image line at any given time, in order to find slopes. 3 to 7 I'd say) and put the pixels on the screen to a canvas component. No need to generate a gif out of it. You stated yourself that the gif is not needed. This will work faster.

0
 

Author Comment

by:waleed072098
ID: 1227372
Gadio,
I like very much what you say. But loading a simple GIF image will take time ?
since sometimes we need to see the image before processing it (before performing the slope). Do you think displaying a GIF in java take considerable amount of time ? beside the calculation

Waleed
0
 

Author Comment

by:waleed072098
ID: 1227373
Gadio,
Sorry I forgot this:

For jar/zip, java will process the file unzipped?  if that is the case . This is very good
Waleed
0
 

Author Comment

by:waleed072098
ID: 1227374
Gadio,
Sorry I forgot this:

For jar/zip, java will process the file unzipped?  if that is the case . This is very good
Waleed
0
 
LVL 6

Expert Comment

by:gadio
ID: 1227375
No. Loading and displaying the gif is very short. BUT since you want to create it first - this action may take some time, since this action involves compressing of the image etc. You dont have to have gif or jpg in order to display raster info on the screen!
About the zip. The java is able to read from a file that is over the net and zipped. The file is unzipped on the fly, in the client side.
0
 

Author Comment

by:waleed072098
ID: 1227376
Gadio,
I thank you very much. You have solved my problem


Waleed
0
 
LVL 6

Expert Comment

by:gadio
ID: 1227377
Ok. Let me know if you need pointers when you write your code.

Regards,
G.
0
 

Author Comment

by:waleed072098
ID: 1227378
Can you do this now. I am afraid you forget.
0
 

Author Comment

by:waleed072098
ID: 1227379
Can you do this now. I am afraid you forget.
0
 

Author Comment

by:waleed072098
ID: 1227380
Can you do this now. I am afraid you forget.
0
 
LVL 6

Expert Comment

by:gadio
ID: 1227381
Ok. At first stage you can leave the zip/jar thing. You can always add it later.
1. First start by writing an applet that reads a file from the same directory where the applet is. Use the URL class (its openStream) and read the file.
2. try and break the file into tokens using StreamTokenizer.
3. Convert the strings to numbers using Integer class or Float or Double class.
4. Build an array of points (define class mypoint with 3 floats/int whatever you nned) from the data.

Tell me how that goes.

0
 

Author Comment

by:waleed072098
ID: 1227382
thanks

Waleed
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
check java version using powershell 13 280
Android development question 2 75
Java: anonymous class 4 37
Html split(text) 2 26
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question