[R-sig-Geo] create a triangular grid ?
Fernando Paim
fernandopaim at paim.pro.br
Fri Sep 30 19:12:49 CEST 2016
Hello Mike,
Thanks for answering. I also thank the code and
example. They will be very useful for me.
Greetings
Fernando Paim
Em 30.09.2016 13:19, Michael Sumner escreveu:
> On Fri, 30 Sep 2016
at 21:29 Fernando Paim <fernandopaim at paim.pro.br> wrote:
>
>> Hello
everyone,
>>
>> I need to create a triangular grid for kriging.
>> I've
tried with makegrid, expand.grid but with just a rectangular grid.
>> I
have not been able to find a method to trim the rectangular grid to
>>
the newdata same shape of the original data, is this possible?
>
> You
already have a reasonable triangular mesh here so I assume you want to
generate a rectangular grid (a raster) from this?
>
> d <-
read.delim("http://www.paim.pro.br/downloads/dados.csv [1]")
>
> tri
<- RTriangle::triangulate(RTriangle::pslg(P = cbind(d$x, d$y), PA =
cbind(d$z)))
>
> rgl::triangles3d(cbind(tri$P, tri$PA)[t(tri$T), ],
col = "grey", specular = "black")
> rgl::points3d(d$x, d$y, d$z)
>
>
You can use barycentric coordinates to get a fast interpolation for
arbitrary points on this mesh, there are functions for this in geometry
package but you have to drive the subsequent sampling yourself. If
that's on the right track I would generate a regular grid with raster,
then convert to barycentric and pull out interpolated values. I have an
old example here that might help:
>
>
https://github.com/mdsumner/xyztrisurf/blob/master/xyztrisurf.Rmd [3]
>
> You can use simple interpolation to get a little more resolution from
your data on the mesh in the first place with a maximum triangle area
(the 'a' argument):
>
> tri <-
RTriangle::triangulate(RTriangle::pslg(P = cbind(d$x, d$y), PA =
cbind(d$z)), a = 2)
>
> rgl::triangles3d(cbind(tri$P,
tri$PA)[t(tri$T), ], col = "grey", specular = "black")
>
rgl::points3d(d$x, d$y, d$z)
>
> These visualizations at least give a
sense of what your data are and what is sensible, the barycentric
interpolation to sample points is as if you intersect those grid points
with this surface.
>
> Otherwise you can use real modelling -
depending on what makes sense for these data . . .
>
> Cheers, Mike.
>
>> The
>> data (x,y,z) are available in
>>
http://www.paim.pro.br/downloads/dados.csv [1]
>>
>> Can anyone
help?
>>
>> Thanks in
>> advance,
>>
>> Fernando Paim
>>
>>
[[alternative HTML version deleted]]
>>
>>
_______________________________________________
>> R-sig-Geo mailing
list
>> R-sig-Geo at r-project.org
>>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo [2]
>>
>> University of
Tasmania Electronic Communications Policy (December, 2014).
>> This
email is confidential, and is for the intended recipient only. Access,
disclosure, copying, distribution, or reliance on any of it by anyone
outside the intended recipient organisation is prohibited and may be a
criminal offence. Please delete if obtained in error and email
confirmation to the sender. The views expressed in this email are not
necessarily the views of the University of Tasmania, unless clearly
intended otherwise.
>> .
>
> --
>
> Dr. Michael Sumner
> Software and
Database Engineer
> Australian Antarctic Division
> 203 Channel
Highway
> Kingston Tasmania 7050 Australia
Links:
------
[1]
http://www.paim.pro.br/downloads/dados.csv
[2]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[3]
https://github.com/mdsumner/xyztrisurf/blob/master/xyztrisurf.Rmd
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list