mapPolys(rworldmap)
mapPolys()所属R语言包:rworldmap
Map polygon data.
图多边形数据。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Plot a map of polygons, from a spatialPolygonsDataFrame, coloured according to one a specified attribute column.
绘制图的多边形,从一个spatialPolygonsDataFrame,彩色根据一个指定的属性列。
用法----------Usage----------
mapPolys( mapToPlot = ""
, nameColumnToPlot = ""
, numCats = 7
, xlim=c(-160,160)
, ylim=c(-80,90)
, mapRegion = "world"
, catMethod="quantiles"
, colourPalette= "heat"
, addLegend=TRUE
, borderCol = 'grey'
, mapTitle = 'columnName'
, oceanCol=NA
, aspect=1
, missingCountryCol=NA
, add=FALSE
)
参数----------Arguments----------
参数:mapToPlot
a spatial polygons dataframe (e.g. from joinData2Map()) containing polygons and associated data, if none specified an internal example data is used
空间的多边形数据框(例如joinData2Map())包含多边形和相关数据的,如果没有指定一个内部的示例数据
参数:nameColumnToPlot
name of column containing the data you want to plot
列名包含要绘制的数据
参数:numCats
number of categories to put the data in, may be modified if this number is incompatible with the catMethod chosen
类别中的数据,可能会被修改,如果这个数字是不符合catMethod选择
参数:xlim
map extents c(west,east), can be overidden by mapRegion
图数据区C区(西部,东部),可以凌驾通过的MapRegion
参数:ylim
map extents c(south,north), can be overidden by mapRegion
图范围是C(南,北),可以凌驾通过的MapRegion
参数:mapRegion
a country name from getMap()[['NAME']] or 'world','africa','oceania','eurasia','uk' sets map extents, overrides xlim,ylim
国家名称的GetMap()[“NAME”或“世界”,“非洲”,“大洋洲”,“欧亚”,“英国将图的程度,覆盖作适当调整,ylim
参数:catMethod
for categorisation of data "pretty", "fixedWidth", "diverging", "logfixedWidth","quantiles","categorical", or a numeric vector defining breaks
分类数据“漂亮”,“固定宽度”,“分歧”,“logfixedWidth”,“位数”,“分类”,或一个数值向量定义截断
参数:colourPalette
string describing the colour palette to use, choice of: <ol> "palette" for the current palette
当前调色板的字符串,用于描述使用的调色板,选择:<OL>的“调色板”
a vector of valid colours, e.g. =c('red','white','blue') or output from RColourBrewer
一个向量的有效的颜色,例如= C(红,白,蓝)或RColourBrewer输出
one of "heat","diverging","white2Black","black2White","topo","rainbow","terrain","negpos8","negpos9" </ol>
之一</ OL>
参数:addLegend
whether to add a legend or not
是否添加图例或
参数:borderCol
the colour for country borders
国家边界的颜色
参数:mapTitle
title to add to the map, any string or 'columnName' to set it to the name of the data column
标题添加到图,任何的字符串或COLUMNNAME“的,将其设置为数据列的名称
参数:oceanCol
a colour for the ocean
海洋的颜色
参数:aspect
aspect for the map, defaults to 1, if set to 'variable' uses same method as plot.Spatial in sp
图方面,默认为1,如果设置为“变量”SP使用相同的方法plot.Spatial
参数:missingCountryCol
a colour for missing countries
缺少国家的颜色
参数:add
whether to add this map on top of an existing map, TRUE/FALSE
是否要添加现有的图,图上TRUE / FALSE
Details
详细信息----------Details----------
Certain catMethod and colourPalette options go well together. e.g. "diverging" and "diverging", "categorical" and "rainbow"
某些catMethod和colourPalette可以融洽相处。例如“分流”和“分流”,“类别”和“彩虹”
There are two styles of legend available. If catMethod='categorical' or the packages fields and spam are not installed a simple legend with coloured boxes is created. Otherwise a colour bar legend is created. Finer control can be achieved by addMapLegendBoxes or addMapLegend repectively.
有两种风格的传奇。如果catMethod =分类或者其包装领域和垃圾邮件的未安装一个简单的传说与彩色框被创建。否则,彩条传说被创建。可以实现更好的控制。addMapLegendBoxes或addMapLegend捣破五个。
值----------Value----------
invisibly returns a list containing the data and main options used for the map, the list can be passed to addMapLegend or addMapLegendBoxes along with additional options to allow greater flexibility in legend creation.
无形地返回一个列表,其中包含的数据,主要用于图的选项,这个列表可以通过addMapLegend或addMapLegendBoxes传说中的创造额外的选项允许更大的灵活性。
(作者)----------Author(s)----------
andy south
参见----------See Also----------
joinData2Map, classInt, RColorBrewer
joinData2Map,classInt,RColorBrewer
实例----------Examples----------
## this example uses downloaded files[#本例中使用下载的文件]
## to run it download the files[#运行下载的文件]
## and remove the comment symbols '#' from all the lines starting with a single '#'[#和删除注释符号#开始的行与一个单一的#]
## US states map downloaded from :[#美国的图下载:]
## http://www2.census.gov/cgi-bin/shapefiles2009/national-files[#http://www2.census.gov/cgi-bin/shapefiles2009/national-files]
#inFile <- 'tl_2009_us_stateec.shp'[INFILE < - tl_2009_us_stateec.shp的]
#sPDF <- readShapePoly(inFile)[SPDF < - readShapePoly(是Infile)]
#str(sPDF@data)[STR(SPDF数据)]
##################[#################]
## use mapPolys to map the sPDF[#使用mapPolys映射SPDF]
#mapPolys(sPDF,nameColumnToPlot = "ALANDEC")[mapPolys(SPDF“,nameColumnToPlot”ALANDEC“)]
#mapPolys(sPDF,nameColumnToPlot = "AWATEREC",mapRegion='North America')[mapPolys(SPDF,nameColumnToPlot =“AWATEREC”,北美的MapRegion =)]
##################[#################]
## join some other data to it[加入一些其他的数据]
## education data downloaded from here as xls then saved as csv[#教育从这里下载为XLS格式的数据,然后保存为CSV]
## http://nces.ed.gov/ccd/drpcompstatelvl.asp[#http://nces.ed.gov/ccd/drpcompstatelvl.asp]
#dataFile <- 'SDR071A_xls.csv'[数据文件< - “SDR071A_xls.csv”的]
#dF <- read.csv(dataFile,as.is=TRUE)[DF < - read.csv(DATAFILE,as.is TRUE)]
#str(dF)[STR(DF)]
## STATENAME[#STATENAME]
## DRP912 Dropout Rate, Grades 9 through 12[DRP912 9到12年级辍学率,]
## joining the data to the map[#加入数据的图]
## based upon state names (column NAMEEC in map, and STATENAME in the data)[#根据国家名(列NAMEEC图,STATENAME的数据中)]
#sPDF2 <- joinData2Map(dF[sPDF2 < - joinData2Map(DF]
# , nameMap = sPDF[nameMap = SPDF]
# , nameJoinIDMap = "NAMEEC"[,nameJoinIDMap =“NAMEEC”]
# , nameJoinColumnData = "STATENAME")[nameJoinColumnData =“STATENAME”)]
#################[################]
## plot one of the attribute variables[#图的属性变量]
#mapDevice()# to set nice shape map window[mapDevice()#设置造型美观大方图窗口]
#mapPolys(sPDF2,nameColumnToPlot = "DRP912",mapRegion='North America')[mapPolys(sPDF2,nameColumnToPlot =“DRP912”,北美的MapRegion =)]
#################[################]
###to map US counties data (Tiger) downloaded from :[##图美国的县(虎)下载:]
##http://www2.census.gov/cgi-bin/shapefiles2009/national-files[#http://www2.census.gov/cgi-bin/shapefiles2009/national-files]
#inFile <- 'tl_2009_us_county.shp'[INFILE < - tl_2009_us_county.shp的]
#sPDF <- readShapePoly(inFile)[SPDF < - readShapePoly(是Infile)]
#str(sPDF@data)[STR(SPDF数据)]
#mapPolys(sPDF,nameColumnToPlot='AWATER',xlim=c(-140,-65), ylim=c(25,45))[mapPolys(SPDF的,nameColumnToPlot =自来水,XLIM = C(-140,-65),ylim = C(25,45))]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|