Solved

Convert DEM to GIF & keep Z values

Posted on 1998-07-21
17
433 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 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