Automatic geographical projection parameters setting
Hello,
Please reply to the list, not only to me.
Example taken from rgdal::spTransform:
> crds <- matrix(data=c(9.05, 48.52), ncol=2)
> spPoint <- SpatialPoints(coords=crds,
+ proj4string=CRS("+proj=longlat +ellps=sphere
+no_defs"))
> a <- spTransform(spPoint, CRS(paste("+proj=ob_tran +o_proj=longlat",
+ "+o_lon_p=-162 +o_lat_p=39.25
+lon_0=180 +ellps=sphere +no_defs")), use_ob_tran=TRUE)
> a
SpatialPoints:
coords.x1 coords.x2
[1,] -5.917698 -1.87195
Coordinate Reference System (CRS) arguments: +proj=ob_tran
+o_proj=longlat +o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere
+no_defs
>
> lon_0 <- 180
> o_lon_p <- -162
> o_lat_p <- 39.25
>
> crs.args <- paste("+o_lon_p=",o_lon_p," +o_lat_p=",o_lat_p,"
+lon_0=",lon_0," +ellps=sphere +no_defs", sep='')
> b <- spTransform(spPoint, CRS(paste("+proj=ob_tran
+o_proj=longlat",crs.args)), use_ob_tran=TRUE)
> b
SpatialPoints:
coords.x1 coords.x2
[1,] -5.917698 -1.87195
Coordinate Reference System (CRS) arguments: +proj=ob_tran
+o_proj=longlat +o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere
+no_defs
Regards,
Pascal
On 05/29/2013 06:26 PM, Francesco Carotenuto wrote:
Thank you for the reply but in my post I've already explained that the function doesn't "read" any object. ------------------------------------------------------------------------ *Da:* Pascal Oettli <kridox at ymail.com> *A:* Francesco Carotenuto <carotenuto_francesco at yahoo.it> *Cc:* "r-sig-geo at r-project.org" <r-sig-geo at r-project.org> *Inviato:* Mercoled? 29 Maggio 2013 10:15 *Oggetto:* Re: [R-sig-Geo] Automatic geographical projection parameters setting Hello, Something like that?
> LONG <- 20 > LAT <- 5
> crs.args <- paste("+proj=laea +lat_0=",LAT," +lon_0=",LONG," +x_0=0
+y_0=0 +ellps=WGS84 +units=m +no_defs",sep="")
> CRS("+proj=laea +lat_0=5 +lon_0=20 +x_0=0 +y_0=0 +ellps=WGS84
+units=m +no_defs") CRS arguments: +proj=laea +lat_0=5 +lon_0=20 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs
> CRS(crs.args)
CRS arguments: +proj=laea +lat_0=5 +lon_0=20 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs Regards, Pascal On 05/29/2013 04:58 PM, Francesco Carotenuto wrote:
> Hi > to all, > I > need to automatically set the geographical coordinates of the
projection?s
> centre to project different polygons in different territories. My
problem is the
> following.
> By
> using spTransform(xy, CRS("+proj=laea +lat_0=LAT +lon_0=LONG +x_0=0
+y_0=0
> +ellps=WGS84 +units=m +no_defs")), I would like to set +lat_0 and
+long_0 as objects (here ?LAT? and
> ?LONG?) that I automatically generated. Unfortunately, this function
doesn?t
> read objects (even if ?as.numeric?) but only numerical values set
manually. Is
> there a way to set these coordinates as objects? > Many > thanks. > [[alternative HTML version deleted]] > > > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo at r-project.org <mailto:R-sig-Geo at r-project.org> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo >