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 
Switch to threaded view of this topic Create a new topic Submit Reply
Error with MapProjection::Forward [message #86661] Wed, 27 November 2013 03:17 Go to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Hello,

Following the example at http://www.exelisvis.com/docs/ImageWithMapProjection.html

I have prepared the following IDL program for my requirement:

;-------------------------
PRO MELPITZ_GOOGLE_PLOT

CLOSE,/ALL

; DOWNLOAD A MAP
url = "http://maps.googleapis.com/maps/api/staticmap?" + $
"center=51.525517,12.927633&zoom=14&size=600x600" + $
"&maptype=satellite&sensor=true"

netObject = IDLnetURL()
!null = netObject.Get(URL=url, FILENAME="melpitz.png")
netObject = 0

; Load the newly created file
READ_PNG, "melpitz.png", img

; DISPLAY THE MAP IMAGE WITH THE MAP PROJECTION

centerLon = 12.927633D
centerLat = 51.525517D
zoom = 14
Re = 6378137D ; Radius of the Earth
resolution = (2*!DPI*Re)/(256*2D^zoom) ; meters/pixel
PRINT, resolution

; The image is 600 pixel wide by 600 pixel tall
deltax = 600*resolution ; meters
deltay = 600*resolution ; meters

; Convert the map center to spherical Mercator coordinates
; Create a hidden map object to do the conversions.
m = MAP('Mercator',/BUFFER, $
SEMIMAJOR_AXIS=6378137D, SEMIMINOR_AXIS=6378137D)
uv = m.Forward(centerLon, centerLat)

; Compute the image bounding box in spherical Mercator coordinates
x0 = uv[0] - deltax/2 ; meters
x1 = uv[0] + deltax/2 ; meters
y0 = uv[1] - deltay/2 ; meters
y1 = uv[1] + deltay/2 ; meters
m.Close

PRINT, [x0, y0, x1, y1]

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

I am using IDL Version 8.0 (linux x86_64 m64). (c) 2010, ITT Visual Information Solutions. When I run above IDL procedure, I get the following error:

IDL> .r MELPITZ_GOOGLE_PLOT.pro
% Loaded DLM: URL.
% Compiled module: MELPITZ_GOOGLE_PLOT.
IDL> MELPITZ_GOOGLE_PLOT
% Compiled module: READ_PNG.
% Loaded DLM: PNG.
9.5546285
% Loaded DLM: XML.
% Attempt to call undefined method: 'MAPPROJECTION::MAPFORWARD'.
% Execution halted at: MELPITZ_GOOGLE_PLOT 34

I tried to search in Google for the possible solution to the problem but could not resolve. Am I missing some function files? Please suggest me to resolve this issue and go forward.

Thanks in advance
Re: Error with MapProjection::Forward [message #86663 is a reply to message #86661] Wed, 27 November 2013 05:23 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> I tried to search in Google for the possible solution to the problem but could not resolve. Am I missing some function files? Please suggest me to resolve this issue and go forward.

This appears to be a typo. Try this, instead:

uv = m.mapForward(centerLon, centerLat)

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.")
Re: Error with MapProjection::Forward [message #86665 is a reply to message #86663] Wed, 27 November 2013 05:56 Go to previous messageGo to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
I tried this but still it doesn't work. My corrected code is as below:
; -------------------------------
PRO MELPITZ_GOOGLE_PLOT

CLOSE,/ALL

; DOWNLOAD A MAP
url = "http://maps.googleapis.com/maps/api/staticmap?" + $
"center=51.525517,12.927633&zoom=14&size=600x600" + $
"&maptype=satellite&sensor=true"

netObject = IDLnetURL()
!null = netObject.Get(URL=url, FILENAME="melpitz.png")
netObject = 0

; Load the newly created file
READ_PNG, "melpitz.png", img

; DISPLAY THE MAP IMAGE WITH THE MAP PROJECTION

centerLon = 12.927633D
centerLat = 51.525517D
zoom = 14
Re = 6378137D ; Radius of the Earth
resolution = (2*!DPI*Re)/(256*2D^zoom) ; meters/pixel
PRINT, resolution

; The image is 600 pixel wide by 600 pixel tall
deltax = 600*resolution ; meters
deltay = 600*resolution ; meters

; Convert the map center to spherical Mercator coordinates
; Create a hidden map object to do the conversions.
; Setup map projection, draw a grid
m = MAP('Mercator',/BUFFER, $
SEMIMAJOR_AXIS=6378137D, SEMIMINOR_AXIS=6378137D, $
CENTER_LONGITUDE=centerLon,LIMIT=[51.515D,12.91D,51.540D,12. 95D])
print,m
; Convert from longitude/latitude to meters
uv = m.MapForward(centerLon, centerLat)

; Compute the image bounding box in spherical Mercator coordinates
x0 = uv[0] - deltax/2 ; meters
x1 = uv[0] + deltax/2 ; meters
y0 = uv[1] - deltay/2 ; meters
y1 = uv[1] + deltay/2 ; meters
m.Close

PRINT, [x0, y0, x1, y1]

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

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.

Regards


On Wednesday, November 27, 2013 2:23:47 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> I tried to search in Google for the possible solution to the problem but could not resolve. Am I missing some function files? Please suggest me to resolve this issue and go forward.
>
>
>
> This appears to be a typo. Try this, instead:
>
>
>
> uv = m.mapForward(centerLon, centerLat)
>
>
>
> 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.")
Re: Error with MapProjection::Forward [message #86666 is a reply to message #86665] Wed, 27 November 2013 06:02 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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.")
Re: Error with MapProjection::Forward [message #86669 is a reply to message #86666] Wed, 27 November 2013 08:04 Go to previous messageGo to next 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.")
Re: Error with MapProjection::Forward [message #86670 is a reply to message #86669] Wed, 27 November 2013 08:38 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> 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?

I'm not sure what you mean by "low resolution". My guess is that you are
referring to Hershey fonts in the display window. Yes, they are not as
nice as the function graphics fonts. This is usually not much of a
problem, since the point of Coyote Graphics is to produce "high
resolution" raster and PostScript output. The "low resolution" you see
will be fixed as soon as you try to share your result with someone. :-)

If you mean by "low resolution" that you want to zoom into the area
more, you do that by setting the zoom factor. Setting the zoom to 18 or
20 spreads the points out.

> (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?

I'm not sure I understand this question, but it is probably related to
too much hard-coding of numbers in the code I wrote. I could make it
more general by using the Keep_Aspect keyword on the cgImage command and
by using the "output" position of the image in the window as the
position for the map projection (with the OPOS keyword to cgImage). You
can use the Aspect keyword to cgDisplay to match the aspect ratio of the
image, if that is what you want.

I'll see if I can find the time today (I am suppose to be cleaning the
house for my wife while she cooks!) to make the change.

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

I guess I would use the Color keyword to specify whatever color you wanted.

numColors = N_Elements(geo_lon)
cgLoadCT, 33, NColors=numColors
cgPlotS, geo_lon, geo_lat, COLOR=Bindgen(numColors), $
PSYM=16, SYMSIZE=1.2,MAP_OBJECT=mapCoord

You put text near a point by using the location of the point and
"offsetting" the location a bit. I find the ALIGNMENT keyword to cgText
to be useful when doing this. This always requires some trial and error
to get things looking the way you want them to. There is no general way
to do this. If I want the offset distance in device coordinates, I have
to make sure to translate device coordinates to data coordinates. This
is the purpose of the Convert_Coord function in IDL.

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.")
Re: Error with MapProjection::Forward [message #86671 is a reply to message #86669] Wed, 27 November 2013 08:54 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> ; 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

I just noticed that you are trying to recover a 1200x1200 image from
Google. The maximum size of an image returned from Google using this
Google API is 640x640. In fact, this is the size of the image returned
by this command. Maybe that is what you meant by "low resolution". If
so, then I guess we are stuck with it. You can try complaining to
Google. :-)

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.")
Re: Error with MapProjection::Forward [message #86672 is a reply to message #86671] Wed, 27 November 2013 09:08 Go to previous messageGo to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Thanks for more info. I have the following google static map:
http://maps.googleapis.com/maps/api/staticmap?center=51.5255 17,12.927633&zoom=14&size=600x600&maptype=satell ite&sensor=true

After running my program above by correcting size and window to 600 by 600,
I find that the image from the above link of google statics is enlarged in area and covers more portion of above/below, side-ways in comparison to the above link image. Is there a way I can provide the limits of lat-lon axis that I want to overlay on the google statics map? Can you please elaborate how the lat-lon axis is overlayed onto this google statics map for which the center lat and center lon are only provided with zoom factor? It would be of great help if you can provide me some information on this.

Thanks in advance

On Wednesday, November 27, 2013 5:54:24 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> ; 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
>
>
>
> I just noticed that you are trying to recover a 1200x1200 image from
>
> Google. The maximum size of an image returned from Google using this
>
> Google API is 640x640. In fact, this is the size of the image returned
>
> by this command. Maybe that is what you meant by "low resolution". If
>
> so, then I guess we are stuck with it. You can try complaining to
>
> Google. :-)
>
>
>
> 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.")
Re: Error with MapProjection::Forward [message #86673 is a reply to message #86672] Wed, 27 November 2013 10:15 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> After running my program above by correcting size and
> window to 600 by 600, I find that the image from the above l
> ink of google statics is enlarged in area and covers more
> portion of above/below, side-ways in comparison to the above
> link image.

I don't understand what this means. When I make the same changes to my
code (from your program) the map coordinates *exactly* match the image,
which is exactly what they are suppose to do. If you would like to "zoom
into" your image, you will have to trim both the image and the xrange
and yrange limits of the map coordinate object appropriately

> Is there a way I can provide the limits of lat-lon axis that I
> want to overlay on the google statics map?

A vector of X and Y projected meter values associated with the image can
be constructed like this:

dims = Image_Dimensions(googleImage, XSIZE=xsize, YSIZE=ysize)
xvec = cgScaleVector(Dindgen(xsize) + 1, xrange[0], xrange[1])
yvec = cgScaleVector(Dindgen(ysize) + 1, yrange[0], yrange[1])

If you wanted to trim 50 pixels of the left of the image and 100 pixels
off the right of the image. You might do something like this:

googleImage = googleImage[*, 50:xsize-100, *]

You will have to re-define your xrange accordingly:

xrange = [xvec[50],xvec[xsize-100]]

Here is the code I'm using.

PRO Google_Map_Plot

; Set up variables for the plot. Normally, these values would be
; passed into the program as positional and keyword parameters.
centerLat= 51.525517D ; (Max(Lats) + Min(Lats)) / 2.0 deg. N
centerLon= 12.927633D ; (Max(Lons) + Min(Lons)) / 2.0 deg. E
zoom = 16
scale = cgGoogle_MetersPerPixel(zoom)

; 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=600x600" + $
"&maptype=satellite&sensor=false&format=png32"
netObject = Obj_New('IDLnetURL')
void = netObject -> Get(URL=googleStr, FILENAME="googleimg.png")
Obj_Destroy, netObject
googleImage = Read_Image('googleimg.png')

; Set up the map projection information to be able to draw on top
; of the Google map.
map = Obj_New('cgMap', 'Mercator', ELLIPSOID='WGS 84', /OnImage)
uv = map -> Forward(centerLon, centerLat)
uv_xcenter = uv[0,0]
uv_ycenter = uv[1,0]
xrange = [uv_xcenter - (300*scale), uv_xcenter + (300*scale)]
yrange = [uv_ycenter - (300*scale), uv_ycenter + (300*scale)]

; Trim the image and xrange 50 pixels on left and 100 on right.
dims = Image_Dimensions(googleImage, XSIZE=xsize, YSIZE=ysize)
xvec = cgScaleVector(Dindgen(xsize) + 1, xrange[0], xrange[1])
yvec = cgScaleVector(Dindgen(ysize) + 1, yrange[0], yrange[1])
googleImage = googleImage[*, 50:xsize-100, *]
xrange = [xvec[50],xvec[xsize-100]]


map -> SetProperty, XRANGE=xrange, YRANGE=yrange

; Open a window and display the Google Image with a map grid and
; location of Coyote's favorite prairie dog restaurant.
cgDisplay, 700, 700, Title='Google Image with Coyote Graphics'
cgImage, googleImage[0:2,*,*], /Keep_Aspect, $
Position=[50, 50, 650, 650] / 700., OPOS=opos
map -> SetProperty, POSITION=opos
cgMap_Grid, MAP=map, /BOX_AXES, /cgGRID
cgPlotS, -105.1, 40.6, PSYM='filledstar', SYMSIZE=3.0, $
MAP=map, COLOR='red'

; 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)

numColors = N_Elements(geo_lon)
cgLoadCT, 33, NColors=numColors
cgPlotS, geo_lon, geo_lat, COLOR=Bindgen(numColors), $
PSYM=16, SYMSIZE=1.2,MAP_OBJECT=map

END ;*********************************************************** ******



--
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.")
Re: Error with MapProjection::Forward [message #86674 is a reply to message #86673] Wed, 27 November 2013 10:41 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> A vector of X and Y projected meter values associated with the image can
> be constructed like this:
>
> dims = Image_Dimensions(googleImage, XSIZE=xsize, YSIZE=ysize)
> xvec = cgScaleVector(Dindgen(xsize) + 1, xrange[0], xrange[1])
> yvec = cgScaleVector(Dindgen(ysize) + 1, yrange[0], yrange[1])
>
> If you wanted to trim 50 pixels of the left of the image and 100 pixels
> off the right of the image. You might do something like this:
>
> googleImage = googleImage[*, 50:xsize-100, *]
>
> You will have to re-define your xrange accordingly:
>
> xrange = [xvec[50],xvec[xsize-100]]

By the way, these are the details of how this is done, more or less. In
practice, I would use cgClipToMap from the Coyote Library to do this in
one go. :-)

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.")
Re: Error with MapProjection::Forward [message #86678 is a reply to message #86670] Wed, 27 November 2013 12:50 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I'm not sure I understand this question, but it is probably related to
> too much hard-coding of numbers in the code I wrote. I could make it
> more general by using the Keep_Aspect keyword on the cgImage command and
> by using the "output" position of the image in the window as the
> position for the map projection (with the OPOS keyword to cgImage). You
> can use the Aspect keyword to cgDisplay to match the aspect ratio of the
> image, if that is what you want.

I have updated this code to make the program a little more general in
nature.

http://www.idlcoyote.com/gallery/google_map_plot.zip

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.")
Re: Error with MapProjection::Forward [message #86679 is a reply to message #86678] Thu, 28 November 2013 01:28 Go to previous messageGo to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
This is very useful and more general code.

One more clarification is required. Can you provide me an example of inserting a text by the side of the symbol plotting with cgPlotS or some other tool?

Thanks in advance David!


On Wednesday, November 27, 2013 9:50:21 PM UTC+1, David Fanning wrote:
> David Fanning writes:
>
>
>
>> I'm not sure I understand this question, but it is probably related to
>
>> too much hard-coding of numbers in the code I wrote. I could make it
>
>> more general by using the Keep_Aspect keyword on the cgImage command and
>
>> by using the "output" position of the image in the window as the
>
>> position for the map projection (with the OPOS keyword to cgImage). You
>
>> can use the Aspect keyword to cgDisplay to match the aspect ratio of the
>
>> image, if that is what you want.
>
>
>
> I have updated this code to make the program a little more general in
>
> nature.
>
>
>
> http://www.idlcoyote.com/gallery/google_map_plot.zip
>
>
>
> 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.")
Re: Error with MapProjection::Forward [message #86683 is a reply to message #86679] Thu, 28 November 2013 05:23 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> This is very useful and more general code.
>
> One more clarification is required. Can you provide me an example of inserting a text by the side of the symbol plotting with cgPlotS or some other tool?

Add this code to the end of the example you found on the Gallery page:

; Add a label for the restaurant.
xy = map -> Forward(-105.1, 40.6)
loc = Convert_Coord(xy[0], xy[1], /Data, /To_Normal)
cgText, loc[0], loc[1]+0.025, 'Prairie Dog Restaurant', /Normal, $
Alignment=0.5, Color='red', Font=0

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.")
Re: Error with MapProjection::Forward [message #86690 is a reply to message #86683] Thu, 28 November 2013 06:52 Go to previous messageGo to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Thanks ... It works!

Is it possible to reduce the size of the text (on the .ps file)?

Thanks in advance.

On Thursday, November 28, 2013 2:23:20 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> This is very useful and more general code.
>
>>
>
>> One more clarification is required. Can you provide me an example of inserting a text by the side of the symbol plotting with cgPlotS or some other tool?
>
>
>
> Add this code to the end of the example you found on the Gallery page:
>
>
>
> ; Add a label for the restaurant.
>
> xy = map -> Forward(-105.1, 40.6)
>
> loc = Convert_Coord(xy[0], xy[1], /Data, /To_Normal)
>
> cgText, loc[0], loc[1]+0.025, 'Prairie Dog Restaurant', /Normal, $
>
> Alignment=0.5, Color='red', Font=0
>
>
>
> 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.")
Re: Error with MapProjection::Forward [message #86691 is a reply to message #86690] Thu, 28 November 2013 06:57 Go to previous messageGo to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Sorry ... I got my answer. 'charsize' controls the size of text.

Thanks for the clarifications.

On Thursday, November 28, 2013 3:52:41 PM UTC+1, Madhavan Bomidi wrote:
> Thanks ... It works!
>
>
>
> Is it possible to reduce the size of the text (on the .ps file)?
>
>
>
> Thanks in advance.
>
>
>
> On Thursday, November 28, 2013 2:23:20 PM UTC+1, David Fanning wrote:
>
>> Madhavan Bomidi writes:
>
>>
>
>>
>
>>
>
>>> This is very useful and more general code.
>
>>
>
>>>
>
>>
>
>>> One more clarification is required. Can you provide me an example of inserting a text by the side of the symbol plotting with cgPlotS or some other tool?
>
>>
>
>>
>
>>
>
>> Add this code to the end of the example you found on the Gallery page:
>
>>
>
>>
>
>>
>
>> ; Add a label for the restaurant.
>
>>
>
>> xy = map -> Forward(-105.1, 40.6)
>
>>
>
>> loc = Convert_Coord(xy[0], xy[1], /Data, /To_Normal)
>
>>
>
>> cgText, loc[0], loc[1]+0.025, 'Prairie Dog Restaurant', /Normal, $
>
>>
>
>> Alignment=0.5, Color='red', Font=0
>
>>
>
>>
>
>>
>
>> 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.")
Re: Error with MapProjection::Forward [message #86692 is a reply to message #86690] Thu, 28 November 2013 07:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> Is it possible to reduce the size of the text (on the .ps file)?

The CHARSIZE keyword is traditionally used for this purpose. ;-)

Of course, you will have to use True-Type or Hershey fonts when you do
this. Hardware fonts can't be resized.

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
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 11:32:35 PDT 2025

Total time taken to generate the page: 0.00514 seconds