comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: reading dem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: reading dem [message #21530] Thu, 31 August 2000 05:56
Struan Gray is currently offline  Struan Gray
Messages: 178
Registered: December 1995
Senior Member
David Fanning, davidf@dfanning.com writes:

> P.S. Of course I knew you knew, Struan. That's why
> you have your badge. :-)

Blimey! When did that happen?


Bursting with pride,
Struan
Re: reading dem [message #21531 is a reply to message #21530] Thu, 31 August 2000 05:50 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Struan Gray (struan.gray@sljus.lu.se) writes:

> I've never got the acrobat plug in to work successfully with IE,
> but dont want to swap to Linux or Netscape. If you specify "view with
> application" instead of "view with browser" in the File Helper prefs
> for .pdf files, IE will save the file to disk and automatically start
> or hand over to the external Acrobat viewer. In terms of usability it's
> not that much different a feel, and it actually works properly.

Well, *something* like that, anyway. :-)

Thanks for these ideas. I actually had to turn "Browser
Integration" off in Acrobat, but now it is back to acting
more like what I had in mind. Thank you *very* much for this
answer to a w-a-a-y off-topic question. I knew I could count
on you guys. :-)

I think I mentioned that I am re-reading Robert Pirsig's
The Art of Motorcycle Maintenance. It is amazing to read
a book again 25 years later and see how profoundly your
ideas about life were affected by a book you can't even
remember. I felt the same way reading Walden again not
too long ago.

Anyway, last night I was reading about the various ways
you can get "stuck" in a problem. One of the classic
ways is asking questions that can't be answered from
your current perspective of what the problem is. You
get a "mu" answer. One that is neither yes or no. The
hoped for response to such a question is to retreat a
bit from the problem and see if you can't put it in a
larger perspective.

In this case, I think I was *WAY* to eager to blame
Mr. Gates and it never occurred to me that the folks who
built Photoshop could possibly share some of the blame.

In that sense, at least, this seems like a proper IDL
question for this group. :-)

Cheers,

David

