Solved

Convert DEM to GIF & keep Z values

Posted on 1998-07-21
17
422 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
Comment Utility
Have you tried compresing the contents into an archive file, specifically .JAR format
0
 
LVL 6

Accepted Solution

by:
gadio earned 50 total points
Comment Utility
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
Comment Utility
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
 
LVL 6

Expert Comment

by:gadio
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:waleed072098
Comment Utility
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
Comment Utility
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
Comment Utility
Gadio,
I thank you very much. You have solved my problem


Waleed
0
 
LVL 6

Expert Comment

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

Regards,
G.
0
 

Author Comment

by:waleed072098
Comment Utility
Can you do this now. I am afraid you forget.
0
 

Author Comment

by:waleed072098
Comment Utility
Can you do this now. I am afraid you forget.
0
 

Author Comment

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

Expert Comment

by:gadio
Comment Utility
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
Comment Utility
thanks

Waleed
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Logs to delete in Windows VCenter server ? 11 156
bigHeights  challenge 13 55
mapBully challenge 6 88
solarwind tftp server 2 30
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now