Before we get started with the tutorial, it is recommended that you learn how to make your own basemaps (see tutorial on making basemaps here). However, if you want to skip learning how to make basemaps for now, I will provide the basemap needed for this tutorial. The basemap provided will be the same basemap used in the above example. To download this basemap to your computer, simply right click on the image below and choose "Save Image As..." and save it to your GrADS folder.
|Save this image, as your basemap for this tutorial|
So, now that you have your basemap, lets get started. Plotting data onto a basemap is very simple, and requires very little extra code. All you need to do is add a few extra options onto the 'printim' command, when you are outputting your data to an image.
- Normal: 'printim img.png png x800 y600'
- Basemap: 'printim img.png png x800 y600 -b basemap.png -t 0'
And that's pretty much all there is to overlaying your data onto a basemap.
There are however a few things to watch out for. Since all you are essentially doing when you include the -b option, is printing your GrADS plot onto a preexisting image, you need to make sure all the image dimensions match. To do this there are really only three things that you need to remember:
- Your GrADS page area (parea) matches the page area on your basemap
- Your image dimensions are equal (you can get your image dimensions by right clicking your image and looking at 'properties')
- Your lat/lon boundaries must be the same between the basemap domain and the GrADS domain
Now, that you have an idea on how to do it, here are the correct dimensions for the basemap provided here.
Image Dimensions: x=800px, y=600px
Parea: '0.5 10.0 0.5 7.5'
latitude: 22, 51
longitude: -128, -65
So if you were to use these dimensions in a script to plot radar, your code might look like:
'set mpdset hires'
'set lat 22 51'
'set lon -128 -65' ;*Depending on the dataset, you may need to add 360 to this
'set display color white'
'set parea 0.5 10.0 0.5 7.5' ;*Note the page area is equal to the basemap
'set gxout shaded'
'set ccols 0 14 4 11 5 13 19 7 12 8 2 6' ;*Note that the 0 is the specified transparent color
'set clevs 5 10 15 20 25 30 35 40 45 50 55 60 65'
'printim img.png png -b basemap.png -t 0 x800 y600' ;*x800, y800 correspond to the image dimensions
That about does it for this tutorial, you should now be able to overlay images onto preexisting basemaps. And just for fun, and so you know, your background image does not necessarily have to be a map.
I hope you enjoyed, and found this tutorial useful!