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

Home » Public Forums » archive » Error with MapProjection::Forward
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Error with MapProjection::Forward [message #86669 is a reply to message #86666] Wed, 27 November 2013 08:04 Go to previous messageGo to previous message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
I did attempt to write IDL code by using your graphics tools. My goal was to overlay the points on Google static map with the link:
http://maps.googleapis.com/maps/api/staticmap?center=51.5255 17,12.927633&zoom=14&size=1200x1200&maptype=sate llite&sensor=true

Below is my code:

; ----------------------------
PRO Melpitz_GooglePlot

CLOSE,/ALL

; Set up variables for the plot
centerLat= 51.525517D ; (Max(Lats) + Min(Lats)) / 2.0 deg. N
centerLon= 12.927633D ; (Max(Lons) + Min(Lons)) / 2.0 deg. E
zoom=14
scale=cgGoogle_MetersPerPixel(zoom)
; resolution = (2*!DPI*Re)/(256*2D^zoom)
; Re = 6378137D - radius of Earth
PRINT, scale
googleImageFilename='melpitzgoogleimg.png'

IF FILE_TEST(googleImageFilename) THEN BEGIN
googleImage = READ_PNG(googleImageFilename)
ENDIF ELSE BEGIN

; Gather the Google Map using the Google Static Map API
googleStr="http://maps.googleapis.com/maps/api/staticmap?" + $
"center=" + StrTrim(centerLat,2) + ',' + StrTrim(centerLon,2) + $
"&zoom=" + StrTrim(zoom,2) + "&size=1200x1200" + $
"&maptype=satellite&sensor=true&format=png32" ; terrain/satellite/hybrid

netObject = Obj_New('IDLnetURL')
void = netObject -> Get(URL=googleStr, FILENAME=googleImageFilename)
Obj_Destroy, netObject
googleImage = Read_PNG(googleImageFilename)
s=SIZE(googleImage,/DIMENSIONS)
;googleImage = Read_Image('melpitzgoogleimg.png')
ENDELSE

; Set up the map projection information to be able to draw on top
; of the Google map.

mapCoord = Obj_New('cgMap', 'Mercator', ELLIPSOID='WGS 84', /OnImage)
xy = mapCoord -> Forward(centerLon, centerLat)
xrange = [xy[0,0] - (1200*scale), xy[0,0] + (1200*scale)]
yrange = [xy[1,0] - (1200*scale), xy[1,0] + (1200*scale)]
mapCoord -> SetProperty, XRANGE=xrange, YRANGE=yrange
PRINT, xrange, yrange

; Open display window - Google Image with a map grid
cgDisplay, 720, 800

; Show the Google image on the track
cgImage, googleImage[0:2,*,*],Position=[50, 50, 550, 550]/600.
cgMap_Grid, MAP=mapCoord,LINESTYLE=0,THICK=2,/BOX_AXES,/CGGRID,/LABEL

; Overlay the points on the map
geo_lon=[ 12.928891,12.926434,12.925875,12.922277,12.913507,12.925407, $
12.927663,12.927191,12.928041,12.926399,12.925676,12.926233, $
12.942073,12.927199,12.927197,12.927209,12.941039,12.922861, $
12.925361,12.928772,12.937340,12.927910,12.926749,12.929081, $
12.930733,12.917927,12.937282,12.940540,12.931345,12.920242, $
12.927734,12.934965,12.913434,12.926365,12.925563,12.925388, $
12.926150,12.927432,12.928548,12.925627,12.928129,12.927163, $
12.928032,12.929043,12.919992,12.931943,12.927277,12.928178, $
12.916696,12.926318]


geo_lat=[51.525643,51.528963,51.529627,51.526104,51.526895, $
51.525046,51.525569,51.525998,51.529957,51.526427,51.525457, $
51.525176,51.527107,51.525662,51.525315,51.524935,51.520126, $
51.522013,51.525613,51.526004,51.525096,51.526548,51.525709, $
51.518588,51.522657,51.525658,51.519825,51.536149,51.526332, $
51.519956,51.535018,51.531251,51.518749,51.525994,51.525979, $
51.524687,51.525668,51.521689,51.526567,51.526391,51.525455, $
51.526486,51.525986,51.525204,51.528715,51.527705,51.522675, $
51.525066,51.534141,51.524814]

PRINT, MAX(geo_lon),MIN(geo_lon),MAX(geo_lat),MIN(geo_lat)

cgPlotS, geo_lon, geo_lat, COLOR='yellow', $
PSYM=16, SYMSIZE=1.2,MAP_OBJECT=mapCoord


END ;*********************************************************** ******
; This main program shows how to call the program and produce
; various types of output.

; Display the plot in a graphics window.
Melpitz_GooglePlot

; Display the plot in a resizeable graphics window
cgWindow,'Melpitz_GooglePlot',WXSIZE=600,WYSIZE=600,WASPECT= 600./600, $
WTitle='Melpitz',WBackground='white'

; Create a PostScript file.
PS_Start, 'melpitz_googleplot.ps'
Melpitz_GooglePlot
PS_End

; Create a PNG file with a width of 600 pixels.
cgPS2Raster, 'melpitz_googleplot.ps', /PNG, /Portrait

END
;----------------------------------------------

The problems I noticed are ...

(1) The google static map link provided top of my code shows a high resolution map while the lat-lon axis overlaying google map in the code is at a low resolution. I wanted to have the map at a high resolution because my overlaying points are very close by. Can you where I am going wrong?

(2) I guess I am doing something wrong with cgDisplay and cgImage while providing the dimensions. How to provide these dimensions for any google static map while overlaying the axis?

(3) Can anyone provide me an example to include different colors for my points with CgPlots and also text / label near the point?

Please help understand properly if I am going wrong in my code.

Thanks and regards

On Wednesday, November 27, 2013 3:02:18 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> I get the same error message ...
>
>> % Attempt to call undefined method: 'MAPPROJECTION::MAPFORWARD'.
>
>> % Execution halted at: MELPITZ_GOOGLE_PLOT 38
>
>>
>
>> I don't have any clue now!!! Any help to solve this issue will be of great help.
>
>
>
> Well, you have IDL 8.0, which was the absolute buggiest version of IDL
>
> ever when it came to these new function graphics routines. If you want
>
> to use function graphics I think you will have to upgrade to the latest
>
> version, which is quite a bit better. (Your code ran in IDL 8.2.3.)
>
>
>
> The other alternative is to use Coyote Graphics to make your Google map.
>
> (It will probably look better, too.) You can find an example of what you
>
> are trying to do and code to do this in the Coyote Plot Gallery:
>
>
>
> http://www.idlcoyote.com/gallery/index.html
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Rounding errors and the New Graphics image routine
Next Topic: ENVI_OPEN_FILE not found

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

Current Time: Wed Oct 08 17:51:18 PDT 2025

Total time taken to generate the page: 0.00286 seconds