# How to transform coordinates to location in x-y grid in R?

I have a polygon with a 40m diameter and several points that lay inside it. Now I want to reformat the point locations (projected in DHDN/GK-3, but could vary) to x-y coordinates ranging from zero to the maximal diameter of the polygon (in this case 40m).

I am working in R and therefore I need a scripted solution (this is just a testing subset and many more follow, therefore "click"-solutions in Qgis/arcgis won't suffice.)

Pictures say more than words: The triangle is the polygons centroid. The green dots the point locations.

I appreciate any coding assistance :-)

-

If I understand your question right: it is a simple algebra calculation. You have two cartesian coordinate systems.

For the x-coordinate of the blue point: 20 + 2500117 - 2500100 = 37

EDIT: This solution works only if the coordinate system is a "projected coordinate system" (e.G. Gauss-Krueger, UTM, ...). It is not a solution for "geographical coordinate systems" (e.g. WGS84).

-
no comment. Thanks for this easy solution ;-) However it results in some negative values, which is why i took the diameter instead of the radius. I should read some of those old highschool math books... – Curlew Dec 12 '12 at 16:20

There is Proj4 library interface for R in CRAN http://cran.r-project.org/package=proj4 and http://www.rforge.net/proj4/ After that only thing what you need is source and destination SRID

-
I don't want to transform between projections, but instead from one projection to a cartesian coordinate system. – Curlew Dec 12 '12 at 12:43
A projection can be either geographic or projected. In the first case, your coordinates are in the φ,λ (spherical) plane and in the later in x,y (Cartesian) plane. – nickves Dec 12 '12 at 12:51
proj4 can solve your problem. You need create a custom proj4 string, with the appropriate parameters. trac.osgeo.org/proj/wiki/GenParms . – nickves Dec 12 '12 at 12:55
Ahh. i understood question wrong and assumed that we were talking about point on globe. But still you can solve problem with proj4 using link 'nickves' provided – simplexio Dec 12 '12 at 13:00