Senani,

Please read the help file of ptransform. It says that the first argument
"can be a list of vectors, a two-dimensional matrix or array", but you are
using a RasterStack.

I think you want to use projectRaster in the raster package; or else
spTransform in rgdal (but avoid ptransform from the proj4 package:
http://r-sig-geo.2731867.n2.nabble.com/Different-result-from-sptransform-and-ptransform-td7232814.html)

Best,
Robert


On Wed, Feb 29, 2012 at 8:18 PM, senani karunaratne <senawusl@yahoo.com>wrote:

>
>
> Dear List members
> I am trying to ready time series of monthly weather data to
> R which are in ascii grid format (480). I used some of the previous
> comments in
> mailing list and able to read those files.
>
>
> library (raster)
> library (proj4)
>
> ## Create a list
> Data <- list.files()
>
> ## Stack them
> weather <- stack (lapply(Data,raster))
>
> All the ascii data were in lat and long. However, spatial reference
> for those files are not assign and I used following command to assign
> spatial
> reference
>
> # Projection
> projection(weather) <- "+proj=longlat +ellps=WGS84
> +datum=WGS84 +no_defs"
>
> Now I need to pre-project them to local coordinate system
>
> +proj=utm +zone=55
> +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs
>
> And used following command
> ptransform(data = weather, src.proj = "+proj=longlat
> +ellps=WGS84 +datum=WGS84 +no_defs", dst.proj = "+proj=utm +zone=55
> +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
>
> But it gives error.
> #Error in ptransform(data = weather, src.proj = "+proj=longlat
> +ellps=WGS84 #+datum=WGS84 +no_defs",  :
>  # input must be 2-dimensional with at most three columns
>
> So, can anyone advice me how to do re-projection for stacked
> raster. And also will it be possible to change to resolution from 5 * 5 km
> grids
> to 90 * 90 m grids for projected rasters stack (after re-projection).
>
> Thanks
> Cheers,
> Senani
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

	[[alternative HTML version deleted]]

