[R-sig-Geo] extract X, Y coordinates from (points) POSTGIS coordinates (WKT

Marcos Angelini angelini75 at gmail.com
Mon Apr 20 12:01:51 CEST 2015


Hi community,

I have a data frame of points with coordinates (WKT) in one column. It is

d <- as.data.frame(NULL)
d$xy <- c("POINT (-59.900833 -34.869722)", "POINT (-60.009032477477234
-34.71350213192503)", "POINT (-60.13337136105485 -34.74472597084807)",
"POINT (-60.199859958706185 -34.7384738077165)")

I want to convert this into:
d$X
-59.900833
-60.009032
-60.133371
-60.199860
d$Y
-34.869722
-34.713502
-34.744726
-34.738474

I've tried with gsub() but I'm not handy with regular expressions. Could
you help me, please?

Marcos.

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list