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

Home » Public Forums » archive » Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file?
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
Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file? [message #71469] Fri, 25 June 2010 01:55 Go to next message
Harry Kim is currently offline  Harry Kim
Messages: 16
Registered: April 2010
Junior Member
Hi, all. I would like to add the coastline on my solar zenith angle
(SOLZA) image layers on Korean Peninsula retrieved from MODIS 07
atmospheric profile product. These images were georeferenced on the
basis of the information in the geolocation fields (data set # 0 and
1, latitude and longitude, respectively) of MODIS 07 HDF file. In
order to add the high resolution coastline, I downloaded
Map_GSHHS_shoreline (David Fanning, 2008).

However, at least in my understanding so far, Map_GSHHS_shoreline
seems to draw a coastline on a blank window, and I have no idea how to
link this procedure to the classical MODIS image-processing method.
Please take a look at my sourcecode and give me any suggestions,
especially section 3.2.

I know that someone in this forum may not like the idea to post a full
source code here. I am sorry if I am bothering him, but I hope this
humble source code can help others to begin MODIS data processing in
near future.

Thank you very much in dvance.



----------------------------------------

PRO MOD07_MakeImage_solza_062310 ; Ta, Td, Solza only

;*********************************************************** **************
;******** 1. Preprocessing.
*********
;*********************************************************** **************

; 1.1. Designate paths of workspace and output image folders.
WorkSp07 = 'E:\MODIS07\MOD07_Workspace\'
WorkSpOut07 = 'E:\MODIS07\Image_output\'
batch_st07 = strcompress(WorkSp07+'List_MOD07.txt',/remove_all)
WorkSpHDF = 'E:\MODIS07\MOD07\'

numDates = file_lines(batch_st07)
Dates = StrArr(numDates)

; 1.2. Read input dates from batch file
OpenR, lun, batch_st07, /Get_lun
ReadF, lun, Dates
Free_Lun, lun, /force

FOR j = 0, numDates-1 DO BEGIN
;FOR j = 0, 50 DO BEGIN

s_time = systime(1)

print, "Now processing MOD07 data from date: ", Dates[j], '
File ', j+1, ' out of ', numDates

; 1.3. Open HDF files.

HDFname = WorkSpHDF+Dates[j]

FileOpen = HDF_OPEN(HDFname, /Read)
sdFileID = HDF_SD_Start(HDFname, /Read)
sdsID_lat = HDF_SD_Select(sdFileID, 0)
sdsID_lon = HDF_SD_Select(sdFileID, 1)
sdsID_SOLZA = HDF_SD_Select(sdFileID, 3)

hdf_sd_getdata, sdsID_lat, lat
hdf_sd_getdata, sdsID_lon, lon
hdf_sd_getdata, sdsID_lon, SOLZA_temp

ENVI_WRITE_ENVI_FILE, lat, out_name='lat_temp.img'
ENVI_WRITE_ENVI_FILE, lon, out_name='lon_temp.img'

envi_open_file, 'lat_temp.img', r_fid=lat_fid
envi_open_file, 'lon_temp.img', r_fid=lon_fid
envi_file_query, lat_fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)

;*********************************************************** **************
;** 2. CONSTRUCTING GLT FILE FOR GEOREFERENCING **
;*********************************************************** **************
; 2.1. Designate datum and projection name.

DATUM = 'Tokyo mean'
Projection_Name = 'Korea - TM (Middle)'
Params = [6377397.2, 6356079.0, 38.000000, 127.002890, 200000.0,
500000.0, 1.000000]

IN_proj = ENVI_PROJ_CREATE(/Geographic)
OUT_Proj = ENVI_PROJ_CREATE(type=3, name=Projection_Name,
datum=Datum, params=Params)

;2.2. Building GLT file for georeferencing
ENVI_DOIT, 'ENVI_GLT_DOIT', DIMS=dims, I_PROJ=IN_proj,
O_PROJ=OUT_proj, R_FID=GLT_fid,$
ROTATION=0, X_FID=lon_fid,
X_POS=pos[0], Y_FID=lat_fid, Y_POS=pos[0], out_name='GLT.img'

;2.3. Scale HDF data to physical values
SOLZA = CONV_PHYSICAL(sdsID_SOLZA, SOLZA_temp) ; SOLAR zenith
angle [degrees]

;*********************************************************** **************
;** 3. Add Korea TM coordinates on georeferenced files *********
;*********************************************************** **************

;3.1. Printout these arrays on image files.

StrDate = STRMID(Dates[j], 10,7)
StrFile = STRMID(Dates[j], 10, 12)
StrTime = STRMID(Dates[j], 18, 4)
StrSat = STRMID(Dates[j], 0, 5)

ENVI_WRITE_ENVI_FILE, SOLZA, out_name='SOLZA_temp.img'
envi_open_file, 'SOLZA_temp.img', r_fid=SOLZA_fid
envi_file_query, SOLZA_fid, ns=ns, nl=nl, nb=nb
pos = lindgen(nb)

out_name_SOLZA = WorkSpOut07+StrSat+'/'+StrDate+'/'+StrSat+StrFile
+'_SOLZA0_5km'+'.img'
ENVI_DOIT, 'ENVI_GEOREF_FROM_GLT_DOIT', FID=SOLZA_fid,
GLT_FID=GLT_fid, POS=pos, R_fid=SOLZA_G_fid, out_name=out_name_SOLZA

