Hi, It's good form to reply to the list rather than just to me, and I've taking the liberty of doing so. So is, "How can I use im() from spatstat with data of this format to make a pixel image that I can use as a covariate for my analysis?" a good summary of your question? Complete information up front means that people don't have to spend time asking for more information. Yes, im() can be used to make a pixel image from a matrix. You don't have a matrix, but instead a vector of points with x and y coordinates. It's normally easy to turn that into a matrix, but your points do not fall on a regular grid in the coordinate system being used, so I think you'd have to interpolate in some way to create such a matrix, which is an entirely different problem. Unless I'm missing something, you need to process your data before you can make a pixel image from it. The r-sig-geo mailing list might be of more use for that. You can see this by plotting with(mydata, plot(X, Y)) to see where the values are. For the rest of the list, K?tia sent me her full dataset offlist. I'm reluctant to include it here, but the point pattern it produces is on a regular grid, but rotated with respect to the coordinate system being used so that there are irregular distances between X and Y values. If it were my data, I'd use GIS software to interpolate it to a regular grid, though there are several ways of varying complexity to do that in R. Sarah
On Mon, Jul 9, 2012 at 1:40 PM, K?tia Emidio <kat.emidio at gmail.com> wrote:
Hi Sarah, I intend to use de alt_m (elevation) as a covariate on my species distribution. I am using Spatstat package, and there, if I have vectors with x/y coordinates and a covariate, it is possible I make a image from a matrix based on the elevation data. there is a function in spatstat, but I am not confident about use it from my data. I am sending the whole data, but the structure is the same. The function is: im(mat, xcol=seq_len(ncol(mat)), yrow=seq_len(nrow(mat)), xrange=NULL, yrange=NULL, unitname=NULL) Attached I'm sending the material that I have been used. See on page 63, may be you can undertand the functions. Also see on pags 82 and 83 about using covariates to study plant distribution. Thanks 2012/7/9 Sarah Goslee <sarah.goslee at gmail.com>
Hi, I'm not quite clear on what you want; see below. On Sun, Jul 8, 2012 at 6:37 PM, K?tia Emidio <kat.emidio at gmail.com> wrote:
Hi, Someone could help me in create a pixel image using the SPATSTAT Package?
spatstat doesn't deal with pixel images (raster?) but instead with point pattern objects. If that's what you want, ?ppp will get you started.
Attached there is a sample from my data. The column names are (x and y coordinates, and elevation (alt_m). Thanks
You don't provide either enough data or enough information for me to be able to know whether your data are gridded or not. If so, this will work for creating a SpatialGridDataFrame: library(sp) coordinates(mydata) <- ~X+Y But I'm not sure if that's what you want: what are you trying to do, and what do your data represent? Sarah
Sarah Goslee http://www.functionaldiversity.org