[R] convert to grid file
Petr PIKAL
petr.pikal at precheza.cz
Thu Sep 1 17:01:58 CEST 2011
Hi
I do not know sp package therefore I can not help you. Anyway without
knowing "what is wrong" and without some reproducible example you hardly
get any reasonable answer.
It seems to me that your d list especially x and y is not what you expect
to be.
see
str(d)
430071.4887:460006.8067
will resilt in row of integers from 430071 to 460006. I believe it is not
what you want.
Regards
Petr
>
> Thank you
>
> I want to make a map from my spatial data that I can show it in GIS.
> I used the package sp and
>
> d<- list(x=430071.4887:460006.8067, y =3390040.0591:3420006.2701, z =
> matrix(mat, 970, 960))
> gt<- GridTopology(cellcentre.offset = c(d$x[1], d$y[1]),
> cellsize=c(diff(d$x[1:2]), diff(d$y[1:2])), cells.dim = dim(d$z))
> grdatts<-SpatialGridDataFrame(gt, data.frame(depth =
> as.vector(d$z[,ncol(d$z):1])))
> image(grd.atts, axes=TRUE)
> grd<-SpatialGridDataFrame(gt, data.frame(depth =
> as.vector(d$z[,ncol(d$z):1])))
>
> It doesn't work and I think it is wrong.
>
> Thanks
>
> From: Petr PIKAL <petr.pikal at precheza.cz>
> To: azam jaafari <azamjaafari at yahoo.com>
> Cc: R-help <r-help at r-project.org>
> Sent: Thursday, September 1, 2011 10:22 AM
> Subject: Re: [R] convert to grid file
>
> Hi
>
> > Thank you Petr
> >
> > It work.
> >
> > Now I have a matrix 970*960. If I want to convert to spatial grid
(each
> > pixel has x and y coordinate).
> > How can I do?
>
> I do not understand. What do you want to do with your data? Maybe you
> could consult spatial package or CRAN Task views. One option could be to
> make vectors of row and columns coordinates. But it depends on what you
> want to do with your data.
>
> Regards
> Petr
>
>
> >
> > Thanks
> >
> >
> > From: Petr PIKAL <petr.pikal at precheza.cz>
> > To: azam jaafari <azamjaafari at yahoo.com>
> > Cc: R-help <r-help at r-project.org>
> > Sent: Thursday, September 1, 2011 8:59 AM
> > Subject: Re: [R] convert to grid file
> >
> > Hi
> >
> > >
> > > Hi
> > >
> > > I computed probability in each cell.
> > > I have:
> > >
> > > [99883,] -0.0062412957690
> > > [99884,] -0.0062412957690
> > > [99885,] -0.0062412957690
> > > [99886,] -0.0062412957690
> > > [99887,] -0.0062412957690
> > > [99888,] -0.0062412957690
> > > [99889,] 0.9909126638948
> > > [99890,] 0.9909126638948
> > > [99891,] 0.9909126638948
> > > [99892,] 0.9909126638948
> > > [99893,] 0.9909126638948
> > > [99894,] 0.9909126638948
> > > [99895,] 0.9909126638948
> > > [99896,] 0.9909126638948
> > > [99897,] 0.9909126638948
> > > [99898,] 0.9909126638948
> > > [99899,] 0.9909126638948
> > > [99900,] 0.9909126638948
> > > [99901,] 0.9909126638948
> > > [99902,] 0.9909126638948
> > > [99903,] 0.9909126638948
> > >
> > > [99999,] -0.0062412957690
> > > [ reached getOption("max.print") -- omitted 839931 rows ]]
> > >
> > > How want to convert this matrix to a grid file with 970*960 pixel.
> >
> > Assuming your object is one column matrix called mat1
> >
> > You can simply change its dimension
> >
> > dim(mat) <- c(970, 960)
> >
> > regards
> > Petr
> >
> >
> >
> >
> > >
> > > Thanks alot
> > > [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
>
More information about the R-help
mailing list