Sp-package overlay

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

Sp-package overlay

|_Ivy_|
Hey there,

For my internship I have to work with R. I am working with R for the first
time and I don't know much.
Somehow I don't manage to find the answer to my question in google. I think
I don't search with the right words, or maybe I just don't understand
enough. Anyways, I hope someone here can help me out.

I have 2 datasets:

a SpatialPolygonDataFrame, this dataset is called "field" (these are
different fields of arable land)
and a SpatialPointsDataFrame, this dataset is called "odk" (these are
different soil samples taken in each field)

The field data set consists of 8 polygons and they have a slot with coords

The odk data set consists of 537 features (soil samples), these features
belong to the polygons but they are all mixed. This dataset also has a slot
with coords

They are both projected in the same coordinate system.

Now I would like to create a new dataset with a table with the features of
odk that belong to polygon 1 and a separate table for the features that
belong to polygon 2 etc. The best is if they also get into the
spatialpointsdataframe format.

I really don't know how to do this. I hope someone here can help me out. I
hope that I gave enough information for anyone to help me else let me know
if I have to tell something more about my datasets.

Thank you already a lot in advance,

Hope to hear from anyone soon,

Kind regards,

Ivy

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Sp-package overlay

Ben Tupper-2
Hi,

I'm pretty sure that what you ask is likely not too hard to do.  On the other hand, I think you will do well to consider the following...

1. Join the mailing list; the folks there will know better what you are trying to do - see

https://stat.ethz.ch/mailman/listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>


2. Switch from the sf package to the sf package if you can - see  

https://cran.r-project.org/web/packages/sf/


3. Come up to speed with geospatial data handling in R starting here

https://geocompr.robinlovelace.net/index.html


Cheers,
Ben


> On Oct 2, 2018, at 10:33 AM, Ivy Pieters <[hidden email]> wrote:
>
> Hey there,
>
> For my internship I have to work with R. I am working with R for the first
> time and I don't know much.
> Somehow I don't manage to find the answer to my question in google. I think
> I don't search with the right words, or maybe I just don't understand
> enough. Anyways, I hope someone here can help me out.
>
> I have 2 datasets:
>
> a SpatialPolygonDataFrame, this dataset is called "field" (these are
> different fields of arable land)
> and a SpatialPointsDataFrame, this dataset is called "odk" (these are
> different soil samples taken in each field)
>
> The field data set consists of 8 polygons and they have a slot with coords
>
> The odk data set consists of 537 features (soil samples), these features
> belong to the polygons but they are all mixed. This dataset also has a slot
> with coords
>
> They are both projected in the same coordinate system.
>
> Now I would like to create a new dataset with a table with the features of
> odk that belong to polygon 1 and a separate table for the features that
> belong to polygon 2 etc. The best is if they also get into the
> spatialpointsdataframe format.
>
> I really don't know how to do this. I hope someone here can help me out. I
> hope that I gave enough information for anyone to help me else let me know
> if I have to tell something more about my datasets.
>
> Thank you already a lot in advance,
>
> Hope to hear from anyone soon,
>
> Kind regards,
>
> Ivy
>
> ______________________________________________
> [hidden email] 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.
>

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/






        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Sp-package overlay

R help mailing list-2
In addition, the function you want is
  sp::over
or its equivalent in sf

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

´╗┐On 10/2/18, 1:41 PM, "R-help on behalf of Ben Tupper" <[hidden email] on behalf of [hidden email]> wrote:

    Hi,
   
    I'm pretty sure that what you ask is likely not too hard to do.  On the other hand, I think you will do well to consider the following...
   
    1. Join the mailing list; the folks there will know better what you are trying to do - see
   
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
   
   
    2. Switch from the sf package to the sf package if you can - see  
   
    https://cran.r-project.org/web/packages/sf/
   
   
    3. Come up to speed with geospatial data handling in R starting here
   
    https://geocompr.robinlovelace.net/index.html
   
   
    Cheers,
    Ben
   
   
    > On Oct 2, 2018, at 10:33 AM, Ivy Pieters <[hidden email]> wrote:
    >
    > Hey there,
    >
    > For my internship I have to work with R. I am working with R for the first
    > time and I don't know much.
    > Somehow I don't manage to find the answer to my question in google. I think
    > I don't search with the right words, or maybe I just don't understand
    > enough. Anyways, I hope someone here can help me out.
    >
    > I have 2 datasets:
    >
    > a SpatialPolygonDataFrame, this dataset is called "field" (these are
    > different fields of arable land)
    > and a SpatialPointsDataFrame, this dataset is called "odk" (these are
    > different soil samples taken in each field)
    >
    > The field data set consists of 8 polygons and they have a slot with coords
    >
    > The odk data set consists of 537 features (soil samples), these features
    > belong to the polygons but they are all mixed. This dataset also has a slot
    > with coords
    >
    > They are both projected in the same coordinate system.
    >
    > Now I would like to create a new dataset with a table with the features of
    > odk that belong to polygon 1 and a separate table for the features that
    > belong to polygon 2 etc. The best is if they also get into the
    > spatialpointsdataframe format.
    >
    > I really don't know how to do this. I hope someone here can help me out. I
    > hope that I gave enough information for anyone to help me else let me know
    > if I have to tell something more about my datasets.
    >
    > Thank you already a lot in advance,
    >
    > Hope to hear from anyone soon,
    >
    > Kind regards,
    >
    > Ivy
    >
    > ______________________________________________
    > [hidden email] 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.
    >
   
    Ben Tupper
    Bigelow Laboratory for Ocean Sciences
    60 Bigelow Drive, P.O. Box 380
    East Boothbay, Maine 04544
    http://www.bigelow.org
   
    Ecological Forecasting: https://eco.bigelow.org/
   
   
   
   
   
   
    [[alternative HTML version deleted]]
   
    ______________________________________________
    [hidden email] 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.
   

______________________________________________
[hidden email] 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.