Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

Convert DEM to GIF & keep Z values

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
waleed072098
Asked:
waleed072098
  • 10
  • 6
1 Solution
 
dryangCommented:
Have you tried compresing the contents into an archive file, specifically .JAR format
0
 
gadioCommented:
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
 
waleed072098Author Commented:
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
Industry Leaders: 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!

 
gadioCommented:
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
 
waleed072098Author Commented:
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
 
gadioCommented:
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
 
waleed072098Author Commented:
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
 
waleed072098Author Commented:
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
 
waleed072098Author Commented:
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
 
gadioCommented:
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
 
waleed072098Author Commented:
Gadio,
I thank you very much. You have solved my problem


Waleed
0
 
gadioCommented:
Ok. Let me know if you need pointers when you write your code.

Regards,
G.
0
 
waleed072098Author Commented:
Can you do this now. I am afraid you forget.
0
 
waleed072098Author Commented:
Can you do this now. I am afraid you forget.
0
 
waleed072098Author Commented:
Can you do this now. I am afraid you forget.
0
 
gadioCommented:
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
 
waleed072098Author Commented:
thanks

Waleed
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 10
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now