<div>Dear Roger,</div>
<div> I have a problem on converting the coordinates into interval [0,1], hoping that you can give me a hand. </div>
<div> 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.</div>
<div>The following is the programs to read the data and one possible method for conversion:</div>
<div>
<p>library(sp)<br>library(foreign)<br>library(mgcv)<br>library(maptools)</p>
<p>#read the polygon containing the studied points<br>guichi <- readShapePoly("e:/guichi.shp") #boundary polygons containing the points<br>point_poly <- getPolygonCoordsSlot(getPolygonsPolygonsSlot(getSpPpolygonsSlot(guichi)[[1]])[[1]]) #get the coordinates of guichi
<br>#plot(point_poly,xlab="x", ylab="y",type="l")</p>
<p>#read the lines of two rivers in the guichi<br>rivers <- readShapeLines("e:/qiupu.shp") #change the coordinates??difficult<br>#plot(rivers,add=T)</p>
<p>#read the points of cases and controls<br>case_control <- read.csv("e:/casecontrol.csv",sep=",", header=TRUE)<br>#plot(case_control$x,case_control$y)</p>
<p><strong>#Plot the whole figure</strong><br>plot(point_poly,xlab="x", ylab="y",type="l")<br>plot(rivers,add=T)<br>points(case_control$x,case_control$y,add=T)</p>
<p>###################################################################################<br>#one of the possible methods to convert the x/y coordinates into interval [0,1]<br><strong># But it seems there is a problem: it convert the x/y coordinates into interval [0,1], respectively.
<br># In my opinion, they should be expand or shrink according to the same minimum/maximum value</strong>.<br>st <- function(x)(x-min(x))/(max(x)-min(x))<br>case_control[,c(8,9)] <- data.frame(lapply(case_control[,c(6,7)],st))
<br>###################################################################################<br><font color="#ff0000"><strong>Q1. The main problem is on the rivers, which has multiple lines. There are difficulties for conversion.
<br>Q2. when i convert the x/y coordinates, i'm not very sure whether i should use the same scale of conversion or not. </strong></font><br> Could you please help us to solve it?<br> Any suggestions/help are greatly appreciated.
<br></p></div>
<div><br clear="all"><br>-- <br>With Kind Regards,<br><br>oooO:::::::::<br>(..)::::::::: <br>:\.(:::Oooo:: <br>::\_)::(..):: <br>:::::::)./:::
<br>::::::(_/:::: <br>:::::::::::::<br>[***********************************************************************]<br>Zhi Jie,Zhang ,PHD <br>Tel:86-21-54237149 <br>Dept. of Epidemiology,School of Public Health,Fudan University
<br>Address:No. 138 Yi Xue Yuan Road,Shanghai,China <br>Postcode:200032 <br><a href="mailto:Email:epistat@gmail.com">Email:epistat@gmail.com</a> <br>Website: <a href="http://www.statABC.com">www.statABC.com</a><br>[***********************************************************************]
<br>oooO:::::::::<br>(..)::::::::: <br>:\.(:::Oooo:: <br>::\_)::(..):: <br>:::::::)./::: <br>::::::(_/::::
<br>::::::::::::: </div>