goodmap
function is designed to create interactive PNG Map or GIF Map from a provided data file.
It supports two types of maps: point
and polygon
.
The function can visualize data by either plotting points based on geographical coordinates
or highlighting regions polygon based on their administrative boundaries (province or city level).
Additionally, the function can generate animated that showcase the change of data.If the map type is point
, the color and size of the points will be determined by the
value_set
column in the data file, which means the different value of each point.
If the map type is polygon
, the color of the polygons will be determined by the average
value of the value_set
column for each city or province in the data file.
goodmap(
data_file,
type = "point",
level = NULL,
animate = FALSE,
animate_var = NULL,
map_center = c(35.8617, 104.1954),
zoom_level = 4,
color_type = "numeric",
custom_colors = NULL,
point_radius = 5,
legend_opacity = 0.7,
legend_name = NULL,
width = 800,
height = 900
)
Image in the viewer.
Dataframe.
When generate point map, data_file
should include required columns such as g_lat
and g_lon
.
When generate polygon map, data_file
should include required columns such as prov
or city
.
The prov
columns must be complete, official names rather than any shortened form or abbreviation.
If there is only incomplete names or geocodes in your data_file, we recommend you to use function regioncode
as a one-step solution to these conversion from incomplete names.
Ensure the file is formatted correctly with appropriate column headers.
A string specifying the type of map to generate. Options are point
for point maps using g_lat
and g_lon
,
or polygon
for maps with administrative boundaries.
A string specifying the level of administrative boundaries for polygon maps.
Acceptable values are province
or city
. This parameter is required if type
is polygon
.
A logical value indicating whether to generate an animation from the maps. The default is FALSE. If animate is FALSE, the whole data will be generated as a PNG file. If animate is TRUE, an animation will be generated from all panel data, the animate_var must be assigned.
A string specifying the variable to animate over.
The default is NULL
, the whole data will be generated as a PNG file.
If an animation is needed, data_file
should include required the animate_set
column.
animate_set
includes a series of unique values that represents year or month, or other categorical variable.
The frame number of the animation depends on the animate_set
.
A numeric vector of length 2 specifying the latitude and longitude
for the center of the map view. Default is c(35.8617, 104.1954)
, which
is approximately the center of China.
A numeric value specifying the zoom level for the map. Default is 3.
If the data is discrete, such as types or categories, choose factor
.
If the data is continuous, such as temperature or pressure, choose numeric
. Default is numeric.
A vector of colors for customizing the color gradient. Default is NULL
,
which uses the predefined color palette.
A numeric value specifying the radius for point markers on point maps. Default is 5.
A numeric value specifying the opacity of the legend. Default is 0.7.
The name of the legend. Default is Value
.
A numeric value specifying the width of the map images. Default is 800.
A numeric value specifying the height of the map images. Default is 900.
# \donttest{
goodmap(
toy_poly,
type = "polygon",
level = "province"
)
# }
Run the code above in your browser using DataLab