P.S. Of course I knew you knew, Struan. That's why
you have your badge. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: reading dem [message #21535 is a reply to message #21531] Thu, 31 August 2000 00:00 Go to previous message
Struan Gray is currently offline  Struan Gray
Messages: 178
Registered: December 1995
Senior Member
David Fanning, davidf@dfanning.com writes:

> Does anyone know why, when I click on an Adobe Acrobat
> File (like the one at the link above), that the Adobe Acrobat
> Reader 4.0 starts up in my Windows Internet Explorer 5.0
> browser and *always* shows me a blank page. :-(

Bill doesn't like you. Actually, he doesn't like anyone.


> I've reinstalled Explorer. I've reinstalled the Reader.
> I've kicked the dog, cursed my lot in life, etc. But
> all to no avail. If I download the Acrobat file,
> then open the Reader, then open the downloaded file
> all is well. It's a mystery.

I've never got the acrobat plug in to work successfully with IE,
but dont want to swap to Linux or Netscape. If you specify "view with
application" instead of "view with browser" in the File Helper prefs
for .pdf files, IE will save the file to disk and automatically start
or hand over to the external Acrobat viewer. In terms of usability it's
not that much different a feel, and it actually works properly.


Struan
Re: reading dem [message #21541 is a reply to message #21535] Wed, 30 August 2000 19:08 Go to previous message
Sylvain Carette is currently offline  Sylvain Carette
Messages: 19
Registered: May 2000
Junior Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt>Aaaaahh... Thank you so much</tt>
<br><tt>Whithout knowing it you answered a couple of unnasked questions
(I think I have one for each page of the documentation)</tt><tt></tt>
<p><tt>Craig Markwardt wrote:</tt>
<blockquote TYPE=CITE><tt>Sylvain,</tt><tt></tt>
<p><tt>Part of the problem is that very few people have any direct experience</tt>
<br><tt>with what you are trying.&nbsp; Some, including me, offered some
general</tt>
<br><tt>advice, hoping that would help, but reading byte-level DEM's is
not</tt>
<br><tt>exactly common knowledge.&nbsp; Also realize that a topic so focussed
and</tt>
<br><tt>specific as yours is not likely to pique anybody's interst.&nbsp;
In the</tt>
<br><tt>future you would do better to describe what you need to do at a
higher</tt>
<br><tt>level, and help us by providing documentation, like I do now.</tt><tt></tt>
<p><tt>The documentation is here:</tt>
<br><tt><a href="http://rockyweb.cr.usgs.gov/nmpstds/demstds.html">http://rockyweb.cr.usgs.gov/nmpstds/demstds.html</a></tt>
<br><tt></tt>&nbsp;</blockquote>
<tt>Sorry if my requests sound confused; they are... I'm trying not to
trow all the questions floating in my head at the same time but probably
it will get better as time goes. Sorry also if a bit of frustration did
show up through the lines; I was getting anxious to get something done.
Now already feel better...</tt>
<blockquote TYPE=CITE><tt>The DEM's are digital elevation maps, and are
stored in 1024 byte</tt>
<br><tt>blocks.&nbsp; The first block contains a type "A" record.&nbsp;
The next blocks</tt>
<br><tt>contain a type "B" record which have the actual elevation data.&nbsp;
The</tt>
<br><tt>actual data start at offset 144 of the record (where offset 0 is
the</tt>
<br><tt>beginning); there are 1201x1201 elements stored, 146 in the first</tt>
<br><tt>1024-block, and then 170 in the successive 1024-blocks.&nbsp; Elevation</tt>
<br><tt>values are stored as ASCII format=(I6).</tt><tt></tt>
<p><tt>The key thing to realize that all the data is in ASCII, separated
by</tt>
<br><tt>blanks.&nbsp; Therefore, while we could read each 1024-block in
turn, it's</tt>
<br><tt>better to just do a formatted READF.&nbsp; There is no need to
work at the</tt>
<br><tt>byte level, except at the beginning to get to the right file offset.</tt>
<br><tt>Unfortunately IDL can only read 32k elements at a time, so I read
a</tt>
<br><tt>row at a time as a compromise.</tt></blockquote>
<tt>I did realize that the data was in ascii but my problem was to make
idl realize that...</tt>
<br><tt>I tryed readf but could get only the value of the ascii code instead
of the value itself; of course I tryed to use "format=" but couldnt guess
the right syntax - I think I was trying somthing like "format=(6(i))" so...
- again, the documentation could be lot more helpful by providing a couple
of (meaningful) examples.</tt>
<br><tt>So I end up thinking it was not the right function especially that
all the dem doc say it is a binary file and I though that formatted input
mean a real ascii file (one you can read). So I can do lot with readf as
long I know how to express the "format" syntax. Now, where I can find a
good table &amp; rule describing formatting (I have absolutely no background
in fortran - completely alien to me. I have the impression I'll need to
refer to that all the time.</tt>
<blockquote TYPE=CITE><tt></tt>&nbsp;<tt></tt>
<p><tt>pro readdem250, file, im</tt>
<br><tt>&nbsp; m = 1201L &amp; n = 1201L ;; Really get this from Type A,
element 16</tt>
<br><tt>&nbsp; im = lonarr(m, n)&nbsp;&nbsp;&nbsp;&nbsp; ;; Formally defined
as INTEGER*4</tt><tt></tt>
<p><tt>&nbsp; openr, lun, file, /get_lun</tt>
<br><tt>&nbsp; ;; Skip past type A record and 144 bytes of Type B record</tt>
<br><tt>&nbsp; point_lun, lun, 1024L + 144L</tt><tt></tt>
<p><tt>&nbsp; ;; Read data, one row at a time</tt>
<br><tt>&nbsp; row = im(*,0)</tt>
<br><tt>&nbsp; for i = 0, 1200 do begin</tt>
<br><tt>&nbsp;&nbsp;&nbsp; readf, lun, row, format='(1201(I6))'</tt>
<br><tt>&nbsp;&nbsp;&nbsp; im(*,i) = row</tt>
<br><tt>&nbsp; endfor</tt>
<br><tt>&nbsp; free_lun, lun</tt>
<br><tt>end</tt><tt></tt>
<p><tt>Of course I haven't tested this, but you can use this as a starting</tt>
<br><tt>point.</tt></blockquote>
<tt>Sure I will! I knew already that what I was not on the right track.
Now I will be able to "start" the right way so its a big improvement. Just
this small snippet tell me lot. It show me how to do things right. Thanks
also for the gtopo answer; now I have two goods starting point.</tt>
<blockquote TYPE=CITE><tt>Craig</tt><tt></tt>
<p><tt>P.S.&nbsp; If you are still interested in the block structure, then
you</tt>
<br><tt>would read the blocks like this:</tt><tt></tt>
<p><tt>bb = bytarr(1024)*nblocks</tt>
<br><tt>readu, lun, bb</tt><tt></tt>
<p><tt>This avoids some extraneous STRING calls.</tt><tt></tt>
<p><tt>--</tt>
<br><tt> ------------------------------------------------------------ -------------- </tt>
<br><tt>Craig B. Markwardt, Ph.D.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;
EMAIL:&nbsp;&nbsp;&nbsp; craigmnet@cow.physics.wisc.edu</tt>
<br><tt>Astrophysics, IDL, Finance, Derivatives | Remove "net" for better
response</tt>
<br><tt> ------------------------------------------------------------ -------------- </tt></blockquote>
<tt>Sylvain Carette</tt>
<br><tt>VRML designer-composer</tt></html>
Re: reading dem [message #21542 is a reply to message #21541] Wed, 30 August 2000 17:36 Go to previous message
Sylvain Carette is currently offline  Sylvain Carette
Messages: 19
Registered: May 2000
Junior Member
I'll guess Explorer is the culprit; try with Netscape...
Consider yourself lucky to have a brand new paperweight on your desk;
parerweight are lot more useful than a boat anchor on your desk.....

ps: I really appreciate your site and advise; its been about a mounth
now I follow this group to get "immersed" into idl problem and I realize
now that "getting started" with idl is lot more difficult than expected.
So, being able to rely on a group like this whith peoples like you help
to feel less anxious. So thanks for your work, and thanks to all of the
others who share some insight.

Sylvain Carette
VRML designer-composer

David Fanning wrote:

> Craig Markwardt (craigmnet@cow.physics.wisc.edu) writes:
>
>> The documentation is here:
>> http://rockyweb.cr.usgs.gov/nmpstds/demstds.html
>
> First of all, I appreciate this gentle advice and
> pointer. This is something I've wondered about to.
> Thanks, Craig.
>
> Second, I realize this isn't the place to be asking
> dumb-ass questions, but you folks are s-o-o-o smart. :-)
>
> Does anyone know why, when I click on an Adobe Acrobat
> File (like the one at the link above), that the Adobe Acrobat
> Reader 4.0 starts up in my Windows Internet Explorer 5.0
> browser and *always* shows me a blank page. :-(
>
> I've reinstalled Explorer. I've reinstalled the Reader.
> I've kicked the dog, cursed my lot in life, etc. But
> all to no avail. If I download the Acrobat file,
> then open the Reader, then open the downloaded file
> all is well. It's a mystery.
>
> Thanks,
>
> David
>
> P.S. I *tried* to install Linux and the Corel Linux
> CD-ROM froze half-way through the installation with
> one OS in shreds and the other partly installed. Now
> all I have is a new paperweight. The installer
> reports a "problem". Ho-boy. :-(
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Re: reading dem [message #21546 is a reply to message #21542] Wed, 30 August 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Sylvain Carette (sylvainc@total.net) writes:

> ps: I really appreciate your site and advise; its been about a mounth
> now I follow this group to get "immersed" into idl problem and I realize
> now that "getting started" with idl is lot more difficult than expected.

You have to be careful drawing too many conclusions
from the marketing materials. IDL is -- and has always
been -- a programming language. There are no real
shortcuts to learning it. But I have thought several
times today that you might find ENVI more to your liking.

> So, being able to rely on a group like this whith peoples like you help
> to feel less anxious.

Well, that's the idea. We've all been stuck and
frustrated. More than once, if memory serves me
correctly. But this is a pretty good group for
keeping things in perspective. (Just don't mention
the Table Widget.)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: reading dem [message #21547 is a reply to message #21546] Wed, 30 August 2000 00:00 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
davidf@dfanning.com (David Fanning) writes:
>
> Second, I realize this isn't the place to be asking
> dumb-ass questions, but you folks are s-o-o-o smart. :-)

Sorry, I don't do windows. :-)

> P.S. I *tried* to install Linux and the Corel Linux
> CD-ROM froze half-way through the installation with
> one OS in shreds and the other partly installed. Now
> all I have is a new paperweight. The installer
> reports a "problem". Ho-boy. :-(

I keep waiting for Linux to be easier to install. It's happening, but
slowly.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: reading dem [message #21549 is a reply to message #21546] Wed, 30 August 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Craig Markwardt (craigmnet@cow.physics.wisc.edu) writes:

> The documentation is here:
> http://rockyweb.cr.usgs.gov/nmpstds/demstds.html

First of all, I appreciate this gentle advice and
pointer. This is something I've wondered about to.
Thanks, Craig.

Second, I realize this isn't the place to be asking
dumb-ass questions, but you folks are s-o-o-o smart. :-)

Does anyone know why, when I click on an Adobe Acrobat
File (like the one at the link above), that the Adobe Acrobat
Reader 4.0 starts up in my Windows Internet Explorer 5.0
browser and *always* shows me a blank page. :-(

I've reinstalled Explorer. I've reinstalled the Reader.
I've kicked the dog, cursed my lot in life, etc. But
all to no avail. If I download the Acrobat file,
then open the Reader, then open the downloaded file
all is well. It's a mystery.

Thanks,

David

P.S. I *tried* to install Linux and the Corel Linux
CD-ROM froze half-way through the installation with
one OS in shreds and the other partly installed. Now
all I have is a new paperweight. The installer
reports a "problem". Ho-boy. :-(

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: reading dem [message #21550 is a reply to message #21546] Wed, 30 August 2000 00:00 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Sylvain,

Part of the problem is that very few people have any direct experience
with what you are trying. Some, including me, offered some general
advice, hoping that would help, but reading byte-level DEM's is not
exactly common knowledge. Also realize that a topic so focussed and
specific as yours is not likely to pique anybody's interst. In the
future you would do better to describe what you need to do at a higher
level, and help us by providing documentation, like I do now.

The documentation is here:
http://rockyweb.cr.usgs.gov/nmpstds/demstds.html

The DEM's are digital elevation maps, and are stored in 1024 byte
blocks. The first block contains a type "A" record. The next blocks
contain a type "B" record which have the actual elevation data. The
actual data start at offset 144 of the record (where offset 0 is the
beginning); there are 1201x1201 elements stored, 146 in the first
1024-block, and then 170 in the successive 1024-blocks. Elevation
values are stored as ASCII format=(I6).

The key thing to realize that all the data is in ASCII, separated by
blanks. Therefore, while we could read each 1024-block in turn, it's
better to just do a formatted READF. There is no need to work at the
byte level, except at the beginning to get to the right file offset.
Unfortunately IDL can only read 32k elements at a time, so I read a
row at a time as a compromise.

pro readdem250, file, im
m = 1201L & n = 1201L ;; Really get this from Type A, element 16
im = lonarr(m, n) ;; Formally defined as INTEGER*4

openr, lun, file, /get_lun
;; Skip past type A record and 144 bytes of Type B record
point_lun, lun, 1024L + 144L

;; Read data, one row at a time
row = im(*,0)
for i = 0, 1200 do begin
readf, lun, row, format='(1201(I6))'
im(*,i) = row
endfor
free_lun, lun
end

Of course I haven't tested this, but you can use this as a starting
point.

Craig

P.S. If you are still interested in the block structure, then you
would read the blocks like this:

bb = bytarr(1024)*nblocks
readu, lun, bb

This avoids some extraneous STRING calls.

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: reading dem [message #21562 is a reply to message #21546] Wed, 30 August 2000 00:00 Go to previous message
Sylvain Carette is currently offline  Sylvain Carette
Messages: 19
Registered: May 2000
Junior Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Sorry error in the listing comments: the&nbsp; bb, bc, bd, be, bf, bg var
hold 170 *int values* per 1040 byte chunk while ba hold 146 and bh hold
35 for a total of 1201 *int value* spread on 8*1024 byte file chunk - hope
it is more clear...
<p>Sylvain Carette wrote:
<blockquote TYPE=CITE><tt>I'm trying to get started with IDL .</tt>
<br><tt>All their examples work fine. But of course, working with my data
didnt work at all...</tt>
<br><tt>Need to read usgs1:250k dem. I'm not sure if I understand the format
but I succeed to</tt>
<br><tt>get the right value using " reads, string(filechunk), var ". Maybe
there is other ways</tt>
<br><tt>with assoc, format, xdr stuff?</tt>
<br><tt>Anyhow, the problem here is that although if I execute each line
of a small procedure</tt>
<br><tt>separately from the console and it work as expected, it doesnt
when i execute the</tt>
<br><tt>procedure. It doesnt even finish the first loop.</tt>
<br><tt>% READS: End of input data encountered: &lt;STRING&nbsp;&nbsp;
('&nbsp;&nbsp; 366&nbsp;&nbsp; 366&nbsp;&nbsp; 359&nbsp; ...')></tt>
<br><tt>% Execution halted at:&nbsp; READDEM250&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
25 C:\RSI\IDL53\project\readdem250.pro</tt>
<br><tt>Why can I execute the first loop cycle from the console and not
from inside the loop?</tt>
<br><tt>What did I miss?</tt>
<br><tt>Below listing -&nbsp; btw, the reason the statements are all written
inline instead of</tt>
<br><tt>inside another loop is that I coulnt get nested loop to work thanks
to wonderful IDL documentation.</tt>
<p><tt>Thanks</tt>
<p><tt>Sylvain Carette</tt>
<br><tt>VRML designer-composer</tt>
<p><tt>pro readdem250</tt>
<br><tt>openr, lun, dialog_pickfile(), /get_lun</tt>
<br><tt>block = assoc( lun, bytarr(1024)) ;the file is divided in 1024
chunk</tt>
<br><tt>im = intarr(1201,1201) ; dem is 1201x1201</tt>
<br><tt>col = intarr(1201) ; one column</tt>
<br><tt>ba = intarr(146) ; to hold one profile stored trough 8*1024 recordB
chunk</tt>
<br><tt>bb = intarr(170) ; first = 146 bytes, last = 35 bytes,</tt>
<br><tt>bc = intarr(170) ; others = 170 bytes, total = 1201 bytes</tt>
<br><tt>bd = intarr(170)</tt>
<br><tt>be = intarr(170)</tt>
<br><tt>bf = intarr(170)</tt>
<br><tt>bg = intarr(170)</tt>
<br><tt>bh = intarr(35)</tt>
<p><tt>for i=1, 1201 do begin ; skip first 1024 chunk, "recordA"</tt>
<br><tt>&nbsp;reads, string(block[146:*,i]), ba ; recordB profile value
begin at byte 146</tt>
<br><tt>&nbsp;reads, string(block[i+1]), bb</tt>
<br><tt>&nbsp;reads, string(block[i+2]), bc</tt>
<br><tt>&nbsp;reads, string(block[i+3]), bd</tt>
<br><tt>&nbsp;reads, string(block[i+4]), be</tt>
<br><tt>&nbsp;reads, string(block[i+5]), bf</tt>
<br><tt>&nbsp;reads, string(block[i+6]), bg</tt>
<br><tt>&nbsp;reads, string(block[0:210,i+7]), bh&nbsp; ; 6 byte/value</tt>
<p><tt>&nbsp;col = [ba, bb, bc, bd, be, bf, bg, bh] ; concatenate all segment
in one profile</tt>
<br><tt>&nbsp;im[i,*] = col</tt>
<br><tt>endfor</tt>
<br><tt>imlr = bytscl(im)</tt>
<br><tt>end</tt></blockquote>
</html>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: contour fill
Next Topic: Minimize windows !

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:52:19 PDT 2025

Total time taken to generate the page: 0.07096 seconds