; 3.2. Add coast lines for Korean penninsular. - not yet
completed...!!!
Set_plot, 'z'
datafile = 'C:\Program Files\ITT\IDL708\lib
\GSHHS_2.0\gshhs_h.b'
Device, set_resolution = [500, 350]
pos = [0.1,0.1, 0.9, 0.8]
Map_Set, 37.0, 127.0, Position=pos, Scale=15e6, /Mercator, /
NoBorder
Polyfill, [pos[0], pos[0], pos[2], pos[2], pos[0]], $
[pos[1], pos[3], pos[3], pos[1], pos[1]], $
/Normal, Color=FSC_Color('Almond')
Map_GSHHS_Shoreline, datafile, Level=3, /Outline
b = tvrd()
write_jpeg, 'test09.jpg', b

;*********************************************************** **************
;****** 4. Finish up the image processing
*************
;*********************************************************** **************

; 4.1. Clean memories.

NextHdf:

ENVI_FILE_MNG, ID=lat_fid, /remove ;, /Delete
ENVI_FILE_MNG, ID=lon_fid, /remove ;, /Delete
ENVI_FILE_MNG, ID=SOLZA_G_fid, /remove

NextHdf_2:

; 4.2. Done with SDS, close the interface

HDF_SD_ENDACCESS,SdsID_LAT
HDF_SD_ENDACCESS,SdsID_LON
HDF_SD_ENDACCESS,SdsID_SOLZA
HDF_SD_END,sdFileID
HDF_CLOSE,FileOpen

Close, /all, /force

ENDFOR

e_time = systime(1)

print, "It's done!!! Elapsed time for this procedure: ", e_time -
s_time

close, /all

END
Re: Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file? [message #71518 is a reply to message #71469] Tue, 29 June 2010 22:34 Go to previous messageGo to next message
Harry Kim is currently offline  Harry Kim
Messages: 16
Registered: April 2010
Junior Member
Thanks, Dave. That must be the most efficient alternative in my case.
Would you let me know how to do that in programming way in IDL?

*.SHP file or *.evf will be OK, maybe.

Harry
Re: Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file? [message #71528 is a reply to message #71469] Tue, 29 June 2010 03:21 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Jun 29, 2:36 am, Harry Kim <kim4ecohy...@gmail.com> wrote:
> Mmmm... I am really sorry to hear that. (T.T) However, I did not give
> this up, and I found an alternative in Envi main menu.
>
> 1) Open my image and go to the ENVI main menu. -> Vector -> Create
> world boundaries -> check [2] Coastlilnes (High Res)
>
> 2) Bounding Lat/Lon Coordinates . In my case.
> Lat min: 30; Lat max: 50
> Lon min: 120; Lon max: 140
>
> 3) Output results to File
> Enter output root Filename : Test001 -> then click OK.
>
> Then available vector layer is shown on the table.
>
> 4) Then click 'Load Selected' and choose the image that I opend in 1)
> (In this case, display #1)
> Now I got the coastline in my image.
>
> 5) save using write_jpeg.
>
> However, I cannot do this manually since I have to do this over 1700
> images per year from 2000 to 2009. I have to complete this through
> programming.
> Can you give me any suggestions? Thanks, in advance.
>
> Harry
How about to save data as vector file like *.SHP file and just load
that every time?
D.
Re: Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file? [message #71529 is a reply to message #71469] Tue, 29 June 2010 02:36 Go to previous messageGo to next message
Harry Kim is currently offline  Harry Kim
Messages: 16
Registered: April 2010
Junior Member
Mmmm... I am really sorry to hear that. (T.T) However, I did not give
this up, and I found an alternative in Envi main menu.


1) Open my image and go to the ENVI main menu. -> Vector -> Create
world boundaries -> check [2] Coastlilnes (High Res)

2) Bounding Lat/Lon Coordinates . In my case.
Lat min: 30; Lat max: 50
Lon min: 120; Lon max: 140

3) Output results to File
Enter output root Filename : Test001 -> then click OK.

Then available vector layer is shown on the table.

4) Then click 'Load Selected' and choose the image that I opend in 1)
(In this case, display #1)
Now I got the coastline in my image.

5) save using write_jpeg.

However, I cannot do this manually since I have to do this over 1700
images per year from 2000 to 2009. I have to complete this through
programming.
Can you give me any suggestions? Thanks, in advance.

Harry
Re: Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file? [message #71556 is a reply to message #71469] Sun, 27 June 2010 17:55 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Harry Kim writes:

> "I guess what I am saying is, even if you could figure out how to make
> a vector layer from the GSHHS data, I'm not sure you
> are going to be happy with the result. It just seems to me that this
> is one of those few things that ENVI is not very good at."
>
> Would you let me know how to do this please?

If I knew how to do that, I would have probably
written an article about it already. :-(

You will have to ask someone who knows more about ENVI
than I do. Sorry.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Add GSHHS coastline on georeferenced image layers retrieved from MODIS HDF file? [message #71609 is a reply to message #71518] Wed, 30 June 2010 03:17 Go to previous message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Jun 29, 10:34 pm, Harry Kim <kim4ecohy...@gmail.com> wrote:
> Thanks, Dave. That must be the most efficient alternative in my case.
> Would you let me know how to do that in programming way in IDL?
>
>  *.SHP file or *.evf will be OK, maybe.
>
> Harry

Help> Overview of ESRI Shape files. There are some examples show how
to read shape file to IDL and after reading the identities you can
easily over plot on your data.
Cheers
Dave
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Reading complicated ASCII data
Next Topic: Re: problem is ther in my progam how to solve this problem

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

Current Time: Wed Oct 08 11:32:31 PDT 2025

Total time taken to generate the page: 0.00790 seconds