Skip to content

Commit

Permalink
version 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown author authored and gaborcsardi committed Feb 13, 2002
1 parent 6ac69b4 commit e787864
Show file tree
Hide file tree
Showing 93 changed files with 14,464 additions and 491 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: RArcInfo
Version: 0.02
Date: 2001/05/01
Title: Functions to import Arc/Info V7.x coverages and data
Version: 0.2
Date: 2002/02/13
Title: Functions to import data from Arc/Info V7.x binary coverages
Author: Virgilio G�mez-Rubio <virgilio.gomez@uv.es>
Maintainer: Virgilio G�mez-Rubio <virgilio.gomez@uv.es>
Dependes: R (>= 0.9)
Depends: R (>= 1.4.0)
Description: This package uses the functions written by Daniel
Morissette <danmo@videotron.ca> to read geographical information in Arc/Info
V 7.x format to import the coverages into R variables.
Morissette <danmo@videotron.ca> to read geographical information in Arc/Info
V 7.x format to import the coverages into R variables.
License: GPL version 2 or later

URL:http://sourceforge.net/projects/rarcinfo/
26 changes: 26 additions & 0 deletions INDEX
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
RArcInfo RArcInfo
get.arcdata Function for importing the contents of an ARC
file into R
get.bnddata Function for importing the contents of a BND
file into R
get.cntdata Function for importing the contents of a CNT
file into R
get.labdata Funtion for importing the contents of a LAB file
into R
get.namesofcoverages Function for getting the names of the coverages
get.paldata Function for importing the contents of a PAL
file into R
get.tabledata Function for importing the contents of a table
file into R
get.tablefields Function for reading names of the table fields
in the coverages
get.tablenames Function for reading the names of the tables in
the coverages
get.toldata Function for importing the contents of a TOL
file into R
get.txtdata Function for importing the contents of an TXT
file into R
plotarc Plots the data imported from an ARC file
plotpal Plots the data imported from an ARC file
according to the contents of a PAL file
plotpoly Plots polygons defined by the coverages.
104 changes: 104 additions & 0 deletions R/RArcInfo.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
get.namesofcoverages <- function(directory)
{
directory<-as.character(directory)
# .Call("get_names_of_coverages", as.character(dir))

if(length(dir(path=directory, pattern="info"))==1)
{
fil<-file.info(dir(path=directory, full.names=TRUE))

covnames<-(dir(path=directory))[fil$isdir]
covnames<-covnames[covnames!="info"]
}
covnames
}
get.tablenames <-function(infodir)
{
data<-.Call("get_table_names", as.character(infodir))

#A data frame with all the data
data.frame(TableName=I(data[[1]]), InfoFile=I(data[[2]]), NFields=data[[3]], RecSize=data[[4]], NRecords=data[[5]], External=I(data[[6]]))
}
get.tablefields <- function(infodir, tablename)
{
data<-.Call("get_table_fields", as.character(infodir), as.character(tablename))

#A data frame with all the data
data.frame(FieldName=I(data[[1]]), FieldType=data[[2]])
}

get.arcdata <- function(datadir, coverage, filename="arc.adf")
{
data<-.Call("get_arc_data", as.character(datadir), as.character(coverage), as.character(filename))

#a table (dataframe) with the first seven fields is built
df<-data.frame(ArcId=data[[1]], ArcUserId=data[[2]], FromNode=data[[3]], ToNode=data[[4]], LeftPoly=data[[5]], RightPoly=data[[6]], NVertices=data[[7]])

list(df, data[[8]])
}


get.bnddata <- function(infodir, tablename)
.Call("get_bnd_data", as.character(infodir), as.character(tablename))

get.paldata <- function(datadir, coverage, filename="pal.adf")
{
data<-.Call("get_pal_data", as.character(datadir), as.character(coverage), as.character(filename))

#a table (dataframe) with the first six fields is built
df<-data.frame(PolygonId=data[[1]], MinX=data[[2]], MinY=data[[3]], MaxX=data[[4]], MaxY=data[[5]], NArcs=data[[6]])

list(df, data[[7]])
}

get.labdata <- function(datadir, coverage, filename="lab.adf")
{
data<-.Call("get_lab_data", as.character(datadir), as.character(coverage), as.character(filename))
data.frame(LabelUserID=data[[1]], PolygonID=data[[2]], Coord1X=data[[3]], Coord1Y=data[[4]], Coord2X=data[[5]], Coord2Y=data[[6]], Coord3X=data[[7]], Coord3Y=data[[8]])
}

get.cntdata <- function(datadir, coverage, filename="cnt.adf")
{
data<-.Call("get_cnt_data", as.character(datadir), as.character(coverage), as.character(filename))

df<-data.frame(PolygonID=data[[1]], CoordX=data[[2]], CoordY=data[[3]], NLabels=data[[4]])

list(df, data[[5]])
}

