reportcompiler_ic_tools.maps¶
This module contains helper functions to plot maps from the HPV Information Centre data.
Functions¶
generate_map(): This function returns a map plot with the specified options.
-
reportcompiler_ic_tools.maps.generate_map(data, region, value_field, iso_field='iso', scale_params=None, plot_na_dots=False, tolerance=None, plot_size=8, out_region_color='#f0f0f0', na_color='#aaaaaa', line_color='#666666', projection=None)¶ This function returns a map plot with the specified options.
Parameters: - data (pandas.DataFrame) – Data to be plotted.
- region (str) – Region to center the map around. Countries outside the chosen region will be obscured.
- value_field (str) – Column of data with the values to be plotted.
- iso_field (str) – Column of data with the ISO3 codes for each country.
- scale_params (dict) – Dictionary of parameters to be passed to the ggplot corresponding color scale (continuous or discrete).
- plot_na_dots (bool) – Whether to plot the dots for small countries if said country doesn’t have data available.
- tolerance (int) – Coordinate tolerance for polygon simplification, a higher number will result in simpler polygons and faster rendering (see DEFAULT_TOLERANCES).
- plot_size (int) – Size of the plot, which determines the relative sizes of the elements within.
- out_region_color (str) – Hex color of the countries that are out of the specified region.
- na_color (str) – Hex color of the countries with no data available.
- line_color (str) – Color of the country borders.
- projection (str) – Kind of map projection to be used in the map. Currently, Oceania (XOX) is only available in ESPG:4326 to enable wrapping.
Returns: a ggplot-like plot with the map
Return type: plotnine.ggplot
Variables¶
-
reportcompiler_ic_tools.maps.DEFAULT_TOLERANCES¶ Default tolerances for polygon simplification in different regions by projection.
{'epsg4326': {'XEX': 0.1, 'XFX': 0.2, 'XMX': 0.4, 'XOX': 0.4, 'XSX': 0.2, 'XWX': 0.6}, 'robinson': {'XEX': 13000, 'XFX': 26000, 'XMX': 40000, 'XOX': None, 'XSX': 32000, 'XWX': 40000}}
-
reportcompiler_ic_tools.maps.DOT_THRESHOLD¶ A dot will be plotted for countries with areas below this percentage of the total shown map area.
1e-05
-
reportcompiler_ic_tools.maps.REGION_BOUNDS¶ Region bounds by projection coordinates
{'epsg4326': {'XEX': ([-32, 80], [103, 35]), 'XFX': ([-25, 38], [56, -38]), 'XMX': ([-165, 80], [-15, -60]), 'XOX': ([110.049387, 23.214162], [241.54582, -51.583946]), 'XSX': ([28, 57], [155, -16]), 'XWX': ([-163, 80], [163, -60])}, 'robinson': {'XEX': ([-2500000, 8200000], [5000000, 3800000]), 'XFX': ([-1580000, 3800000], [5580000, -4040000]), 'XMX': ([-14500000, 8000000], [-1000000, -5700000]), 'XOX': None, 'XSX': ([2500000, 5800000], [13000000, -970000]), 'XWX': ([-16000000, 8000000], [16000000, -6000000])}}
-
reportcompiler_ic_tools.maps.PROJECTION_DICT¶ Pyproj projections.
{'epsg4326': {}, 'robinson': {'proj': 'robin'}}