Skip to content

Commit

Permalink
version 0.4-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown author authored and gaborcsardi committed Dec 3, 2002
1 parent 33d21b6 commit aef3806
Show file tree
Hide file tree
Showing 16 changed files with 284 additions and 136 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RArcInfo
Version: 0.4-1
Date: 2002/10/28
Version: 0.4-2
Date: 2002/12/03
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>
Expand Down
69 changes: 35 additions & 34 deletions INDEX
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
RArcInfo RArcInfo
avctoe00 Converts a ARC/INFO binary coverage into an
ESRI E00 file
e00toavc Converts an ESRI E00 file into an Arc/Info V
7.x binary coverage
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.
read.coverage Function for retrieving basic data from a given
coverage
thinlines Function for deleting points in an arc
definition object
RArcInfo RArcInfo
avctoe00 Converts a ARC/INFO binary coverage into an
ESRI E00 file
e00toavc Converts an ESRI E00 file into an Arc/Info V
7.x binary coverage
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.nb Function for calculating neighbouting polygons.
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.
read.coverage Function for retrieving basic data from a given
coverage
thinlines Function for deleting points in an arc
definition object
2 changes: 1 addition & 1 deletion R/RArcInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ get.tabledata <- function(infodir, tablename)
{
for (i in 2:l)
df<-cbind(df,I(data[[i]]))

}

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

data
}

Expand Down
30 changes: 30 additions & 0 deletions R/get.nb.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
get.nb<-function(arc,pal,index=NULL)
{
if(is.null(index))
index<-1:length(pal[[1]][[1]])

lindex<-length(index)

nb<-vector(mode="list", length=lindex)

arcid<-arc[[1]]$ArcId
lpoly<-arc[[1]]$LeftPoly
rpoly<-arc[[1]]$RightPoly

for(p in 1:lindex)
{
arcs<-sort(unique(abs(pal[[2]][[ index[p] ]][[1]])))

if(arcs[1]==0)
arcs<-arcs[-1]

arcindex<-as.vector(tapply( arcs , 1:length(arcs),
function(X,arcid){which(arcid==X)}
,arcid) )

thisnb<-c(lpoly[arcindex], rpoly[arcindex])
nb[[p]]<-sort(unique(thisnb))
}

nb
}
142 changes: 77 additions & 65 deletions R/plotarc.R
Original file line number Diff line number Diff line change
@@ -1,76 +1,88 @@
#Plots all the arcs imported from an ARC file by get.arcdata