get.toldata <- function(datadir, coverage, filename="tol.adf")
{
data<-.Call("get_tol_data", as.character(datadir), as.character(coverage), as.character(filename))
data.frame(Type=data[[1]], Status=data[[2]], Value=data[[3]])
}


get.txtdata <- function(datadir, coverage, filename="txt.adf")
{
data<-.Call("get_txt_data", as.character(datadir), as.character(coverage), as.character(filename))

df<-data.frame(TxtID=data[[1]], UserId=data[[2]], Level=data[[3]], NVerticesLine=data[[4]], NVerticesArrow=data[[5]], Text=data[[6]])

list(df, data[[7]])
}


get.tabledata <- function(infodir, tablename)
{
data<-.Call("get_table_data", as.character(infodir), as.character(tablename))

df<-data.frame(I(data[[1]]))
l<-length(data)

if(l>=2)
{
for (i in 2:l)
df<-cbind(df,I(data[[i]]))

}

fields<-get.tablefields(infodir, tablename)
names(data)<-fields[[1]]
data
}

30 changes: 0 additions & 30 deletions R/RInfo.R

This file was deleted.

40 changes: 21 additions & 19 deletions R/plotarc.R
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
#Plots all the arcs imported from an ARC file by get.arcdata

#New: T for new plots
plotarc<-function(arc, new=T)
plotarc<-function(arc, new=TRUE)
{

#We only need the list of arcs, not the dataframe with the other data
arc<-arc[[2]]

ll<-length(arc)

if(new==T)
if(new==TRUE)
{
#Calculate the boundary

bnd<-c(0,0,0,0)
nbnd<-c(0,0,0,0)

x<-arc[[1]][[8]]
l<-as.integer(length(x)/2)
x<-arc[[1]][[1]]
y<-arc[[1]][[2]]
l<-as.integer(length(x))

bnd[1]<-min(x[2*1:l-1])
bnd[2]<-max(x[2*1:l-1])
bnd[3]<-min(x[2*1:l])
bnd[4]<-max(x[2*1:l])
bnd[1]<-min(x)
bnd[2]<-max(x)
bnd[3]<-min(y)
bnd[4]<-max(y)



for(i in 2:ll)
{

x<-arc[[i]][[8]]
l<-as.integer(length(x)/2)
x<-arc[[i]][[1]]
y<-arc[[i]][[2]]
l<-as.integer(length(x))

nbnd[1]<-min(x[2*1:l-1])
nbnd[2]<-max(x[2*1:l-1])
nbnd[3]<-min(x[2*1:l])
nbnd[4]<-max(x[2*1:l])
nbnd[1]<-min(x)
nbnd[2]<-max(x)
nbnd[3]<-min(y)
nbnd[4]<-max(y)

for(j in 1:2)
{
if( nbnd[2*j-1] < bnd[2*j-1] ) bnd[2*j-1]<-nbnd[2*j-1]

if(nbnd[2*j]>bnd[2*j]) bnd[2*j]<-nbnd[2*j]

}
}

Expand All @@ -49,14 +52,13 @@ range<-max( c(bnd[2]-bnd[1], bnd[4]-bnd[3]) )/2
xmedian<-(bnd[1]+bnd[2])/2
ymedian<-(bnd[3]+bnd[4])/2

plot(arc[[1]][[8]][1], arc[[1]][[8]][2], xlim=c(xmedian-range,xmedian+range), ylim=c(ymedian-range, ymedian+range), type="n")
plot(arc[[1]][[1]], arc[[1]][[2]], xlim=c(xmedian-range,xmedian+range), ylim=c(ymedian-range, ymedian+range), type="n")

}##if(new)

for (i in 1:ll)
{
l<-length(arc[[i]][[8]])/2
lines(arc[[i]][[8]][2*1:l-1], arc[[i]][[8]][2*1:l])
lines(arc[[i]][[1]], arc[[i]][[2]])
}


Expand Down
15 changes: 10 additions & 5 deletions R/plotpal.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#Plots the polygons in pal imported by get.paldata according
#to the arcs in arc (value returned by get.arcdata)
plotpal<-function(arc,pal, new=T)
plotpal<-function(arc,pal, new=TRUE)
{

#We only need the lists of arcs
arc<-arc[[2]]
pal<-pal[[2]]

larc<-length(arc)
arcs<-vector(mode="logical", length=larc)

Expand All @@ -10,13 +15,13 @@ plotpal<-function(arc,pal, new=T)

for(i in 1:lpal)
{
l<-length(pal[[i]][[5]])
for(j in 3*1:(l/3)-2)
l<-length(pal[[i]][[1]])
for(j in 1:l)
{
arcs[abs(pal[[i]][[5]][j])]<-T
arcs[abs(pal[[i]][[1]][j])]<-TRUE
}
}

plotarc(arc[arcs], new)
plotarc(list(c(0),arc[arcs]), new=new)

}

0 comments on commit e787864

Please sign in to comment.