TransWikia.com

st_intersection only if specific conditions are satisfied

Geographic Information Systems Asked on July 30, 2020

I’m new to sf package.

I have two sf files, one containing lat/long position of points (point_sf) and the other one containing sf polygon geometries (polygon_sf). I want to see which points belong to specific polygons (using sf_intersection this is easy) however certain conditions must be met (I believe this would also reduce multiple options).

For example, I want to "match" only points that are within specific altitude band, which is defined in one of the columns in polygon_sf, and that years (values exist in both files) are the same. I have tried the following but it gives NULL output.

point_new <- if(point_sf$year== point_sf$year&
                  point_sf$FL >= polygon_sf$from_FL &
                  point_sf$FL <= polygon_sf$to_FL)  {
  st_intersection(point_sf, st_difference(point_sf))}

Any suggestions?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP