Semi-join?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Semi-join?

Tim Keitt-3
I keep finding things that are trivial in sql are not so in R, so perhaps
you can help me out.

What would be the way in the 'sf' package to retain only polygons from one
coverage that intersect points in another coverage? I think that's a
semi-join.

Roughly: 'select a.* from polys a, points b where st_intersects(a.geom,
b.geom)'

Thanks.

THK

--
Timothy H. Keitt
Professor of Integrative Biology and
Associate Chair for Undergraduate Education
http://www.keittlab.org/

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Semi-join?

edzer


On 5/7/19 8:29 PM, Tim Keitt wrote:
> I keep finding things that are trivial in sql are not so in R, so perhaps
> you can help me out.
>
> What would be the way in the 'sf' package to retain only polygons from one
> coverage that intersect points in another coverage? I think that's a
> semi-join.
>
> Roughly: 'select a.* from polys a, points b where st_intersects(a.geom,
> b.geom)'

a[b,]

# or

st_join(a, b, left = FALSE) # no left join gives you inner join

>
> Thanks.
>
> THK
>

--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

pEpkey.asc (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Semi-join?

Tim Keitt-3
On Tue, May 7, 2019 at 1:39 PM Edzer Pebesma <[hidden email]>
wrote:

>
>
> On 5/7/19 8:29 PM, Tim Keitt wrote:
> > I keep finding things that are trivial in sql are not so in R, so perhaps
> > you can help me out.
> >
> > What would be the way in the 'sf' package to retain only polygons from
> one
> > coverage that intersect points in another coverage? I think that's a
> > semi-join.
> >
> > Roughly: 'select a.* from polys a, points b where st_intersects(a.geom,
> > b.geom)'
>
> a[b,]
>
> # or
>
> st_join(a, b, left = FALSE) # no left join gives you inner join
>

Hmm... tried this and for some reasons it was not giving me what I wanted.
I will investigate.

THK


>
> >
> > Thanks.
> >
> > THK
> >
>
> --
> Edzer Pebesma
> Institute for Geoinformatics
> Heisenbergstrasse 2, 48151 Muenster, Germany
> Phone: +49 251 8333081
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >> This message is from an external sender. Learn more about why this <<
> >> matters at https://links.utexas.edu/rtyclf.                        <<
>


--
Timothy H. Keitt
Professor of Integrative Biology and
Associate Chair for Undergraduate Education
http://www.keittlab.org/

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Semi-join?

Tim Keitt-3
Thanks. Works now. It was an issue with map projections.

THK

On Tue, May 7, 2019 at 3:18 PM Tim Keitt <[hidden email]> wrote:

>
>
> On Tue, May 7, 2019 at 1:39 PM Edzer Pebesma <
> [hidden email]> wrote:
>
>>
>>
>> On 5/7/19 8:29 PM, Tim Keitt wrote:
>> > I keep finding things that are trivial in sql are not so in R, so
>> perhaps
>> > you can help me out.
>> >
>> > What would be the way in the 'sf' package to retain only polygons from
>> one
>> > coverage that intersect points in another coverage? I think that's a
>> > semi-join.
>> >
>> > Roughly: 'select a.* from polys a, points b where st_intersects(a.geom,
>> > b.geom)'
>>
>> a[b,]
>>
>> # or
>>
>> st_join(a, b, left = FALSE) # no left join gives you inner join
>>
>
> Hmm... tried this and for some reasons it was not giving me what I wanted.
> I will investigate.
>
> THK
>
>
>>
>> >
>> > Thanks.
>> >
>> > THK
>> >
>>
>> --
>> Edzer Pebesma
>> Institute for Geoinformatics
>> Heisenbergstrasse 2, 48151 Muenster, Germany
>> Phone: +49 251 8333081
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> >> This message is from an external sender. Learn more about why this <<
>> >> matters at https://links.utexas.edu/rtyclf.                        <<
>>
>
>
> --
> Timothy H. Keitt
> Professor of Integrative Biology and
> Associate Chair for Undergraduate Education
> http://www.keittlab.org/
>


--
Timothy H. Keitt
Professor of Integrative Biology and
Associate Chair for Undergraduate Education
http://www.keittlab.org/

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo