找回密码
 注册
查看: 3646|回复: 0

R语言 shapefiles包 shapefiles()函数中文帮助文档(中英文对照)

  [复制链接]
发表于 2012-9-30 01:49:46 | 显示全部楼层 |阅读模式
shapefiles(shapefiles)
shapefiles()所属R语言包:shapefiles

                                        Read and write ESRI shapefiles
                                         读写ESRI shapefile的

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This package includes functions to read and write ESRI shapefiles.
这个软件包包括ESRI Shapefile文件读取和写入的功能。


用法----------Usage----------


read.shapefile(shape.name)
read.shp(shp.name)
read.shx(shx.name)
read.dbf(dbf.name, header=FALSE)
write.shapefile(shapefile, out.name, arcgis=FALSE)
write.shp(shp, out.name)
write.shx(shx, out.name)
write.dbf(dbf, out.name, arcgis=FALSE)
calc.header(shapefile)
add.xy(shapefile)
scaleXY(shapefile, scale.factor)
convert.to.shapefile(shpTable, attTable, field, type)
convert.to.simple(shp)
change.id(shpTable, newFieldAsVector)
dp(points, tolerance)




参数----------Arguments----------

参数:shape.name
String of the shapefile file name without an extension
字符串的shapefile文件名不带扩展名


参数:shp.name
String of the shp file name with an extension
shp文件名的扩展名的字符串


参数:shx.name
String of the shx file name with an extension
一个扩展的字符串的shx文件名,


参数:dbf.name
String of the dbf file name with an extension
dbf文件名的扩展名的字符串


参数:shapefile
The shapefile object of lists created by read.shapefile
shapefile中的对象列表创建的read.shapefile


参数:out.name
Filename to write the data to
FILENAME将数据写入到


参数:shp
shp portion (list) of the shapefile object of lists
小水电部分的shapefile对象的列表(列表)


参数:shx
shx portion (list) of the shapefile object of lists
SHX部分的shapefile对象的列表(列表)


参数:dbf
dbf portion (list) of the shapefile object of lists
DBF部分的shapefile对象的列表(列表)


参数:scale.factor
Number to divide the shapefile geography by
数来划分的shapefile的GEO


参数:arcgis
Replace "." with "\_" in column names for ArcGIS
代替“。” “\ _”在列名的ArcGIS


参数:shpTable
data.frame with columns in order Id, X, and Y
数据框订单ID列,X和Y


参数:attTable
data.frame with first column names "Id" - polygon id (key)
数据框的第一列名“ID” - 多边形ID(键)


参数:type
ESRI Shape type 1=point, 3=polyLine, 5=polygon
ESRI Shape类型点,1 = 3 = 5 =多段线,多边形


参数:field
A field name in the attTable
中的字段名的attTable


参数:newFieldAsVector
A vector of Ids to replace to the Ids in the shpTable
IDS的矢量更换的ID在shpTable


参数:points
A named list of two vectors (x and y) representing points
命名的代表点的两个向量(x和y)


参数:tolerance
A tolerance setting for the DP polyLine simplification algorithm
容差设置为DP多段线简化算法


参数:header
Should read.dbf return the header?
如果read.dbf返回头?


Details

详细信息----------Details----------

ESRI shapefiles consist of three files.  The first file (*.shp) contains the geography  of each shape.  The second file (*.shx) is an index file which contains record offsets. The third file (*.dbf) contains feature attributes with one record per feature.   <br> <br> read.shapefile calls read.shp, read.shx, and read.dbf to read in an entire shapefile.  The result of read.shapefile is a list of many more lists.  The sublists are shp, shx, and dbf.  Each sublist contains a header list and some sort of data list.  The shp list is a list of  $shp$header and $shp$shp.  The shx list is a list of  $shx$header and $shx$index.  The dbf list is a list of  $dbf$header and $dbf$dbf.   <br> <br> The write functions write out a shp, shx, and dbf file from the shapefile list structure. To write out a shapefile from simple R data, you need to run convert.to.shapefile.   The inputs to this function are a simple data frame of points (for points, polyLines, or polygons) and a data frame representing the dbf file.  Examples are below. <br><br> The package reads shape types 1 (point), 3 (polyLine), 5 (polygon), 13 (polyLineZ),  and 15 (polygonZ).  Reading of shape type 13 and 15 from Don MacQueen, macq@llnl.gov <br><br> The package writes shape types 1 (point), 3 (polyLine), 5 (polygon), 13 (polyLineZ),  and 15 (polygonZ).  Conversion of simple polygons to shapefile format from Manuel  Chirouze, Manuel.Chirouze@benfieldgroup.com <br><br> For simple features, the only difference between polyLines and polygons is that the first  and last point is the same for a polygon.  The convert.to.simple function can be used to simplify the shp file to a simple data.frame.  The change.id function can then be used to change the Id field for the simple shp data.frame to a field from a data.frame (dbf). <br> <br> For details about the ESRI shapefile structure refer to  http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf.  A detailed description of DBF files can be found at http://www.e-bachmann.dk/docs/xbase.htm.  The arcgis argument to write.dbf replaces "." with "\_" in field names since ArcGIS does not allow the former.  Note that the read.dbf and write.dbf functions in the foreign package are now used for reading and writing dbfs, which greatly improves the speed of  reading/writing dbfs. <br><br> Function dp is an implementation of the Douglas-Peucker polyLine simplification algorithm.  Douglas, D. and Peucker, T. (1973). "Algorithms for the reduction of the number of points required to represent a digitized line or its caricature." The Canadian Cartographer 10(2). 112-122.  dp currently uses the line, not the line segment to determine the distance of the points from the line. This can result in the omission of extreme "outlier-like" points. See http://www.lgc.com/resources/Doug_Peucker.pdf for more information.
ESRI shape文件包括三个文件。第一个文件(*。马力)包含每个形状的GEO环境。第二个文件(*。SHX)是一个索引文件,其中包含记录偏移量。第三个文件(*。dbf)包含的特征属性与每一个记录功能。参考参考read.shapefileread.shp, read.shx和read.dbf在读一个完整的shapefile。 read.shapefile的结果是多列表的列表。子列表shp,shx和dbf。每个子列表包含一个标题列表和某种类型的数据列表。的马力列表是一个$shp$header和$shp$shp。的SHX列表是一个$shx$header和$shx$index。的DBF列表是一个$dbf$header和$dbf$dbf。参考参考的写函数写了一个从的shapefile文件列表结构SHP,SHX,和dbf文件。写出来的shapefile,从简单的R数据,你需要运行convert.to.shapefile。这个函数的输入点(点,线,多边形)一个简单的数据框和数据框的dbf文件。实施例以下。参考参考包读取的形状类型(点),3(折线),5(多边形),13(polyLineZ),15(polygonZ)。从唐MacQueen,macq@llnl.gov参考参考阅读的形状类型13和15包写的形状类型(点),3(折线),5(多边形),,13(polyLineZ),和15( polygonZ)。转换Shapefile格式从曼努埃尔Chirouze的,Manuel.Chirouze benfieldgroup.com参考<br>对于简单的功能,简单的多边形,折线和多边形之间的唯一区别是多边形的第一个和最后一个点是一样的。 convert.to.simple功能可用于简化shp文件,一个简单的数据框。 change.id函数可以用来改变简单的马力数据框的ID字段的字段从数据框(DBF)。 ESRI的shapefile结构的有关的详细信息,请参阅<BR> <BR>到http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf。 DBF文件的详细说明可以发现在http://www.e-bachmann.dk/docs/xbase.htm。 arcgiswrite.dbf参数替换“。” “\ _”由于ArcGIS中的字段名不允许前。需要注意的是read.dbf和write.dbf在国外的包现在用于阅读和写作dBFS的,这大大提高的速度读/写dBFS的。参考参考功能dp  - 道格拉斯 - 普克多段线简化算法的实现。道格拉斯D.普克,T.(1973)。 “算法需要的点的数量来表示一个数字化的线或它的漫画的减少。”加拿大制图10(2)。 112-122。 dp目前使用的线,以确定从线的各点的距离的线段。这可能会导致在极端“离群点状”点遗漏。更多信息,请参见http://www.lgc.com/resources/Doug_Peucker.pdf。


