Section |
---|
Column |
---|
|
|
Column |
---|
| Panel |
---|
Objectives
- Set-up a cylindrical projection over the United States.
- Apply land-sahding shading on the coastlines.
- Load a grib file containing Mean-Sea level Presssure and visualise it using black isolines.
- Load a grib file containing Precipitation and visualise it using shading technique.
- Add a legend.
- Add a text.
- Draw the position of New-York City
- Draw a line to materialise the Xsection we are going to visualise in a next tutorial
You will need to download
|
|
|
...
Section |
---|
Column |
---|
| Info |
---|
|
subpage_lower_left_longitude | subpage_lower_left_latitude | subpage_upper_right_longitude | subpage_upper_right_latitude |
|
Code Block |
---|
theme | Confluence |
---|
language | python |
---|
title | Python - Setting a projection |
---|
collapse | true |
---|
| from Magics.macro import *
#setting the output
output = output(
output_formats = ['png'],
output_name = "map_step1",
output_name_first_page_number = "off"
)
#settings of the geographical area
area = mmap(subpage_map_projection="cylindrical",
subpage_lower_left_longitude=-110.,
subpage_lower_left_latitude=20.,
subpage_upper_right_longitude=-30.,
subpage_upper_right_latitude=70.,
)
#Using a default coastlines to see the result
plot(output, area, mcoast()) |
|
Column |
---|
|
|
|
Setting the coastlines
Until now you have used the mcoast to add coastlines to your plot. The mcoast object comes with a lot of parameters to allow you to style your coastlines layer.
The full list of parameters can be found in the Coastlines documentation.
In this first exercise, we will like to see:
- The land coloured in cream.
- The coastlines in grey.
- The grid as a grey dash line.
...
|
map_coastline_land_shade | map_coastline_land_shade_colour | map_coastline_colour | map_grid_colour | map_grid_line_style |
|
|
|
Have a look at the PNG output documentation to see which parameters are available to set-up a PNG output.
To create a PNG output Magics, you have to create an output object and to insert at the first position in the plot command
...
Code Block |
---|
theme | Confluence |
---|
language | python |
---|
title | Python - |
---|
|
|
| Output | from Magics.macro import *
|
|
#settings of png
output_formats = ['png'],
|
| magics output_name_first_page_number = "off"
)
#settings of the geographical area
area = mmap(subpage_map_projection="cylindrical",
|
|
#The plot commad will create a png output called magics.png subpage_lower_left_longitude=-110.,
subpage_lower_left_latitude=20.,
subpage_upper_right_longitude=-30.,
subpage_upper_right_latitude=70.,
)
#settings of the caostlines
coast = mcoast(map_coastline_land_shade = "on",
map_coastline_land_shade_colour = "cream",
map_grid_line_style = "dash",
map_grid_colour = "grey",
map_label = "on",
map_coastline_colour = "grey")
plot(output, |
| mcoast()) |
Setting the coastlines
The object mcoast allows the parametrisation of the coastlines.
Have a look at the Coastlines documentation to see which parameters are available.
To configure the look of your coastlines you have to create a mcoast object with the parameters you want.
Column |
---|
| Image Added |
|
Visualising the Mean Sea Level Pressure field
The visualisation of any data in Magics is done by combining 2 kind of objects. One is used to define the data and explain to Magics how to interpret it, the other one is called Visual Action and will define the rules for visualisation. In this example our data are definedThe mcoast object has to be inserted in the plot command.
Section |
---|
Column |
---|
| Info |
---|
|
map_coastline_land_shade | map_coastline_land_shade_colour | map_coastline_colour | map_grid_colour | map_grid_line_style |
|
Code Block |
---|
theme | Confluence |
---|
language | python |
---|
title | Python - Coastlines |
---|
collapse | true |
---|
| from Magics.macro import *
#settings of#setting the png output
output = output(
output_formats = ['png'],
output_name = "coastmap_step2",
output_name_first_page_number = "off"
)
##settings#settings of the coastlinesgeographical attributesarea
coastarea = mcoast(
mmap(subpage_map_projection="cylindrical",
subpage_lower_left_longitude=-110.,
subpage_lower_left_latitude=20.,
subpage_upper_right_longitude=-30.,
subpage_upper_right_latitude=70.,
)
#settings of the caostlines
coast = mcoast(map_coastline_land_shade = "on",
map_coastline_land_shade_colour = "cream",
map_grid_line_style = "dash",
map_grid_colour = "browngrey",
map_label_colour = "brownon",
map_coastline_colour = "browngrey"
)
#The plot command will now use the coast object
plot(output, area, coast) |
|
Column |
---|
| Image Added Image Removed |
|
Adding a text
Magics allows the user to add of or several lines of text. The position of the text is by default above the plot, but some parameters aloow it to be moved around.
...