[GIS] How to determine in which grid cell each coordinate of an x,y series is located

point-in-polygonrvector-grid

I have a circular arena which I have divided into a number of equal-sized 'cells' using a grid-like arrangement of concentric circles and line segments (in grey below) and also a series of x,y coordinates (plotted as a line in black below).

sampleFig

I was wondering what would be the best method (preferably using R) to find out which 'cell' each point is in ? I guess I could test to see which circle each point lies in by its distance from the centrepoint, and then which sector the point lies in by its angle from the centrepoint, but this seems rather laborious and inelegant..

This question bears some similarity to this one, except that I'm using circular lines to demarcate grid cells rather than linear lines.

Best Answer

To me, the simplest approach is to probably convert your XY datapoints to the polar coordinate system that defines your circular 'arena'.

Be sure to convert your XY coordinates such that the center of your circle is the origin of your Cartesian grid before converting to polar coordinates. Almost all math texts would provide these straightforward conversion equations, but this Wikipedia entry would definitely suffice.

Each of your equal area sectors are bounded by specific values for R and theta in the polar coordinate system.

Once you convert your Cartesian coordinates, simply round the calculated polar coordinates for each of your points to the nearest R and theta values that define your arena sectors.

This solution may be 'inelegant', but it strikes me as being about as straightforward as you could get.