Skip to content
Prev 2581 / 29559 Next

problem on converting the coordinates into interval [0, 1]?

Dear Roger,
  I have a problem on converting the coordinates into interval [0,1], hoping
that you can give me a hand.
  My data consist of points(cases), lines(rivers) and polygon (guichi city),
and i want to change their coordinates into interval [0,1].  I have put the
data in the attachment, so that you can use it.
The following is the programs to read the data and one possible method for
conversion:

library(sp)
library(foreign)
library(mgcv)
library(maptools)

#read the polygon containing the studied points
guichi <- readShapePoly("e:/guichi.shp")  #boundary polygons containing the
points
point_poly <-
getPolygonCoordsSlot(getPolygonsPolygonsSlot(getSpPpolygonsSlot(guichi)[[1]])[[1]])
#get the coordinates of guichi
#plot(point_poly,xlab="x", ylab="y",type="l")

#read the lines of two rivers in the guichi
rivers <- readShapeLines("e:/qiupu.shp")  #change the coordinates??difficult
#plot(rivers,add=T)

#read the points of cases and controls
case_control <- read.csv("e:/casecontrol.csv",sep=",", header=TRUE)
#plot(case_control$x,case_control$y)

*#Plot the whole figure*
plot(point_poly,xlab="x", ylab="y",type="l")
plot(rivers,add=T)
points(case_control$x,case_control$y,add=T)

###################################################################################
#one of the possible methods to convert the x/y coordinates into interval
[0,1]
*# But it seems there is a problem: it convert the x/y coordinates into
interval [0,1], respectively.
# In my opinion, they should be expand or  shrink according to the same
minimum/maximum value*.
st <- function(x)(x-min(x))/(max(x)-min(x))
case_control[,c(8,9)] <- data.frame(lapply(case_control[,c(6,7)],st))
###################################################################################
*Q1. The main problem is on the rivers, which has multiple lines. There are
difficulties for conversion.
Q2. when i convert the x/y coordinates, i'm not very sure whether i should
use the same scale of conversion or not. *
 Could you please help us to solve it?
 Any suggestions/help are greatly appreciated.