Well, I'm guessing that your input projection is NA, so projectRaster
doesn't know what to project from.
If you know the projection information of grid_count.asc, and it isn't held
in a file associated with grid_count.asc (sometimes there will be a file
like grid_count.prj with this info in it), then you might have to set it
yourself
Here is an example:
library(raster)
asciistring <- "ncols 4
nrows 4
xllcorner 367420.313975849072
yllcorner 7743265.250157702714
cellsize 30.000000000000
35 33 31 39
40 41 44 43
39 39 38 41
39 38 36 41
"
cat(file="aa.asc", asciistring)
r2 <- raster("aa.asc")
# the next line returns an error because r2 has no projection information
pr1 <- projectRaster(r2, crs="+proj=longlat +datum=WGS84 +ellps=WGS84
+towgs84=0,0,0")
# but I know my input projection is GDA94 mga zone 55
proj4string(r2) <- CRS("+init=epsg:28355")
# now I can reproject to whatever I want.
pr1 <- projectRaster(r2, crs="+proj=longlat +datum=WGS84 +ellps=WGS84
+towgs84=0,0,0")
On Tue, Oct 23, 2012 at 8:03 PM, alemante zd <[email protected]> wrote:
> Dear all,
>
> Thanks for the suggestions. I tried
>
>
> r2 <- raster("grid_count.asc")# this is my grid file
> pr1 <- projectRaster(r2, crs="+proj=longlat +datum=WGS84 +ellps=WGS84
> +towgs84=0,0,0")
> and I get the following error message
>
> Raster(r2, crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
> :
> input projection is NA
>
> I also tried it with the example in the r manual and that works fine.
>
> What is it that I am doing wrong?
>
> //minti
> On Mon, Oct 22, 2012 at 11:17 PM, Robert J. Hijmans <[email protected]
> >wrote:
>
> > Minti,
> >
> > For spatial objects (points, lines, polygons) you can use spTransform in
> > the rgdal package. For gridded data, as is the case here, you can use
> > projectRaster from the raster package.
> >
> > Robert
> >
> >
> > On Mon, Oct 22, 2012 at 2:26 PM, Struve,Juliane <[email protected]> wrote:
> >
> >> Hi Minti,
> >>
> >> Have a look at convUL() in package PBSmapping.
> >>
> >> Regards,
> >>
> >> Juliane
> >>
> >> -----Original Message-----
> >> From: [email protected] [mailto:
> >> [email protected]] On Behalf Of alemante zd
> >> Sent: Monday, October 22, 2012 5:16 PM
> >> To: [email protected]
> >> Subject: [R-sig-Geo] converting UTM to decimal (latitude and longitude)
> >>
> >> Dear all,
> >>
> >> I have an ascii grid file based on UTM coordinates. How can I transform
> it
> >> to decimal format.
> >>
> >> Regards
> >> Minti
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> _______________________________________________
> >> R-sig-Geo mailing list
> >> [email protected]
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>
> >> _______________________________________________
> >> R-sig-Geo mailing list
> >> [email protected]
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>
> >
> >
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [email protected]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo