::p_load(maptools, sf, raster, spatstat, tmap) pacman
InClass_Ex04
Getting Started
Installing and Loading the R packages
Importing the spatial data
#chunk2
<- st_read("data/child-care-services-geojson.geojson") %>%
childcare_sf st_transform(crs = 3414)
Reading layer `child-care-services-geojson' from data source
`C:\Quanfang777\IS415-GAA\WeeklyExercise\week4\InClass_Ex04\data\child-care-services-geojson.geojson'
using driver `GeoJSON'
Simple feature collection with 1545 features and 2 fields
Geometry type: POINT
Dimension: XYZ
Bounding box: xmin: 103.6824 ymin: 1.248403 xmax: 103.9897 ymax: 1.462134
z_range: zmin: 0 zmax: 0
Geodetic CRS: WGS 84
<- st_read(dsn = "data", layer="CostalOutline") sg_sf
Reading layer `CostalOutline' from data source
`C:\Quanfang777\IS415-GAA\WeeklyExercise\week4\InClass_Ex04\data'
using driver `ESRI Shapefile'
Simple feature collection with 60 features and 4 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: 2663.926 ymin: 16357.98 xmax: 56047.79 ymax: 50244.03
Projected CRS: SVY21
##hellp
<- st_read(dsn = "data",
mpsz_sf layer = "MP14_SUBZONE_WEB_PL")
Reading layer `MP14_SUBZONE_WEB_PL' from data source
`C:\Quanfang777\IS415-GAA\WeeklyExercise\week4\InClass_Ex04\data'
using driver `ESRI Shapefile'
Simple feature collection with 323 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21
<- st_set_crs(mpsz_sf, 3414) mpsz3414
<- as_Spatial(childcare_sf)
childcare <- as_Spatial(mpsz_sf)
mpsz <- as_Spatial(sg_sf) sg
<- as(childcare, "SpatialPoints")
childcare_sp <- as(sg, "SpatialPolygons") sg_sp
<- as(childcare_sp, "ppp")
childcare_ppp childcare_ppp
Planar point pattern: 1545 points
window: rectangle = [11203.01, 45404.24] x [25667.6, 49300.88] units
tmap_mode("plot")
tm_shape(mpsz3414)+ tm_polygons() + tm_shape(childcare_sf) + tm_dots()
tmap_mode('view')
tm_shape(childcare_sf)+tm_dots(alpha=0.5,size=0.01)+tm_view(set.zoom.limits = c(11,14))