#New: T for new plots
plotarc<-function(arc, new=TRUE, ...)
plotarc<-function(arc, new=TRUE, index=NULL, ...)
{
if(is.null(index))
index<-1:length(arc[[2]])

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

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

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

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

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

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

#Set aspect ratio and display plotting window

par.in <- par(no.readonly = TRUE)
on.exit(par(par.in))

plot.dim<-c(bnd[3]-bnd[1], bnd[4]-bnd[2])

par(pin = min(par.in$pin)
* par.in$fin / max(par.in$fin)
* (plot.dim) / max(plot.dim))



for(i in 2:ll)
{

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

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

for(j in 1:2)
if(new==TRUE)
{
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]
if(!exists("xlim") || !exists("ylim") )
{
#Calculate the boundary

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

xmin<-min(x)
xmax<-max(x)
ymin<-min(y)
ymax<-max(y)

nxmin<-min(x)
nxmax<-max(x)
nymin<-min(y)
nymax<-max(y)


for(i in 2:ll)
{
x<-arc[[i]][[1]]
y<-arc[[i]][[2]]
l<-as.integer(length(x))

nxmin<-min(x)
nxmax<-max(x)
nymin<-min(y)
nymax<-max(y)

if(nxmin<xmin) xmin<-nxmin
if(nymin<ymin) ymin<-nymin
if(nxmax>xmax) xmax<-nxmax
if(nymax>ymax) ymax<-nymax
}
}
else #if(!exists("xlim") || !exists("ylim") )
{
xmin<-xlim[1]
xmax<-xlim[2]
ymin<-ylim[1]
ymax<-ylim[2]
}

range<-max( c(xmax-xmin, ymax-ymin) )/2

xmean<-(xmin+xmax)/2
ymean<-(ymin+ymax)/2


#Set aspect ratio and display plotting window

par.in <- par(no.readonly = TRUE)
# on.exit(par(par.in))

plot.dim<-c(ymax-ymin, xmax-xmin)
print(min(par.in$pin)
* par.in$fin / max(par.in$fin)
* (plot.dim) / max(plot.dim))
par(pin = min(par.in$pin)
* par.in$fin / max(par.in$fin)
* (plot.dim) / max(plot.dim))

plot(arc[[1]][[1]], arc[[1]][[2]], xlim=c(xmean-range,xmean+range), ylim=c(ymean-range, ymean+range), type="n", ...)

}##if(new)

for (i in 1:ll)
{
lines(arc[[i]][[1]], arc[[i]][[2]], ...)
}
}


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]][[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)
{
lines(arc[[i]][[1]], arc[[i]][[2]])
}


}
14 changes: 7 additions & 7 deletions R/plotpal.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#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=TRUE, ...)
plotpal<-function(arc,pal, new=TRUE, index=NULL,...)
{

if(is.null(index))
index<-1:length(pal[[2]])
#We only need the lists of arcs
arc<-arc[[2]]
pal<-pal[[2]]

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

lpal<-length(pal)


for(i in 1:lpal)
for(p in index)
{
l<-length(pal[[i]][[1]])
for(j in 1:l)
l<-length(pal[[p]][[1]])
for(a in 1:l)
{
arcs[abs(pal[[i]][[1]][j])]<-TRUE
arcs[abs(pal[[p]][[1]][a])]<-TRUE
}
}

Expand Down
9 changes: 7 additions & 2 deletions R/plotpoly.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
plotpoly <-function(arc,bnd,pal,index,col, ...)
plotpoly <-function(arc,bnd,pal,index=NULL,col, ...)
{
if(is.null(index))
{
index<-1:length(pal[[1]][[1]])
}

lindex<-length(index)
col<-rep(col,length.out=lindex)

#Set aspect ratio and display plotting window

par.in <- par(no.readonly = TRUE)
on.exit(par(par.in))
# on.exit(par(par.in))

plot.dim<-c(bnd[3]-bnd[1], bnd[4]-bnd[2])

Expand Down
4 changes: 3 additions & 1 deletion R/read.coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ read.coverage<-function(datadir, coverage)
if( length(dir(covdir, pattern="tol.adf"))>0 )
cov.tol<-get.toldata(datadir, coverage)
else
{
cov.tol<-get.toldata(datadir, coverage, "par.adf")

}

tblnames<-get.tablenames(infodir)

pattern<-paste( c(casefold(coverage, upper=TRUE), ".*"), collapse="")
Expand Down
14 changes: 13 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RArcInfo - 0.4-1
RArcInfo - 0.4-2

- INTRODUCTION

Expand Down Expand Up @@ -141,6 +141,18 @@ the source code. When I have more spare time I will make a beatiful web page too

NEWS

*V 0.4-2
- 'index' argument added to plotarc to select the arcs to plot.
- 'index' argument added to plotpal to select the polygons to plot.
- New function 'get.nb', which, given a set of polygons, returns
the neighbouring polygons of each one.
- Fixed a bug in 'get_tol_data'. The file to be open was of
type CNT instead of TOL. Now tolerances are read without problems.
- Output messages have been changed in several functions to
be more useful for the user.
- Fixed a bug in 'plotarc' when calculating plot dimensions.
- Example added to RArcInfo documentation file.

*V 0.4-1- 'thinlines' modified to keep the last point of the arcs. Thanks
to Erich Neuwirth for this comment.

Expand Down

0 comments on commit aef3806

Please sign in to comment.