[R-sig-Geo] Spatial join/intersection in R

Roozbeh Valavi rv@|@v| @end|ng |rom @tudent@un|me|b@edu@@u
Sun May 5 04:49:26 CEST 2019

```Thank you for your explanation, Tom.

Let me explain the case clearly.
The point layer is a very dense grid field collection across Great Britain.
I wanted to do spatial cross-validation by specifying each point in one of
the polygons (and assign a group of the polygons to a fold). Since the
points have been sampled on a regular grid they sometimes fall exactly on
the border of the polygons. If I use any sort of intersection or spatial
join, the points on the borders cause a problem.

Currently, I use st_jitter() in sf package give a bit of randomness to the
points. I wanted to see if there is another systematic way to avoid this.

Thanks,
Roozbeh

PhD Candidate
The Quantitative & Applied Ecology Group <http://qaeco.com/>
School of BioSciences | Faculty of Science
The University of Melbourne, VIC 3010, Australia
M: +61 423 283 238  E: rvalavi using student.unimelb.edu.au

On Wed, May 1, 2019 at 3:16 PM Tom Philippi <tephilippi using gmail.com> wrote:

> Roozbeh--
>
> What do you want to have happen with those points? Given the units in your
> figure, you could unambiguously assign them to the upper-right by adding a
> small value (0.000001) to both the X and Y coordinates of your points.
> Whether that is a sensible thing to do depends on what your data are.
>
> How or why do the points fall exactly on your polygon boundaries?  What
> process puts them exactly on the polygon (grid cell) boundaries?  It
> appears your polygon boundaries are a grid at multiples of 0.05, although
> not all potential cells in a rectangle are shown.  Are there many other
> points not on polygon boundaries not shown in your figure, or are points
> only along grid lines?  If the latter, does it make sense to assign them to
> _polygons_ rather than line segments?
>
> If you're doing a sample draw or measuring locations with only a few
> decimal points of accuracy, and generating your polygon boundaries at exact
> multiples of 0.05, then it might make sense to shift all of your points +
> 1/10th of your point location resolution so that their coordinates never
> fall on polygon boundaries.  There _might_ be situations where instead of
> always adding (shifting up and right), you should randomly add or subtract
> in each direction for each point, but I'm stuck viewing this as points in
> sTomample units so I can't think of such a case.
>
> Tom
> .
>
> On Tue, Apr 30, 2019 at 7:18 PM Roozbeh Valavi <
> rvalavi using student.unimelb.edu.au> wrote:
>
>> Dear members,
>>
>> I want to do a spatial join/intersection in R. The problem is that some
>> of my points are lying exactly at the border of the adjacent polygons (see
>> the figure attached). So these points are either falling in both or none of
>> the polygons! Is there any way to avoid this?
>>
>> Roozbeh
>>
>>
>> [image: image.png]
>>
>>
>>
>> --
>> *Roozbeh Valavi*
>> PhD Candidate
>> The Quantitative & Applied Ecology Group <http://qaeco.com/>
>> School of BioSciences | Faculty of Science
>> The University of Melbourne, VIC 3010, Australia
>> Mobile: +61 423 283 238
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190505/b678d62e/attachment.html>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 27322 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190505/b678d62e/attachment.png>
```