Merging Shape files

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

Merging Shape files

El Mechry El Koudouss
Dear readers,
I downloaded a shapefile with data on crime incidents in Washington DC in
2016 (available here:
https://opendata.dc.gov/datasets/crime-incidents-in-2016) and another
shapefile with data on parks and recreation areas, also in Washington DC
(available here: https://opendata.dc.gov/datasets/parks-and-recreation-areas).
I was able to read both shapefiles using st_read() from the sf package. My
question is, how can I merge the two data sets? I tried st_join() but it
simply resulted in empty columns from the parks dataset getting added to
the crime data. Any guidance would be much appreciated.
library(sf)
parks <- st_read("Parks_and_Recreation_Areas.shp")
crime <- st_read("Crime_Incidents_in_2016.shp")
df <- st_join(crime, parks)

--
El Mechry, El Koudouss (Meshry)
Graduate Research Assistant
Center for International Policy Studies
Fordham University
Department of Economics
Website: www.meshry.com

        [[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: Merging Shape files

Dexter Locke
Within st_join() see the options like "left = TRUE".

You may also want to look at st_intersects()

Here are other helpful reference websites:
https://r-spatial.github.io/sf/reference/geos_binary_pred.html

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

-Dexter


On Tue, Mar 17, 2020 at 10:29 AM El Mechry El Koudouss <
[hidden email]> wrote:

> Dear readers,
> I downloaded a shapefile with data on crime incidents in Washington DC in
> 2016 (available here:
> https://opendata.dc.gov/datasets/crime-incidents-in-2016) and another
> shapefile with data on parks and recreation areas, also in Washington DC
> (available here:
> https://opendata.dc.gov/datasets/parks-and-recreation-areas).
> I was able to read both shapefiles using st_read() from the sf package. My
> question is, how can I merge the two data sets? I tried st_join() but it
> simply resulted in empty columns from the parks dataset getting added to
> the crime data. Any guidance would be much appreciated.
> library(sf)
> parks <- st_read("Parks_and_Recreation_Areas.shp")
> crime <- st_read("Crime_Incidents_in_2016.shp")
> df <- st_join(crime, parks)
>
> --
> El Mechry, El Koudouss (Meshry)
> Graduate Research Assistant
> Center for International Policy Studies
> Fordham University
> Department of Economics
> Website: www.meshry.com
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[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: Merging Shape files

Zia Ahmed
Please  check this:

https://zia207.github.io/geospatial-r-github.io/geoprocessing-vector-data.html
Best
Zia

On Tue, Mar 17, 2020, 10:39 AM Dexter Locke <[hidden email]> wrote:

> Within st_join() see the options like "left = TRUE".
>
> You may also want to look at st_intersects()
>
> Here are other helpful reference websites:
> https://r-spatial.github.io/sf/reference/geos_binary_pred.html
>
> https://cran.r-project.org/web/packages/sf/vignettes/sf3.html
>
> -Dexter
>
>
> On Tue, Mar 17, 2020 at 10:29 AM El Mechry El Koudouss <
> [hidden email]> wrote:
>
> > Dear readers,
> > I downloaded a shapefile with data on crime incidents in Washington DC in
> > 2016 (available here:
> > https://opendata.dc.gov/datasets/crime-incidents-in-2016) and another
> > shapefile with data on parks and recreation areas, also in Washington DC
> > (available here:
> > https://opendata.dc.gov/datasets/parks-and-recreation-areas).
> > I was able to read both shapefiles using st_read() from the sf package.
> My
> > question is, how can I merge the two data sets? I tried st_join() but it
> > simply resulted in empty columns from the parks dataset getting added to
> > the crime data. Any guidance would be much appreciated.
> > library(sf)
> > parks <- st_read("Parks_and_Recreation_Areas.shp")
> > crime <- st_read("Crime_Incidents_in_2016.shp")
> > df <- st_join(crime, parks)
> >
> > --
> > El Mechry, El Koudouss (Meshry)
> > Graduate Research Assistant
> > Center for International Policy Studies
> > Fordham University
> > Department of Economics
> > Website: www.meshry.com
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[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: Merging Shape files

Zia Ahmed
You welcome.

If you are interested in geospatial analysis in python, you check this:

https://zia207.github.io/geospatial-python.io/

Best
Zia

On Wed, Mar 18, 2020, 10:45 AM Dexter Locke <[hidden email]> wrote:

> Zia: this is a fabulous resource!!
>
> Thanks for sharing,
> Dexter
>
>
> On Wed, Mar 18, 2020 at 10:37 AM Zia Ahmed <[hidden email]> wrote:
>
>> Please  check this:
>>
>>
>> https://zia207.github.io/geospatial-r-github.io/geoprocessing-vector-data.html
>> Best
>> Zia
>>
>> On Tue, Mar 17, 2020, 10:39 AM Dexter Locke <[hidden email]>
>> wrote:
>>
>>> Within st_join() see the options like "left = TRUE".
>>>
>>> You may also want to look at st_intersects()
>>>
>>> Here are other helpful reference websites:
>>> https://r-spatial.github.io/sf/reference/geos_binary_pred.html
>>>
>>> https://cran.r-project.org/web/packages/sf/vignettes/sf3.html
>>>
>>> -Dexter
>>>
>>>
>>> On Tue, Mar 17, 2020 at 10:29 AM El Mechry El Koudouss <
>>> [hidden email]> wrote:
>>>
>>> > Dear readers,
>>> > I downloaded a shapefile with data on crime incidents in Washington DC
>>> in
>>> > 2016 (available here:
>>> > https://opendata.dc.gov/datasets/crime-incidents-in-2016) and another
>>> > shapefile with data on parks and recreation areas, also in Washington
>>> DC
>>> > (available here:
>>> > https://opendata.dc.gov/datasets/parks-and-recreation-areas).
>>> > I was able to read both shapefiles using st_read() from the sf
>>> package. My
>>> > question is, how can I merge the two data sets? I tried st_join() but
>>> it
>>> > simply resulted in empty columns from the parks dataset getting added
>>> to
>>> > the crime data. Any guidance would be much appreciated.
>>> > library(sf)
>>> > parks <- st_read("Parks_and_Recreation_Areas.shp")
>>> > crime <- st_read("Crime_Incidents_in_2016.shp")
>>> > df <- st_join(crime, parks)
>>> >
>>> > --
>>> > El Mechry, El Koudouss (Meshry)
>>> > Graduate Research Assistant
>>> > Center for International Policy Studies
>>> > Fordham University
>>> > Department of Economics
>>> > Website: www.meshry.com
>>> >
>>> >         [[alternative HTML version deleted]]
>>> >
>>> > _______________________________________________
>>> > R-sig-Geo mailing list
>>> > [hidden email]
>>> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>> >
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> [hidden email]
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>

        [[alternative HTML version deleted]]

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