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

Home » Public Forums » archive » Re: problems converting to Cylindrical (longitude-latitude)
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: problems converting to Cylindrical (longitude-latitude) [message #42405] Mon, 07 February 2005 13:48 Go to next message
Chris[2] is currently offline  Chris[2]
Messages: 39
Registered: August 2003
Member
Hi Jeff,

MAP_PROJ_IMAGE is used to convert from either lon/lat coordinates to a map
projection (U/V coordinates), or from one map projection to another map
projection. In either case, the result is always in U/V (Cartesian)
coordinates, not in longitude/latitude.

So even though you are converting to the Cylindrical projection, that is
still in Cartesian coordinates, hence the huge (but correct) numbers.
However, since the Cylindrical projection is just a simple scaling from
lon/lat to U/V, you can convert back to lon/lat by just dividing by the
Earth radius. Here is your program, modified to convert back to lon/lat at
the end. I also put in some gratuitous iMap calls, for those running IDL6.1.

-Chris
Research Systems, Inc.

; Data are in Albers Equal-Area; output is to be Cylindrical.
; Albers projection parameters
spar1 = 20
spar2 = 60
clon = -103
clat = 45
; Corners of images (in meters) as stated in metadata.
xmin = -1567000.0
xmax = 277000.0
ymin = -1760000.0
ymax = 694000.0
xyrange = [xmin, ymin, xmax, ymax]

; Compute !MAP structure for each projection.
mapIn = map_proj_init('Albers Equal Area', datum='Clarke 1866', $
standard_par1=spar1, standard_par2=spar2, $
center_longitude=clon, center_latitude=clat)
mapOut = map_proj_init('Cylindrical', datum='Sphere')

; Input image is imgIn. Compute output image.
imgIn = dist(100)
imgOut = map_proj_image(imgIn, xyrange, image_structure=mapIn, $
map_structure=mapOut, uvrange=uvRange)

print, 'U range=', uvRange[[0,2]]
print, 'V range=', uvRange[[1,3]]

; To convert to lon/lat, divide by Earth radius.
print, 'lon range=', uvRange[[0,2]]/6370997*(180/!PI)
print, 'lat range=', uvRange[[1,3]]/6370997*(180/!PI)


; Keep the first image in Albers projection.
iMap, imgIn, GRID_UNITS=1, $ ; meters
IMAGE_DIMENSIONS=[xmax-xmin, ymax-ymin], $
IMAGE_LOCATION=[xmin, ymin], $
MAP_PROJECTION='Albers Equal Area', datum='Clarke 1866', $
standard_par1=spar1, standard_par2=spar2, $
center_longitude=clon, center_latitude=clat, $
LIMIT=[10, -130, 60, -70], $
VIEW_GRID=[2, 1]

it = ITGETCURRENT(TOOL=oTool)
void = oTool->DoAction('Operations/Insert/Map/Continents')

iMap, imgIn, GRID_UNITS=1, $ ; meters
IMAGE_DIMENSIONS=[xmax-xmin, ymax-ymin], $
IMAGE_LOCATION=[xmin, ymin], $
MAP_PROJECTION='Albers Equal Area', datum='Clarke 1866', $
standard_par1=spar1, standard_par2=spar2, $
center_longitude=clon, center_latitude=clat, $
LIMIT=[20, -130, 60, -70], $
/VIEW_NEXT

void = oTool->DoAction('Operations/Insert/Map/Continents')

; Warp second image from Albers to Cylindrical.
oMap = oTool->GetByIdentifier('Operations/Operations/Map Projection')
oMap->SetProperty, SHOW_EXECUTION_UI=0, $
MAP_PROJECTION='Equirectangular', $ ; same as cylindrical
DATUM='Sphere'
void = oTool->DoAction('Operations/Operations/Map Projection')
oMap->SetProperty, SHOW_EXECUTION_UI=1

end


"Jeff DLB" <jeffdlb@erols.com> wrote in message
news:1107788794.384267.35840@z14g2000cwz.googlegroups.com...
> I'm having trouble converting images to Cylindrical (longitude-
> latitude) coordinates. My input data are in Albers Equal-Area
> and cover the western US. When I convert to lon-lat coordinates
> I get output images and bounds that are clearly wrong. I must be
> misusing MAP_PROJ_INIT and MAP_PROJ_IMAGE, but am not sure how.
> Any suggestions would be welcome.
>
> Here's what I have tried:
>
> ; Data are in Albers Equal-Area; output is to be Cylindrical.
> ; Albers projection parameters
> spar1 = 20
> spar2 = 60
> clon = -103
> clat = 45
> ; Corners of images (in meters) as stated in metadata.
> xmin = -1567000.0
> xmax = 277000.0
> ymin = -1760000.0
> ymax = 694000.0
> xyrange = [xmin, ymin, xmax, ymax]
>
> ; Compute !MAP structure for each projection.
> mapIn = map_proj_init('Albers Equal Area', datum='Clarke 1866', $
> standard_par1=spar1, standard_par2=spar2, $
> center_longitude=clon, center_latitude=clat)
> mapOut = map_proj_init('Cylindrical', datum='Sphere')
>
> ; Input image is imgIn. Compute output image.
> imgOut = map_proj_image(imgIn, xyrange, image_structure=mapIn, $
> map_structure=mapOut, uvrange=latLonRange)
> print, lonLatRange
> -14014183. 3207349.0 -10991525. 5658023.0
>
>
> The resulting UVRANGE values are clearly not within +/-360 E-W, +/-180
> N-S.
> The image metadata states the lon-lat bounds are
> lower left lat 28.8444, lon -119.7528
> upper left lat 49.2565, lon -126.0326
> upper right lat 50.8321, lon -98.8492
> lower right lat 30.0061, lon -100.0084
>
> Thanks for any suggestions,
> Jeff DLB
> Reprojection newbie
>
Re: problems converting to Cylindrical (longitude-latitude) [message #42490 is a reply to message #42405] Tue, 08 February 2005 12:37 Go to previous messageGo to next message
Jeff DLB is currently offline  Jeff DLB
Messages: 2
Registered: February 2005
Junior Member
Chris Torrence wrote:
> However, since the Cylindrical projection is just a simple scaling
from
> lon/lat to U/V, you can convert back to lon/lat by just dividing by
the
> Earth radius.

Thank you for the information! The mention of lat/lon in MAP_PROJ_IMAGE
and Chapter 19 - Map Projections suggested degrees would be the output
units. I should have realized I was getting arclength rather than
angle.

Regards,
Jeff DLB
Re: problems converting to Cylindrical (longitude-latitude) [message #42941 is a reply to message #42405] Sun, 27 February 2005 19:12 Go to previous message
sri_sri is currently offline  sri_sri
Messages: 1
Registered: February 2005
Junior Member
I tried to run the code sent by Chris and it is giving me this error
imgOut = map_proj_image(imgIn,xyrange, image_structure=mapIn, $

% Syntax error.
At: F:\sur\test_proj.pro, Line 22
% 1 Compilation error(s) in module $MAIN$.

it is showing the error at xyrange.
I am using IDL 6.0.1 on win 2000
Any help would be highly appreciated.I am trying to project UTM data to
SOM using the same procedure.

Thanks,
Sri
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: psconfig problem
Next Topic: coordinates & transforms & plotting

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

Current Time: Wed Oct 08 13:46:02 PDT 2025

Total time taken to generate the page: 0.00705 seconds