Dear Roger,
  The reason for doing this is to get more general programs, which can be
used in the other similar conditions. If we can convert all the related
objects into internal [0,1], we can more easily use the intermediate results
calculated from unit square,such as .bandwidth in kernels.
  I think the main problem maybe the lines object, that is qiupu.shp. The
scaling factor on the longer axis is from the guichi polygon.
#read the lines of two rivers in the guichi
rivers <- readShapeLines("e:/qiupu.shp")  #change the coordinates??difficult
#plot(rivers,add=T)
 I'm not very sure if they,especially qiupu lines, can be successfullyy
done.
 Thanks very much.

On 9/24/07, Roger Bivand <[EMAIL PROTECTED]> wrote:
>
> Dear Zhijie Zhang,
>
> On Sun, 23 Sep 2007, zhijie zhang wrote:
>
> > Dear Roger,
> >  I have a problem on converting the coordinates into interval [0,1],
> hoping
> > that you can give me a hand.
>
> I think that you need to explain why. If it is just because the
> coordinates "explode" because they are large, then simply scaling like
> this:
>
> library(rgdal)
> guichi <- readOGR(".", "guichi")
> plot(guichi, axes=TRUE)
> bbox(guichi)
> proj4string(guichi)
> t1 <- paste("+proj=tmerc +lat_0=0 +lon_0=117 +k=1.000000 +x_0=0",
>   "+y_0=-3348000 +a=6378140 +b=6356755.288157528 +units=km")
> t2 <- spTransform(guichi, CRS(t1))
> plot(t2, axes=TRUE)
> bbox(t2)
> #          min      max
> # r1 10.148541 79.88203
> # r2  0.834946 61.90978
>
> gets down to 70 by 80, which is not such a numerical risk (if need be, use
> +units=kmi to get nautical miles, which reduces the numbers even more). It
> has the key advantage that you can always get back to the true coordinates
> by transforming back.
>
> In the internal code, you will see that many packages guard by using [-1,
> +1] on both dimensions. In your case and if you know that you need this,
> you would have to work out the scaling factor on the longer axis, so that
> points on the shorter axis would be scaled correctly. But if you want to
> keep the dimensions' aspect, you could just shift the origin and the units
> as I show above.
>
> Hope this helps,
>
> Roger
>
> >  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.
> >
> >
> >
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: [EMAIL PROTECTED]
>



-- 
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:[EMAIL PROTECTED]
Website: www.statABC.com
[***********************************************************************]
oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::
:::::::::::::

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to