Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using st_join for a spatial join using largest intersection

I am using the sf_package to work around spatial data in r. At this stage, I want to make a spatial join so that the tax lots of my area of study inherit the attributes of the floodplain on which they are located. For example, taxlots may be located in a floodplain categorized as X, VE, A, A0, or V (these are codes that relate to the intensity of the flood in each area).

To do this, I tested the sf function st_join, which will by default rely on st_intersects to determine the spatial join for each entity of my tax lots.

However, I am trying to figure out the criteria used by the function when a tax lot intersects with two different floodplain areas (as in the photo below, in which several lots intersect both with an A floodplain and an AE floodplain). Does it take the value of the area that covers the largest area of the lot? or is it a matter of which area is located upper in the dataframe?

Note that I am not interested in partitioning the intersecting lots so that I divide them according to their areas intersecting one and other floodplain zones.

Photo of tax lots intesecting with more than one floodplain category

like image 402
Pablo Herreros Cantis Avatar asked Jul 19 '26 00:07

Pablo Herreros Cantis


1 Answers

By default, st_join(x, y, join = st_intersects) duplicates all features in x, that intersect with more than one features from y.

If you set the argument largest = TRUE, st_join() returns the x features augmented with the fields of y that have the largest overlap with each of the features of x.

See https://r-spatial.github.io/sf/reference/st_join.html and https://github.com/r-spatial/sf/issues/578 for more details.

like image 193
cstepper Avatar answered Jul 21 '26 20:07

cstepper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!