[R-sig-Geo] plotting Football field ball pattern data

Robert Hijmans r.hijmans at gmail.com
Fri Jan 30 10:27:35 CET 2009


Miguel,

I am not entirely sure about what you need, but this might do it:

#install.packages("raster", repos="http://R-Forge.R-project.org")
require(raster)
# create a new raster. use additional arguments so that it matches
your data (extreme x and y )
r <- newRaster(ncols=36, nrows=18)

# I simulate 1000 points, 3 times (simulating not being able to load
all points, but perhaps you can, in this case)
n <- 1000
for (i in 1:3) {
	x <- runif(n)* 360 - 180
	y <- runif(n)* 180 - 90
	xy <- cbind(x, y)
	vals <- rep(1, n)
	r <- pointsToRaster(r, xy, vals)
	r[is.na(r)] <- 0
	if (i == 1) { rs <- r } else { rs <- rs + r }
}
# the plot you do not want:
plot(rs)
# is this the plot you do want?
x11()
plot(density(values(rs)))



Robert

On Fri, Jan 30, 2009 at 3:43 PM, Miguel Eduardo Gil Biraud
<miguel.gil.biraud at ieee.org> wrote:
> Hi,
>
> I was going to post a similar question as I am also a fresh new user of R.
>
> In my case I have between 10 million and 20 million latitude,
> longitude pairs and want to get an image in which each pixel has a
> color that is a function of the amount of positions that would fall
> into the spatial bin corresponding to the pixel size. I understand
> that this would be akin to a 2D histogram of my data and resemble a
> density plot.
>
> The way I started doing that was importing the table with read.table()
> and then converting it to a PPP object providing the adequate bounds.
> The first problem I face is that when I try to put all the points into
> the PPP object I get a memory failure.
>
> To keep experimenting I lowered the number of points I import and
> played around with the density function available in spatstat but
> while I can see its uses when you have few points, in my case the
> patters would get diluded very fast even for small values of sigma and
> I am afraid it would not represent the data faithfully.
>
> On the other hand the function quadratcount returns very fast results
> for a high number of partitions in the X and Y axis and I could
> certainly use the results it provides, if it wouldn't be for the fact
> that when I try to plot it, I get the grid and the point count inside
> each cell. Is there any way to convert the output of gridcount into a
> colored plot in the same spirit of the one you get when you do a
> plot(density())?
>
> Hope it wasn't too confusing. As you can see I've tried to take a jab
> at it on my own, but it is proving more complicated than I expected!
> :)
>
> Cheers,
> Miguel
>
> On Fri, Jan 30, 2009 at 06:09, srinivasa raghavan
> <srinivasraghav at gmail.com> wrote:
>> Hi r-sig-geo team,
>>
>> I am a new user of R 2.8.1 in windows 2003. I have a data set of football
>> ball pattern data. The data is for multiple matches. The variables are :
>>
>> match: The code number of the match.
>> period: First half or second half denotted by 1 or 2.
>> pitchX:  The x co-ordinate of the field.
>> pitchy: The y-co-ordinate of the field.
>> seconds: The time point.
>>
>> I am interested to draw the football graph/diagram and then plot the above
>> data.
>>
>> Can any one let me know the right functions/packages which can help me in
>> this regard.
>>
>> thanks in advance.
>>
>> warm regards,
>> srinivas
>> statistical analyst.
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
>
> --
> http://franchu.net
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>




More information about the R-sig-Geo mailing list