Basic cgMap and cgMapPlotS tutorial [message #81402] |
Mon, 17 September 2012 10:26  |
Brian Daniel
Messages: 80 Registered: July 2009
|
Member |
|
|
I've never worked much with maps in IDL, so now that I need to, I thought I'd start with the Coyote tools. From the documentation, the cgMapPlotS object seems like exactly what I need, which is to plot specific lat/lons onto a map with continents or other shapefiles on top.
Here's my code:
center_lat = 36.099510
center_lon = -5.3362050
latXRange = [35.905270, 36.171590]
lonYRange = [-5.6205900, -5.0512100]
; Create cgMap object
oMap = Obj_New('cgMap', 'UTM', /LatLon_Ranges, $
Center_Latitude=center_lat,Center_Longitude=center_lon,$
XRange=latXRange,YRange=lonYRange, /Window,$
Position=[0.05,0.95,0.05,0.95],Title='cgMap Test',Land_Color='brown')
print, latXRange, lonYRange
The above code prints:
4669305.1 4713144.8
-801136.78 -722963.25
So latRange and lonRange's values were changed, I'm assuming to be in units of meters. center_lat/lon values are unchanged. Then, I attempt to create a cgMapPlotS object to plot the center_lat and center_lon position with a symbol:
oMapPlotS = Obj_New('cgMapPlotS', oMap, color='red', Lats=center_lat, Lons=center_lon, PSym=1 )
I get the following error:
CGMAPPLOTS::INIT--> CGCONTAINER::INIT: Incorrect number of arguments.
The only argument asked of cgMapPlotS is that of a cgMap object, which I provided. What am I missing?
Thanks in advance!
-Brian
|
|
|
Re: Basic cgMap and cgMapPlotS tutorial [message #81479 is a reply to message #81402] |
Wed, 19 September 2012 12:36  |
Brian Daniel
Messages: 80 Registered: July 2009
|
Member |
|
|
On Monday, September 17, 2012 1:26:32 PM UTC-4, Brian J. Daniel wrote:
> I've never worked much with maps in IDL, so now that I need to, I thought I'd start with the Coyote tools. From the documentation, the cgMapPlotS object seems like exactly what I need, which is to plot specific lat/lons onto a map with continents or other shapefiles on top.
>
>
>
> Here's my code:
>
>
>
> center_lat = 36.099510
>
> center_lon = -5.3362050
>
> latXRange = [35.905270, 36.171590]
>
> lonYRange = [-5.6205900, -5.0512100]
>
>
>
> ; Create cgMap object
>
> oMap = Obj_New('cgMap', 'UTM', /LatLon_Ranges, $
>
> Center_Latitude=center_lat,Center_Longitude=center_lon,$
>
> XRange=latXRange,YRange=lonYRange, /Window,$
>
> Position=[0.05,0.95,0.05,0.95],Title='cgMap Test',Land_Color='brown')
>
>
>
> print, latXRange, lonYRange
>
>
>
> The above code prints:
>
> 4669305.1 4713144.8
>
> -801136.78 -722963.25
>
>
>
> So latRange and lonRange's values were changed, I'm assuming to be in units of meters. center_lat/lon values are unchanged. Then, I attempt to create a cgMapPlotS object to plot the center_lat and center_lon position with a symbol:
>
>
>
> oMapPlotS = Obj_New('cgMapPlotS', oMap, color='red', Lats=center_lat, Lons=center_lon, PSym=1 )
>
>
>
> I get the following error:
>
>
>
> CGMAPPLOTS::INIT--> CGCONTAINER::INIT: Incorrect number of arguments.
>
>
>
> The only argument asked of cgMapPlotS is that of a cgMap object, which I provided. What am I missing?
>
>
>
> Thanks in advance!
>
> -Brian
Whew! I thought I was going crazy. Thanks for the update.
|
|
|
Re: Basic cgMap and cgMapPlotS tutorial [message #81499 is a reply to message #81402] |
Mon, 17 September 2012 14:33  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Brian J. Daniel writes:
> I've never worked much with maps in IDL, so now that I need to, I thought I'd start with the Coyote tools. From the documentation, the cgMapPlotS object seems like exactly what I need, which is to plot specific lat/lons onto a map with continents or other shapefiles on top.
>
> Here's my code:
>
> center_lat = 36.099510
> center_lon = -5.3362050
> latXRange = [35.905270, 36.171590]
> lonYRange = [-5.6205900, -5.0512100]
>
> ; Create cgMap object
> oMap = Obj_New('cgMap', 'UTM', /LatLon_Ranges, $
> Center_Latitude=center_lat,Center_Longitude=center_lon,$
> XRange=latXRange,YRange=lonYRange, /Window,$
> Position=[0.05,0.95,0.05,0.95],Title='cgMap Test',Land_Color='brown')
>
> print, latXRange, lonYRange
>
> The above code prints:
> 4669305.1 4713144.8
> -801136.78 -722963.25
>
> So latRange and lonRange's values were changed, I'm assuming to be in units of meters. center_lat/lon values are unchanged. Then, I attempt to create a cgMapPlotS object to plot the center_lat and center_lon position with a symbol:
>
> oMapPlotS = Obj_New('cgMapPlotS', oMap, color='red', Lats=center_lat, Lons=center_lon, PSym=1 )
>
> I get the following error:
>
> CGMAPPLOTS::INIT--> CGCONTAINER::INIT: Incorrect number of arguments.
>
> The only argument asked of cgMapPlotS is that of a cgMap object, which I provided. What am I missing?
Well, this is sort of embarrassing. :-(
This cgMapPlotS program is not suppose to be in the Coyote Library.
I had very nice mapping functionality in the Catalyst Library, but
it seemed too complicated to me to bring it over to the Coyote Library.
I wanted something much simpler there.
Anyway, long story short, this was an experiment that I quickly gave
up on. I don't think I ever really tested the darn thing, because
what you found here is clearly a bug that dates back to it's Catalyst
origin. It is one of several bugs in the program, I think.
Rather, I turned my attention to making the cgPlotS command work on
maps in exactly the same way it worked on normal plots. The cgPlotS
command would be called like this:
cgPlotS, center_lon, center_lat, PSYM=1, color='red', MAP=oMap
Unfortunately, even this wouldn't work with your code,
however, as I think you have gotten a bit confused about
which direction lats (Y direction) and lons (X direction)
go in.
Getting all this sorted out, your code will look like this:
center_lat = 36.099510
center_lon = -5.3362050
latYRange = [35.905270, 36.171590]
lonXRange = [-5.6205900, -5.0512100]
oMap = Obj_New('cgMap', 'utm', /LatLon_Ranges, $
Center_Latitude=center_lat,Center_Longitude=center_lon,$
XRange=lonXRange, YRange=latYRange, $
Position=[0.1,0.1,0.90,0.90],Title='cgMap Test',$
Land_Color='brown', /Window)
cgPlotS, center_lon, center_lat, PSYM=1, color='red', MAP=oMap, /AddCmd
cgMap_Grid, /Box_Axes, Map=oMap, /AddCmd
Note, too, that your "center_lat" and "center_lon" values
are not exactly in the center of your map ranges. Thus,
your point is not drawn in the center of the map. :-)
Sorry for the confusion. I'll see what I can do to get
rid of that strange program.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|