Michael,  the code for converting a data frame containing UTM
coordinates identified by group, into SpatialPolygon objects, works
spectacularly well. Many thanks --Seth

----- Original Message -----
 From:Michael Sumner 
To:
Cc:
Sent:Mon, 16 Jul 2012 16:30:46 +1000
Subject:Re: [R-sig-Geo] Converting UTMs to SpatialPolygons object

Here we go, I'm assuming each ring is its own simple object, and a
few
other things.

id = rep(seq(1,3),each=12)
az = rep(seq(0,359,30),3)

## assume you meant to use all ids here?
d = dataframe(id [1],az)
d$dist = round(rnorm(36,10,3),1)
xp = function(azimuth, r){cos(((90-azimuth)*pi)/180)*r}
yp = function(azimuth, r){sin(((90-azimuth)*pi)/180)*r}
ctr_e = rnorm(3,667314,50)
ctr_n = rnorm(3,4784480,50)

d$utm_e = round(xp(d$az,d$dist),1) + ctr_e[d$id]
d$utm_n = round(yp(d$az,d$dist),1) + ctr_n[d$id]

library(sp)
myCRS = CRS("+proj=utm +zone=18 +ellps=WGS84")

## create list of coords, including repeat of first row for each
l.coords [2]  az = rep(seq(0,359,30),3) # Generate
> azimuth sequence
> c = data.frame(id [11]
> [1],az) # Combine in
> data frame
> c$dist = round(rnorm(36,10,3),1) # Generate random distances from
> center of polygon
>
> xp = function(azimuth, r){cos(((90-azimuth)*pi)/180)*r}
> # Function to calculate horizontal distance from polygon
> center
>
> yp = function(azimuth, r){sin(((90-azimuth)*pi)/180)*r}
> # Function to calculate vertical distance from polygon
> center
>
> ctr_e = rnorm(3,667314,50) # Randomly select eastings
> for polygon centers
> ctr_n = rnorm(3,4784480,50) # Randomly select northings for
> polygon centers
>
> c$utm_e = round(xp(c$az,c$dist),1) + ctr_e[c$id] # Calculate
> point eastings
> c$utm_n = round(yp(c$az,c$dist),1) + ctr_n[c$id] # Calculate point
> northings
>
> myCRS = CRS("+proj=utm +zone=18 +ellps=WGS84") # define
> proj4string
>
> Appreciatively,
>
> Seth Bigelow
>
>
>
> Links:
> ------
> [1] http://sitemail.hostway.com/http:/ [12]
>
>
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org [13]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo [14]
>

-- 
Michael Sumner
Hobart, Australia
e-mail: mdsum...@gmail.com [15]


Links:
------
[1] http://sitemail.hostway.com/http:/
[2] http://l.coords/
[3] http://sitemail.hostway.com/http:/
[4] http://l.polygons/
[5] http://sitemail.hostway.com/http:/
[6] http://sitemail.hostway.com/http:/
[7] http://sitemail.hostway.com/http:/
[8] http://sitemail.hostway.com/http:/
[9] http://sitemail.hostway.com/http:/
[10] http://l.polygons/
[11] http://sitemail.hostway.com/http:/
[12] http://sitemail.hostway.com/http:/
[13] mailto:R-sig-Geo@r-project.org
[14] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[15] mailto:mdsum...@gmail.com


        [[alternative HTML version deleted]]

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

Reply via email to