-
Notifications
You must be signed in to change notification settings - Fork 1
/
loadHeetch.Rmd
68 lines (57 loc) · 1.53 KB
/
loadHeetch.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: "task1"
output: html_document
date: "`r Sys.Date()`"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Introduction
## Load packages
```{r LoadPackages}
library(dplyr)
library(sf)
library(leaflet)
library(lubridate)
library(mapsf)
library(tidyr)
```
## Load data and project spatial features
```{r LoadData}
heetchPoints <-readRDS("../data/heetchmarchcrop.Rds")
casaNeib <-st_read("../data/casaneib.geojson")
casaNeibProj <-st_transform(casaNeib, crs=26191)
heetchPointsProj <-st_transform(heetchPoints, crs=26191)
rm(heetchPoints)
rm(casaNeib)
#heetch_points_proj
head(heetchPointsProj) #(driver_id, location_at_local_time, geometry)
class(heetchPointsProj)
str(heetchPointsProj)
#heetch_points_proj
head(casaNeibProj) #(driver_id, location_at_local_time, geometry)
class(casaNeibProj)
str(casaNeibProj)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
## Intersecter les points x et les quartiers y
```{r IntersectPointsToNeib}
casaNeibUnion <-st_union(casaNeibProj)
selectPtsInCasa <-st_contains(x=casaNeibUnion, y=heetchPointsProj)%>%
unlist()
heetchPointsProj <-heetchPointsProj[selectPtsInCasa,]
ptsInNeib <-st_within(x=heetchPointsProj, y=casaNeibProj) %>%
unlist()
heetchPointsProj$NEIB <-ptsInNeib
rm(casaNeibUnion)
rm(selectPtsInCasa)
rm(ptsInNeib)
saveRDS(heetchPointsProj, file = "../data/heetchmarchcropwithneib.Rds")
head(heetchPointsProj) #(driver_id, location_at_local_time, geometry)
str(heetchPointsProj)
class(heetchPointsProj)
```