[R-sig-Geo] problem on converting the coordinates into interval [0, 1]?

zhijie zhang epistat at gmail.com
Sun Sep 23 13:49:55 CEST 2007


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.


-- 
With Kind Regards,

oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::
:::::::::::::
[***********************************************************************]
Zhi Jie,Zhang ,PHD
Tel:86-21-54237149
Dept. of Epidemiology,School of Public Health,Fudan University
Address:No. 138 Yi Xue Yuan Road,Shanghai,China
Postcode:200032
Email:epistat at gmail.com
Website: www.statABC.com
[***********************************************************************]
oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::
:::::::::::::
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070923/3e55216d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: casecontrol.rar
Type: application/octet-stream
Size: 27619 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070923/3e55216d/attachment.obj>


More information about the R-sig-Geo mailing list