值----------Value----------

</table>  
</ TABLE>


(作者)----------Author(s)----------


Ben Stabler &lt;<a href="mailto:benstabler@yahoo.com">benstabler@yahoo.com</a>&gt; <br>




实例----------Examples----------


## Not run: [#不运行:]
#Read entire shapefile[整个的shapefile]
shapefile <- read.shapefile("links")

#Write entire shapefile[写整个的shapefile]
write.shapefile(shapefile, "temp", T)

#Read shp, shx, or dbf file[SHP,SHX,或dbf文件]
dbf <- read.dbf("links.dbf")

#Write shp, shx, or dbf file[写SHP,SHX,或dbf文件]
write.dbf(dbf, "links.dbf", T)

#Calculate header (to clean up GeoMedia shapefile exports)[计算头(清理GeoMedia的的shapefile出口)]
shapefile <- calc.header(shapefile)

#Add the X and Y coordinates to the dbf list of the shapefile list object[X和Y坐标添加到DBF的的shapefile文件列表对象列表]
shapefile <- add.xy(shapefile)

#Scale the shapefile by scale.factor[规模的shapefile scale.factor]
shapefile <- scaleXY(shapefile, scale.factor)

#Samples of using the convert.to.shapefile function to write out simple shapefiles[样品的,使用convert.to.shapefile函数写简单的shape文件]
#from basic R data.frames[从基本data.frames]

#Point[点]
dd <- data.frame(Id=c(1,2),X=c(3,5),Y=c(9,6))
ddTable <- data.frame(Id=c(1,2),Name=c("Item1","Item2"))
ddShapefile <- convert.to.shapefile(dd, ddTable, "Id", 1)
write.shapefile(ddShapefile, "c:/test", arcgis=T)

#PolyLine[折线]
dd <- data.frame(Id=c(1,1,1,2,2,2),X=c(3,5,8,6,7,8),Y=c(9,8,3,6,7,4))
ddTable <- data.frame(Id=c(1,2),Name=c("Item1","Item2"))
ddShapefile <- convert.to.shapefile(dd, ddTable, "Id", 3)
write.shapefile(ddShapefile, "c:/test", arcgis=T)

#Polygon[多边形]
dd <- data.frame(Id=c(1,1,1,1,2,2,2,2),X=c(3,5,8,3,6,7,8,6),Y=c(9,8,3,9,6,7,4,6))
ddTable <- data.frame(Id=c(1,2),Name=c("Item1","Item2"))
ddShapefile <- convert.to.shapefile(dd, ddTable, "Id", 5)
write.shapefile(ddShapefile, "c:/test", arcgis=T)

#Convert to list of shapes[转换为形状列表]
ddAsList <- by(dd,dd$Id, function(x) x)

#Convert to data.frame[转换成数据框]
dd <- do.call(rbind, ddAsList)

#Read in shp file and convert to simple format[读取shp文件,并转换为简单的格式]
shpTest <- read.shp("c:/test.shp")
simpleShpFormat <- convert.to.simple(shpTest)
simpleShpFormat <- change.id(simpleShpFormat, c("a","b"))
simpleAsList <- by(simpleShpFormat, simpleShpFormat[,1], function(x) x)
backToShape <- convert.to.shapefile(simpleShpFormat,
        data.frame(index=c("a","b")), "index", 5)
write.shapefile(backToShape, "c:/test", arcgis=T)

#Polyline simplification with dp algorithm[DP折线简化算法]
x <- c(5,3,4,1,8,9,10,11)
y <- c(6,4,2,1,1,5,2,3)
points <- list(x=x,y=y)
plot(points, type="l")
simpleLine <- dp(points, 2)
lines(simpleLine, type="l", col="blue")


## End(Not run)[#(不执行)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-23 19:00 , Processed in 0.026342 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表