Hi Julie,
Your task is a bit obscure and I don't have the function
"st_intersects", but I'll suggest this:
br_list<-list()
# your commands would have only run once
for (i in 1:nrow(arrets_buffer)) {
br_list[[i]]<- st_intersects(x = batiments, arrets_buffer[i,], sparse =
FALSE)
}
You should get a list with nrow(arrets_buffer) elements, each of which
will be the result of your "st_intersects" function.
Jim
On Wed, Apr 22, 2020 at 6:00 PM Julie Poitevin <julie at e-poitevin.fr>
wrote:>
> Hello,
> > I want to build a map (bus accessibility map) and for that I need to
identify some polygons intersections. To do that I have 2 data.frame: batiments
(that gives buildings in a city) and arrets_buffer (that gives bus stops
(points) with a buffer around the point).
> >
> > I want to have a column giving the intersect binary result (TRUE or
FALSE) in batiments data.frame. I use st_intersects from sf package.
> >
> > For that I wanted to perform this loop, but it's not a good idea:
> >
> > for (i in nrow(arrets_buffer)) {
> > batiments$in_recharges <- st_intersects(x = batiments,
arrets_buffer[i,], sparse = FALSE)
> > }
> >
> > each time i is incremented, batiments$in_recharges is removed with new
values. So at the end I have results for i=nrow(arrets_buffer) only....
> >
> > No possibility to add a loop in the loop as the number of lines is
quite important (the loop will turns a long time..)
> >
> > Do you have some some idea to help me?
> >
> > Many thanks for your help
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.