Take-Home Exercise 01

Author

Xinyee How

Published

January 30, 2023

Exploratory Spatial Data Analysis (ESDA)

Getting packages

pacman::p_load(sf, tidyverse, funModeling, ggplot2)

Importing data - Geospatial

geoNGA <- st_read("data/geoBoundaries/",
                  layer = "geoBoundaries-NGA-ADM2") %>%
  st_transform(crs = 26392)
Reading layer `geoBoundaries-NGA-ADM2' from data source 
  `C:\xinyeehow\IS415-GAA\Take-Home_Ex\Take-Home_Ex01\data\geoBoundaries' 
  using driver `ESRI Shapefile'
Simple feature collection with 774 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2.668534 ymin: 4.273007 xmax: 14.67882 ymax: 13.89442
Geodetic CRS:  WGS 84
NGA <- st_read("data/",
               layer = "nga_admbnda_adm2_osgof_20190417") %>%
  st_transform(crs = 26392)
Reading layer `nga_admbnda_adm2_osgof_20190417' from data source 
  `C:\xinyeehow\IS415-GAA\Take-Home_Ex\Take-Home_Ex01\data' using driver `ESRI Shapefile'
Simple feature collection with 774 features and 16 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2.668534 ymin: 4.273007 xmax: 14.67882 ymax: 13.89442
Geodetic CRS:  WGS 84

Extract Osun state from Nigeria

osun <- st_read(dsn = "data/", 
               layer = "nga_admbnda_adm2_osgof_20190417") %>%
      filter(`ADM1_EN` == "Osun") %>%
      st_transform(crs = 26392)
Reading layer `nga_admbnda_adm2_osgof_20190417' from data source 
  `C:\xinyeehow\IS415-GAA\Take-Home_Ex\Take-Home_Ex01\data' using driver `ESRI Shapefile'
Simple feature collection with 774 features and 16 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2.668534 ymin: 4.273007 xmax: 14.67882 ymax: 13.89442
Geodetic CRS:  WGS 84

Examining Osun layer

osun
Simple feature collection with 30 features and 16 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 176503.2 ymin: 331434.7 xmax: 291043.8 ymax: 454520.1
Projected CRS: Minna / Nigeria Mid Belt
First 10 features:
   Shape_Leng  Shape_Area        ADM2_EN ADM2_PCODE       ADM2_REF ADM2ALT1EN
1   1.7951405 0.062436080       Aiyedade   NG030001       Aiyedade       <NA>
2   0.7101503 0.024818478       Aiyedire   NG030002       Aiyedire       <NA>
3   0.9199564 0.038002894 Atakumosa East   NG030003 Atakumosa East       <NA>
4   0.8502782 0.030445804 Atakumosa West   NG030004 Atakumosa West       <NA>
5   0.5212768 0.012213340     Boluwaduro   NG030005     Boluwaduro       <NA>
6   0.6088930 0.011827501         Boripe   NG030006         Boripe       <NA>
7   0.4714403 0.008343638      Ede North   NG030007      Ede North       <NA>
8   0.5660235 0.017623677      Ede South   NG030008      Ede South       <NA>
9   0.8273123 0.022026327       Egbedore   NG030009       Egbedore       <NA>
10  1.1304849 0.029791275         Ejigbo   NG030010         Ejigbo       <NA>
   ADM2ALT2EN ADM1_EN ADM1_PCODE ADM0_EN ADM0_PCODE       date    validOn
1        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
2        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
3        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
4        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
5        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
6        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
7        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
8        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
9        <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
10       <NA>    Osun      NG030 Nigeria         NG 2016-11-29 2019-04-17
   validTo        SD_EN SD_PCODE                       geometry
1     <NA>    Osun West  NG03003 MULTIPOLYGON (((213526.6 34...
2     <NA>    Osun West  NG03003 MULTIPOLYGON (((212542.6 40...
3     <NA>    Osun East  NG03002 MULTIPOLYGON (((265746.8 37...
4     <NA>    Osun East  NG03002 MULTIPOLYGON (((248871.4 40...
5     <NA> Osun Central  NG03001 MULTIPOLYGON (((266092.2 43...
6     <NA> Osun Central  NG03001 MULTIPOLYGON (((255072.5 43...
7     <NA>    Osun West  NG03003 MULTIPOLYGON (((236386.9 41...
8     <NA>    Osun West  NG03003 MULTIPOLYGON (((236386.9 41...
9     <NA>    Osun West  NG03003 MULTIPOLYGON (((220756 4317...
10    <NA>    Osun West  NG03003 MULTIPOLYGON (((214422.1 42...

Importing data - Aspatial

wp_nga <- read_csv("data/WPdx.csv") %>%
  filter(`#clean_country_name` == "Nigeria", `#clean_adm1` == "Osun")

Examining the filtered waterpoint layer

glimpse(wp_nga)
Rows: 5,557
Columns: 70
$ row_id                        <dbl> 429123, 70566, 70578, 66401, 422190, 422…
$ `#source`                     <chr> "GRID3", "Federal Ministry of Water Reso…
$ `#lat_deg`                    <dbl> 8.020000, 7.317741, 7.759448, 8.031187, …
$ `#lon_deg`                    <dbl> 5.060000, 4.785507, 4.563998, 4.637400, …
$ `#report_date`                <chr> "08/29/2018 12:00:00 AM", "05/11/2015 12…
$ `#status_id`                  <chr> "Unknown", "No", "No", "No", "Unknown", …
$ `#water_source_clean`         <chr> NA, "Protected Shallow Well", "Borehole"…
$ `#water_source_category`      <chr> NA, "Well", "Well", "Well", NA, NA, "Wel…
$ `#water_tech_clean`           <chr> "Tapstand", "Mechanized Pump", "Mechaniz…
$ `#water_tech_category`        <chr> "Tapstand", "Mechanized Pump", "Mechaniz…
$ `#facility_type`              <chr> "Improved", "Improved", "Improved", "Imp…
$ `#clean_country_name`         <chr> "Nigeria", "Nigeria", "Nigeria", "Nigeri…
$ `#clean_adm1`                 <chr> "Osun", "Osun", "Osun", "Osun", "Osun", …
$ `#clean_adm2`                 <chr> "Ifedayo", "Atakumosa East", "Osogbo", "…
$ `#clean_adm3`                 <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#clean_adm4`                 <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#install_year`               <dbl> NA, NA, NA, 2004, NA, NA, 2006, 2014, 20…
$ `#installer`                  <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#rehab_year`                 <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#rehabilitator`              <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#management_clean`           <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, "Com…
$ `#status_clean`               <chr> NA, "Abandoned/Decommissioned", "Abandon…
$ `#pay`                        <chr> NA, "No", "No", "No", NA, NA, "No", "No"…
$ `#fecal_coliform_presence`    <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#fecal_coliform_value`       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#subjective_quality`         <chr> NA, "Acceptable quality", "Acceptable qu…
$ `#activity_id`                <chr> "6054e946-2573-45bf-ab7c-0ddaa68a61b4", …
$ `#scheme_id`                  <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#wpdx_id`                    <chr> "6FW723C6+222", "6FV68Q9P+36R", "6FV6QH5…
$ `#notes`                      <chr> "Rt Hon Kola Oluwawole Water Tap", "Temi…
$ `#orig_lnk`                   <chr> "https://nigeria.africageoportal.com/dat…
$ `#photo_lnk`                  <chr> NA, "https://akvoflow-55.s3.amazonaws.co…
$ `#country_id`                 <chr> "NG", "NG", "NG", "NG", "NG", "NG", "NG"…
$ `#data_lnk`                   <chr> "https://catalog.waterpointdata.org/data…
$ `#distance_to_primary_road`   <dbl> 4474.22234, 10130.42742, 167.82235, 4133…
$ `#distance_to_secondary_road` <dbl> 1883.98780, 17466.35720, 838.91849, 1162…
$ `#distance_to_tertiary_road`  <dbl> 1885.874322, 2376.832183, 1181.107236, 9…
$ `#distance_to_city`           <dbl> 40100.268, 31549.222, 2449.293, 16704.19…
$ `#distance_to_town`           <dbl> 8120.871, 24652.907, 9463.295, 5176.899,…
$ water_point_history           <chr> "{\"2018-08-29\": {\"source\": \"GRID3\"…
$ rehab_priority                <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ water_point_population        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, 0, 508, …
$ local_population_1km          <dbl> NA, NA, NA, NA, NA, NA, NA, NA, 70, 647,…
$ crucialness_score             <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.78…
$ pressure_score                <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, 1.69…
$ usage_capacity                <dbl> 250, 1000, 1000, 1000, 250, 250, 1000, 3…
$ is_urban                      <lgl> FALSE, FALSE, TRUE, FALSE, FALSE, FALSE,…
$ days_since_report             <dbl> 1483, 2689, 2689, 2700, 1483, 1483, 2688…
$ staleness_score               <dbl> 62.65911, 42.84384, 42.84384, 42.69554, …
$ latest_record                 <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE…
$ location_id                   <dbl> 358783, 239555, 239556, 230405, 358062, …
$ cluster_size                  <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ `#clean_country_id`           <chr> "NGA", "NGA", "NGA", "NGA", "NGA", "NGA"…
$ `#country_name`               <chr> "Nigeria", "Nigeria", "Nigeria", "Nigeri…
$ `#water_source`               <chr> "Tap", "Improved Protected dug well", "I…
$ `#water_tech`                 <chr> NA, "Motorised", "Motorised", "Motorised…
$ `#status`                     <chr> NA, "Non-functional Abandoned", "Non-fun…
$ `#adm2`                       <chr> NA, "Atakumosa East", "Osogbo", "Odo-Oti…
$ `#adm3`                       <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ `#management`                 <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, "Com…
$ `#adm1`                       <chr> NA, "Osun", "Osun", "Osun", NA, NA, "Osu…
$ `New Georeferenced Column`    <chr> "POINT (5.06 8.02)", "POINT (4.7855068 7…
$ lat_deg_original              <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ lat_lon_deg                   <chr> "(8.02°, 5.06°)", "(7.3177411°, 4.785506…
$ lon_deg_original              <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ public_data_source            <chr> "https://catalog.waterpointdata.org/data…
$ converted                     <chr> NA, "#status_id, #water_source, #pay, #s…
$ count                         <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ created_timestamp             <chr> "12/06/2021 09:12:57 PM", "06/30/2020 12…
$ updated_timestamp             <chr> "12/06/2021 09:12:57 PM", "06/30/2020 12…

Converting Aspatial to Geospatial data

wp_nga$Geometry = st_as_sfc(wp_nga$`New Georeferenced Column`)
#wp_nga = st_as_sf(wp_nga, coords = c("lat_deg", "lon_deg"),crs=4326)
#wp_nga
wp_sf <- st_sf(wp_nga, crs=4326)
st_geometry(wp_sf)
Geometry set for 5557 features 
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 4.032004 ymin: 7.060309 xmax: 5.06 ymax: 8.061898
Geodetic CRS:  WGS 84
First 5 geometries:

Extracting waterpoints in Osun area

Transforming project

wp_sf <- wp_sf %>%
  st_transform(crs = 26392)

Data Cleaning

Checking for duplicate name

NGA$ADM2_EN[duplicated(NGA$ADM2_EN)==TRUE]
[1] "Bassa"    "Ifelodun" "Irepodun" "Nasarawa" "Obi"      "Surulere"

Correcting errors

NGA$ADM2_EN[94] <- "Bassa, Kogi"
NGA$ADM2_EN[95] <- "Bassa, Plateau"
NGA$ADM2_EN[304] <- "Ifelodun, Kwara"
NGA$ADM2_EN[305] <- "Ifelodun, Osun"
NGA$ADM2_EN[355] <- "Irepodun, Kwara"
NGA$ADM2_EN[356] <- "Irepodun, Osun"
NGA$ADM2_EN[519] <- "Nasarawa, Kano"
NGA$ADM2_EN[520] <- "Nasarawa, Nasarawa"
NGA$ADM2_EN[546] <- "Obi, Benue"
NGA$ADM2_EN[547] <- "Obi, Nasarawa"
NGA$ADM2_EN[693] <- "Surulere, Lagos"
NGA$ADM2_EN[694] <- "Surulere, Oyo"
NGA$ADM2_EN[duplicated(NGA$ADM2_EN)==TRUE]
character(0)

Data Wrangling (water point data)

Bar graph of water status according to cleanliness of water

ggplot(wp_sf) + geom_bar(aes(y = fct_infreq(`#status_clean`), fill=`#status_clean`, stat="identity"))+  theme(legend.position = "right")

Categorising functional and non-functional water points

Functional

wp_functional <- wp_sf %>%
  filter(`#status_clean` %in%
           c("Functional",
             "Functional but not in use",
             "Functional but needs repair"))
ggplot(wp_functional) + geom_bar(aes(y = fct_infreq(`#status_clean`), fill=`#status_clean`, stat="identity"))+  theme(legend.position = "right")

Non-functional

wp_nonfunctional <- wp_sf %>%
  filter(`#status_clean` %in%
           c("Abandoned/Decommissioned",
             "Abandoned",
             "Non-Functional due to dry season",
             "Non-Functional",
             "Non functional due to dry season"))
ggplot(wp_nonfunctional) + geom_bar(aes(y = fct_infreq(`#status_clean`), fill=`#status_clean`, stat="identity"))+  theme(legend.position = "right")

Saving data

write_rds(wp_sf, "data/rds/wp_sf.rds")

Kernel density maps of functional and non-functional water points using appropriate tmap functions

Loading packages

pacman::p_load(maptools, sf, raster, spatstat, tmap)

Converting sf data frames to sp’s Spatial* class

wp_functional_sf <- as_Spatial(wp_functional)
wp_nonfunctional_sf <- as_Spatial(wp_nonfunctional)
NGA_sf <- as_Spatial(NGA)
osun_sf <- as_Spatial(osun)
wp_functional_sf
class       : SpatialPointsDataFrame 
features    : 2630 
extent      : 177285.9, 290751, 343128.1, 450859.7  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 
variables   : 70
names       : row_id,                                     X.source, X.lat_deg, X.lon_deg,          X.report_date, X.status_id, X.water_source_clean, X.water_source_category,      X.water_tech_clean, X.water_tech_category, X.facility_type, X.clean_country_name, X.clean_adm1, X.clean_adm2, X.clean_adm3, ... 
min values  :  36914, Federal Ministry of Water Resources, Nigeria, 7.0890301, 4.0320038, 01/01/2010 12:00:00 AM,     Unknown,             Borehole,                  Spring,               Hand Pump,             Hand Pump,        Improved,              Nigeria,         Osun,     Aiyedade,           NA, ... 
max values  : 471319,                                        GRID3, 8.0618983, 5.0550034, 09/16/2015 12:00:00 AM,         Yes,     Protected Spring,                    Well, Mechanized Pump - Solar,       Mechanized Pump,        Improved,              Nigeria,         Osun,       Osogbo,           NA, ... 
wp_nonfunctional_sf
class       : SpatialPointsDataFrame 
features    : 2179 
extent      : 180539, 290616, 340054.1, 450780.1  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 
variables   : 70
names       : row_id,                                     X.source, X.lat_deg, X.lon_deg,          X.report_date, X.status_id, X.water_source_clean, X.water_source_category,      X.water_tech_clean, X.water_tech_category, X.facility_type, X.clean_country_name, X.clean_adm1, X.clean_adm2, X.clean_adm3, ... 
min values  :  34829, Federal Ministry of Water Resources, Nigeria,  7.060309, 4.0618927, 01/10/2015 12:00:00 AM,          No,             Borehole,                  Spring,               Hand Pump,             Hand Pump,        Improved,              Nigeria,         Osun,     Aiyedade,           NA, ... 
max values  : 421239,                                        GRID3, 8.0611733, 5.0537867, 09/16/2015 12:00:00 AM,         Yes,     Protected Spring,                    Well, Mechanized Pump - Solar,       Mechanized Pump,        Improved,              Nigeria,         Osun,       Osogbo,           NA, ... 
NGA_sf
class       : SpatialPolygonsDataFrame 
features    : 774 
extent      : 26662.71, 1344157, 30523.38, 1096029  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 
variables   : 16
names       :    Shape_Leng,        Shape_Area,   ADM2_EN, ADM2_PCODE,  ADM2_REF, ADM2ALT1EN, ADM2ALT2EN, ADM1_EN, ADM1_PCODE, ADM0_EN, ADM0_PCODE,  date, validOn, validTo,        SD_EN, ... 
min values  :    0.10410787, 0.000342186810984, Aba North,   NG001001, Aba North,         NA,         NA,    Abia,      NG001, Nigeria,         NG, 17134,   18003,      NA, Abia Central, ... 
max values  : 6.76815542887,    0.929069095283,      Zuru,   NG037014,      Zuru,         NA,         NA, Zamfara,      NG037, Nigeria,         NG, 17134,   18003,      NA, Zamfara West, ... 
osun_sf
class       : SpatialPolygonsDataFrame 
features    : 30 
extent      : 176503.2, 291043.8, 331434.7, 454520.1  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 
variables   : 16
names       :    Shape_Leng,       Shape_Area,  ADM2_EN, ADM2_PCODE, ADM2_REF, ADM2ALT1EN, ADM2ALT2EN, ADM1_EN, ADM1_PCODE, ADM0_EN, ADM0_PCODE,  date, validOn, validTo,        SD_EN, ... 
min values  : 0.26445678806, 0.00248649736648, Aiyedade,   NG030001, Aiyedade,         NA,         NA,    Osun,      NG030, Nigeria,         NG, 17134,   18003,      NA, Osun Central, ... 
max values  :  1.8470166597,  0.0737271661922,   Osogbo,   NG030030,   Osogbo,         NA,         NA,    Osun,      NG030, Nigeria,         NG, 17134,   18003,      NA,    Osun West, ... 

Converting spatial class into generic sp format

wp_functional_sp <- as(wp_functional_sf, "SpatialPoints")
wp_nonfunctional_sp <- as(wp_nonfunctional_sf, "SpatialPoints")
NGA_sp <- as(NGA_sf, "SpatialPolygons")
osun_sp <- as(osun_sf, "SpatialPolygons")
wp_functional_sp
class       : SpatialPoints 
features    : 2630 
extent      : 177285.9, 290751, 343128.1, 450859.7  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 
wp_nonfunctional_sp
class       : SpatialPoints 
features    : 2179 
extent      : 180539, 290616, 340054.1, 450780.1  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 
NGA_sp
class       : SpatialPolygons 
features    : 774 
extent      : 26662.71, 1344157, 30523.38, 1096029  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 
osun_sp
class       : SpatialPolygons 
features    : 30 
extent      : 176503.2, 291043.8, 331434.7, 454520.1  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +a=6378249.145 +rf=293.465 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs 

Converting generic sp format into spatstat’s ppp format

wp_functional_ppp <- as(wp_functional_sp, "ppp")
wp_functional_ppp
Planar point pattern: 2630 points
window: rectangle = [177285.9, 290750.96] x [343128.1, 450859.7] units
wp_nonfunctional_ppp <- as(wp_nonfunctional_sp, "ppp")
wp_nonfunctional_ppp
Planar point pattern: 2179 points
window: rectangle = [180538.96, 290616] x [340054.1, 450780.1] units

Plotting ppp points

plot(wp_functional_ppp)

plot(wp_nonfunctional_ppp)

Summary statistics

summary(wp_functional_ppp)
Planar point pattern:  2630 points
Average intensity 2.151545e-07 points per square unit

Coordinates are given to 2 decimal places
i.e. rounded to the nearest multiple of 0.01 units

Window: rectangle = [177285.9, 290750.96] x [343128.1, 450859.7] units
                    (113500 x 107700 units)
Window area = 12223800000 square units
summary(wp_nonfunctional_ppp)
Planar point pattern:  2179 points
Average intensity 1.787766e-07 points per square unit

Coordinates are given to 2 decimal places
i.e. rounded to the nearest multiple of 0.01 units

Window: rectangle = [180538.96, 290616] x [340054.1, 450780.1] units
                    (110100 x 110700 units)
Window area = 12188400000 square units

Checking for duplicates

any(duplicated(wp_functional_ppp))
[1] FALSE
any(duplicated(wp_nonfunctional_ppp))
[1] FALSE

Creating owin object

NGA_owin <- as(NGA_sp, "owin")
osun_owin <- as(osun_sp, "owin")
plot(NGA_owin)

plot(osun_owin)

Checking on owin summary statistics

summary(NGA_owin)
Window: polygonal boundary
794 separate polygons (3 holes)
                   vertices        area relative.area
polygon 1                70    18683300      2.05e-05
polygon 2                78    43293900      4.75e-05
polygon 3               503  3940900000      4.32e-03
polygon 4               214   832227000      9.13e-04
polygon 5               150   178106000      1.95e-04
polygon 6               192   463153000      5.08e-04
polygon 7               162   774689000      8.50e-04
polygon 8               101    56726500      6.22e-05
polygon 9               152   267817000      2.94e-04
polygon 10              218   176198000      1.93e-04
polygon 11              123   716544000      7.86e-04
polygon 12               83  1722530000      1.89e-03
polygon 13              133   713922000      7.83e-04
polygon 14              176  1186460000      1.30e-03
polygon 15              192   861280000      9.45e-04
polygon 16               80   362066000      3.97e-04
polygon 17               80   333130000      3.65e-04
polygon 18               97   239038000      2.62e-04
polygon 19              104   376914000      4.13e-04
polygon 20              145  1921460000      2.11e-03
polygon 21               74  1047270000      1.15e-03
polygon 22               51    11565800      1.27e-05
polygon 23              140   173516000      1.90e-04
polygon 24               79  1477800000      1.62e-03
polygon 25              151   113895000      1.25e-04
polygon 26               92   318329000      3.49e-04
polygon 27               92   440715000      4.83e-04
polygon 28              204   766084000      8.40e-04
polygon 29               81   304399000      3.34e-04
polygon 30               92   435478000      4.78e-04
polygon 31              109  1381750000      1.52e-03
polygon 32               64    12853400      1.41e-05
polygon 33              247   714085000      7.83e-04
polygon 34              324  5026000000      5.51e-03
polygon 35              100   600214000      6.58e-04
polygon 36              206  2456020000      2.69e-03
polygon 37              352  1343180000      1.47e-03
polygon 38              118   344533000      3.78e-04
polygon 39              127   570176000      6.25e-04
polygon 40               95   222379000      2.44e-04
polygon 41              101   490727000      5.38e-04
polygon 42              666   793051000      8.70e-04
polygon 43              139  1247500000      1.37e-03
polygon 44              152   677546000      7.43e-04
polygon 45               95   308931000      3.39e-04
polygon 46              145   935319000      1.03e-03
polygon 47              217   443956000      4.87e-04
polygon 48               54   336385000      3.69e-04
polygon 49              129   185003000      2.03e-04
polygon 50              293  6019260000      6.60e-03
polygon 51              121   139832000      1.53e-04
polygon 52               85   258902000      2.84e-04
polygon 53              124   953995000      1.05e-03
polygon 54               78   100773000      1.11e-04
polygon 55               98   251158000      2.76e-04
polygon 56               54   369460000      4.05e-04
polygon 57               91   404764000      4.44e-04
polygon 58              105   871119000      9.56e-04
polygon 59              137  2552190000      2.80e-03
polygon 60              120  1281100000      1.41e-03
polygon 61               71   926930000      1.02e-03
polygon 62              105    20217600      2.22e-05
polygon 63              183  2262010000      2.48e-03
polygon 64              162  4043000000      4.44e-03
polygon 65               86  1101870000      1.21e-03
polygon 66              173   521166000      5.72e-04
polygon 67              109  1341810000      1.47e-03
polygon 68               71   115057000      1.26e-04
polygon 69              484  2513010000      2.76e-03
polygon 70               97   465688000      5.11e-04
polygon 71              124   373051000      4.09e-04
polygon 72              187  1820870000      2.00e-03
polygon 73              163  2907440000      3.19e-03
polygon 74              122  1144380000      1.26e-03
polygon 75              211   424132000      4.65e-04
polygon 76              263  2640270000      2.90e-03
polygon 77               79   441514000      4.84e-04
polygon 78               65   345446000      3.79e-04
polygon 79               60   173446000      1.90e-04
polygon 80              110   590436000      6.48e-04
polygon 81              258  1001520000      1.10e-03
polygon 82              169   456525000      5.01e-04
polygon 83              151   515216000      5.65e-04
polygon 84              114   319372000      3.50e-04
polygon 85              188  5113050000      5.61e-03
polygon 86              108   422520000      4.63e-04
polygon 87               25     1656000      1.82e-06
polygon 88               40     2539480      2.79e-06
polygon 89              198   753693000      8.27e-04
polygon 90              105  1503970000      1.65e-03
polygon 91              194  1608070000      1.76e-03
polygon 92              446  9146630000      1.00e-02
polygon 93              418  5061900000      5.55e-03
polygon 94              179   996338000      1.09e-03
polygon 95              242  9749490000      1.07e-02
polygon 96              125  1935360000      2.12e-03
polygon 97              237  1646800000      1.81e-03
polygon 98              148   523796000      5.75e-04
polygon 99              196  1178480000      1.29e-03
polygon 100             167  3654300000      4.01e-03
polygon 101             179   789195000      8.66e-04
polygon 102             201   949273000      1.04e-03
polygon 103             113   724290000      7.95e-04
polygon 104             115   314657000      3.45e-04
polygon 105             173   618647000      6.79e-04
polygon 106             241  1292100000      1.42e-03
polygon 107             137   687464000      7.54e-04
polygon 108              29    52177100      5.72e-05
polygon 109              76   762749000      8.37e-04
polygon 110             156   497186000      5.45e-04
polygon 111              84   831075000      9.12e-04
polygon 112             270  1593160000      1.75e-03
polygon 113             326  1403290000      1.54e-03
polygon 114             545  6532700000      7.17e-03
polygon 115              76  1077240000      1.18e-03
polygon 116             140  1240290000      1.36e-03
polygon 117             442  3293310000      3.61e-03
polygon 118             102   639535000      7.02e-04
polygon 119              99   890376000      9.77e-04
polygon 120             288  2884440000      3.16e-03
polygon 121             189  1720740000      1.89e-03
polygon 122              60   149473000      1.64e-04
polygon 123              41    22700000      2.49e-05
polygon 124               8     2288030      2.51e-06
polygon 125              30    38962000      4.27e-05
polygon 126              49    64971100      7.13e-05
polygon 127             126   551553000      6.05e-04
polygon 128             289 11313500000      1.24e-02
polygon 129              84   144820000      1.59e-04
polygon 130             107  1584140000      1.74e-03
polygon 131 (hole)       46   -63221900     -6.94e-05
polygon 132             242   944565000      1.04e-03
polygon 133             172   568738000      6.24e-04
polygon 134             192  3302700000      3.62e-03
polygon 135             168  2032610000      2.23e-03
polygon 136             136   441312000      4.84e-04
polygon 137             102  1109840000      1.22e-03
polygon 138             353  3824360000      4.20e-03
polygon 139             119  1172270000      1.29e-03
polygon 140             348  1937620000      2.13e-03
polygon 141              33  1045770000      1.15e-03
polygon 142             105   137471000      1.51e-04
polygon 143             195   180017000      1.97e-04
polygon 144              30     8508280      9.33e-06
polygon 145              46    63221900      6.94e-05
polygon 146             171   488609000      5.36e-04
polygon 147             135  1527120000      1.68e-03
polygon 148             346  4482200000      4.92e-03
polygon 149              82    13403000      1.47e-05
polygon 150             178  2351070000      2.58e-03
polygon 151             136  1099370000      1.21e-03
polygon 152             241   789614000      8.66e-04
polygon 153             464  5852250000      6.42e-03
polygon 154             167   807413000      8.86e-04
polygon 155             121  1954440000      2.14e-03
polygon 156             125   479132000      5.26e-04
polygon 157             118  1136380000      1.25e-03
polygon 158             144   482469000      5.29e-04
polygon 159             285  3055000000      3.35e-03
polygon 160              93   688296000      7.55e-04
polygon 161             101   191455000      2.10e-04
polygon 162             113   384285000      4.22e-04
polygon 163             126   437156000      4.80e-04
polygon 164             198   986846000      1.08e-03
polygon 165             195  2407170000      2.64e-03
polygon 166             143  1573000000      1.73e-03
polygon 167             267  1907060000      2.09e-03
polygon 168             213  1488560000      1.63e-03
polygon 169             118  2486810000      2.73e-03
polygon 170             291  3042540000      3.34e-03
polygon 171             181  3696750000      4.06e-03
polygon 172              31    31907200      3.50e-05
polygon 173              45    21471500      2.36e-05
polygon 174             316  1028900000      1.13e-03
polygon 175             122   325297000      3.57e-04
polygon 176             157   647249000      7.10e-04
polygon 177             117   122897000      1.35e-04
polygon 178             165   505877000      5.55e-04
polygon 179             121   913129000      1.00e-03
polygon 180              50   102243000      1.12e-04
polygon 181              72   216002000      2.37e-04
polygon 182             158  2541800000      2.79e-03
polygon 183              59   230988000      2.53e-04
polygon 184             220  1873530000      2.06e-03
polygon 185             133   735204000      8.07e-04
polygon 186             106   259870000      2.85e-04
polygon 187             112   269897000      2.96e-04
polygon 188              66    76272100      8.37e-05
polygon 189             167   174284000      1.91e-04
polygon 190             125   365142000      4.01e-04
polygon 191             259  1818930000      2.00e-03
polygon 192             176   166138000      1.82e-04
polygon 193              76   476516000      5.23e-04
polygon 194              69   315063000      3.46e-04
polygon 195              89   337071000      3.70e-04
polygon 196             102   375363000      4.12e-04
polygon 197              84   121957000      1.34e-04
polygon 198              52   136604000      1.50e-04
polygon 199             162   833337000      9.14e-04
polygon 200              65   250497000      2.75e-04
polygon 201              87   391909000      4.30e-04
polygon 202              98    93298400      1.02e-04
polygon 203              56    75277300      8.26e-05
polygon 204             386  1187590000      1.30e-03
polygon 205             140   264235000      2.90e-04
polygon 206             136   342326000      3.76e-04
polygon 207             170  1306460000      1.43e-03
polygon 208             149   515910000      5.66e-04
polygon 209             152  1080780000      1.19e-03
polygon 210              96   169335000      1.86e-04
polygon 211             168   289107000      3.17e-04
polygon 212             157   815912000      8.95e-04
polygon 213              27    61230000      6.72e-05
polygon 214              56   319113000      3.50e-04
polygon 215             121   538078000      5.90e-04
polygon 216              74   192362000      2.11e-04
polygon 217             180   220312000      2.42e-04
polygon 218             175   172800000      1.90e-04
polygon 219             159   663059000      7.27e-04
polygon 220             202  1132490000      1.24e-03
polygon 221             179   939540000      1.03e-03
polygon 222             187   812156000      8.91e-04
polygon 223              99   630524000      6.92e-04
polygon 224              75   638217000      7.00e-04
polygon 225             125   120414000      1.32e-04
polygon 226             130   413300000      4.53e-04
polygon 227             146   263994000      2.90e-04
polygon 228              78    38534100      4.23e-05
polygon 229             226  2252420000      2.47e-03
polygon 230             267  1682640000      1.85e-03
polygon 231             417  2155190000      2.36e-03
polygon 232             298  4752100000      5.21e-03
polygon 233             177  1595500000      1.75e-03
polygon 234             391  5486120000      6.02e-03
polygon 235             144   422312000      4.63e-04
polygon 236             239   610672000      6.70e-04
polygon 237             135  1517930000      1.67e-03
polygon 238             143   582712000      6.39e-04
polygon 239             174  2938910000      3.22e-03
polygon 240             322  4890620000      5.36e-03
polygon 241             141  2101520000      2.31e-03
polygon 242             372  1408790000      1.55e-03
polygon 243             141   441736000      4.85e-04
polygon 244              91   227717000      2.50e-04
polygon 245             366  8393400000      9.21e-03
polygon 246             308  5548050000      6.09e-03
polygon 247             184   567600000      6.23e-04
polygon 248             194  1752700000      1.92e-03
polygon 249             129  1898840000      2.08e-03
polygon 250             224  3853470000      4.23e-03
polygon 251             110   338774000      3.72e-04
polygon 252             137   750378000      8.23e-04
polygon 253             113  1198410000      1.31e-03
polygon 254             228  1985330000      2.18e-03
polygon 255              42   132735000      1.46e-04
polygon 256              41    45266800      4.97e-05
polygon 257             214  2172830000      2.38e-03
polygon 258             181  1711740000      1.88e-03
polygon 259             265  2635650000      2.89e-03
polygon 260             111  3295570000      3.62e-03
polygon 261             367  3479590000      3.82e-03
polygon 262             381  2135100000      2.34e-03
polygon 263             130  2861350000      3.14e-03
polygon 264              87   227361000      2.49e-04
polygon 265             138  2612750000      2.87e-03
polygon 266             194  1131040000      1.24e-03
polygon 267             256  1064810000      1.17e-03
polygon 268              70   645109000      7.08e-04
polygon 269             165  2065340000      2.27e-03
polygon 270             122   690397000      7.57e-04
polygon 271             329  2530740000      2.78e-03
polygon 272             164  1008740000      1.11e-03
polygon 273             116  1001210000      1.10e-03
polygon 274             101    23625200      2.59e-05
polygon 275             106  1055810000      1.16e-03
polygon 276             530  1858910000      2.04e-03
polygon 277             133   436131000      4.78e-04
polygon 278             108  1993390000      2.19e-03
polygon 279              95  1430860000      1.57e-03
polygon 280             198   451326000      4.95e-04
polygon 281             325  2953570000      3.24e-03
polygon 282              45    32240200      3.54e-05
polygon 283             358  2020480000      2.22e-03
polygon 284             247  2674760000      2.93e-03
polygon 285             113    39173300      4.30e-05
polygon 286             109    13307200      1.46e-05
polygon 287              80    11510600      1.26e-05
polygon 288              97    14118400      1.55e-05
polygon 289             116    48456300      5.32e-05
polygon 290             107  1335400000      1.46e-03
polygon 291             135   689017000      7.56e-04
polygon 292             129   757902000      8.31e-04
polygon 293             128   970597000      1.06e-03
polygon 294              46   360322000      3.95e-04
polygon 295              61    94448100      1.04e-04
polygon 296             236   243275000      2.67e-04
polygon 297             125   175050000      1.92e-04
polygon 298             328  2669260000      2.93e-03
polygon 299             260   336038000      3.69e-04
polygon 300              41   134212000      1.47e-04
polygon 301             221  1921470000      2.11e-03
polygon 302             186   182197000      2.00e-04
polygon 303              91   104163000      1.14e-04
polygon 304              88   132443000      1.45e-04
polygon 305              90   131298000      1.44e-04
polygon 306             203   871429000      9.56e-04
polygon 307              52   231585000      2.54e-04
polygon 308              92    33306600      3.65e-05
polygon 309              83   111191000      1.22e-04
polygon 310             126   192557000      2.11e-04
polygon 311             219   904397000      9.92e-04
polygon 312             174   741131000      8.13e-04
polygon 313              81   138742000      1.52e-04
polygon 314             108   318363000      3.49e-04
polygon 315             246  3449020000      3.78e-03
polygon 316              65   119452000      1.31e-04
polygon 317             131   542710000      5.95e-04
polygon 318             267  3391200000      3.72e-03
polygon 319             231  2114230000      2.32e-03
polygon 320              86   333938000      3.66e-04
polygon 321              61   303909000      3.33e-04
polygon 322              83   170077000      1.87e-04
polygon 323             118   349864000      3.84e-04
polygon 324             125   240906000      2.64e-04
polygon 325             138   108417000      1.19e-04
polygon 326             374  2179670000      2.39e-03
polygon 327             103   959168000      1.05e-03
polygon 328              95   213380000      2.34e-04
polygon 329              87   143429000      1.57e-04
polygon 330              63   378013000      4.15e-04
polygon 331             177  1284310000      1.41e-03
polygon 332             117   114643000      1.26e-04
polygon 333             103   468158000      5.14e-04
polygon 334             118   436075000      4.78e-04
polygon 335             181   940328000      1.03e-03
polygon 336             144   181157000      1.99e-04
polygon 337              95    46930500      5.15e-05
polygon 338              54   146666000      1.61e-04
polygon 339              75   237924000      2.61e-04
polygon 340             159  1072560000      1.18e-03
polygon 341             329  1966820000      2.16e-03
polygon 342             211   262513000      2.88e-04
polygon 343             162   401626000      4.41e-04
polygon 344             214   335586000      3.68e-04
polygon 345             123   115857000      1.27e-04
polygon 346             213   858760000      9.42e-04
polygon 347             104   658339000      7.22e-04
polygon 348             177   655251000      7.19e-04
polygon 349             158   278311000      3.05e-04
polygon 350              90   280205000      3.07e-04
polygon 351             306   967491000      1.06e-03
polygon 352             206   597317000      6.55e-04
polygon 353              34    94929400      1.04e-04
polygon 354              69    69814600      7.66e-05
polygon 355              69    42727500      4.69e-05
polygon 356             126  1083920000      1.19e-03
polygon 357              71   441057000      4.84e-04
polygon 358              70    11777400      1.29e-05
polygon 359             109   243915000      2.68e-04
polygon 360              30     2518970      2.76e-06
polygon 361             113   149668000      1.64e-04
polygon 362             445  1824360000      2.00e-03
polygon 363             238   789152000      8.66e-04
polygon 364             231   382777000      4.20e-04
polygon 365             223   577820000      6.34e-04
polygon 366             164   894287000      9.81e-04
polygon 367              37   984403000      1.08e-03
polygon 368             153   703398000      7.72e-04
polygon 369              49    30458800      3.34e-05
polygon 370              77   327820000      3.60e-04
polygon 371              62   263505000      2.89e-04
polygon 372             155  2166520000      2.38e-03
polygon 373             110   414831000      4.55e-04
polygon 374             147  1825460000      2.00e-03
polygon 375             133   694895000      7.62e-04
polygon 376             143   845436000      9.27e-04
polygon 377             136   283520000      3.11e-04
polygon 378             167   276994000      3.04e-04
polygon 379             164   153494000      1.68e-04
polygon 380              85   633163000      6.95e-04
polygon 381             134   382494000      4.20e-04
polygon 382              93   438930000      4.81e-04
polygon 383             116   459058000      5.04e-04
polygon 384              20    23530600      2.58e-05
polygon 385             116   714012000      7.83e-04
polygon 386 (hole)       20   -23530600     -2.58e-05
polygon 387              78    52602500      5.77e-05
polygon 388             259  1653590000      1.81e-03
polygon 389              82  1551780000      1.70e-03
polygon 390             146   180183000      1.98e-04
polygon 391              69   266635000      2.92e-04
polygon 392             261  2408070000      2.64e-03
polygon 393              87   274127000      3.01e-04
polygon 394             163  1083380000      1.19e-03
polygon 395             114   454348000      4.98e-04
polygon 396             237  2613310000      2.87e-03
polygon 397             209  1245760000      1.37e-03
polygon 398             270  3533910000      3.88e-03
polygon 399              91   190774000      2.09e-04
polygon 400              83   382500000      4.20e-04
polygon 401             124   970150000      1.06e-03
polygon 402             166  1415580000      1.55e-03
polygon 403             370   848310000      9.31e-04
polygon 404             263  1066830000      1.17e-03
polygon 405             163  1027350000      1.13e-03
polygon 406              85   262081000      2.87e-04
polygon 407             146   565903000      6.21e-04
polygon 408             198  2696010000      2.96e-03
polygon 409             128   372050000      4.08e-04
polygon 410             301  4589350000      5.03e-03
polygon 411              70    59358300      6.51e-05
polygon 412              87    52691500      5.78e-05
polygon 413             240  1371380000      1.50e-03
polygon 414             167  1013280000      1.11e-03
polygon 415             261  2585420000      2.84e-03
polygon 416             215  1910440000      2.10e-03
polygon 417             126  6971200000      7.65e-03
polygon 418             110   714045000      7.83e-04
polygon 419              64   608806000      6.68e-04
polygon 420             292  3007610000      3.30e-03
polygon 421             344  1896730000      2.08e-03
polygon 422              72   610435000      6.70e-04
polygon 423             101  1155510000      1.27e-03
polygon 424             253  2746620000      3.01e-03
polygon 425             254  1394860000      1.53e-03
polygon 426             169   940266000      1.03e-03
polygon 427             173   754239000      8.27e-04
polygon 428              65    17171600      1.88e-05
polygon 429             265  1333410000      1.46e-03
polygon 430             100   449680000      4.93e-04
polygon 431             412  6620190000      7.26e-03
polygon 432             185  2884260000      3.16e-03
polygon 433             139  1327500000      1.46e-03
polygon 434             240  1652310000      1.81e-03
polygon 435              87   147970000      1.62e-04
polygon 436             162  2690800000      2.95e-03
polygon 437             203   817292000      8.97e-04
polygon 438             103   518700000      5.69e-04
polygon 439             105   866522000      9.51e-04
polygon 440             159  2511300000      2.75e-03
polygon 441             189   381951000      4.19e-04
polygon 442              88  1164900000      1.28e-03
polygon 443             154  2635140000      2.89e-03
polygon 444              32   112748000      1.24e-04
polygon 445             143   558807000      6.13e-04
polygon 446              78   436326000      4.79e-04
polygon 447             105  2270460000      2.49e-03
polygon 448             210   830157000      9.11e-04
polygon 449             190   904042000      9.92e-04
polygon 450             198  1031320000      1.13e-03
polygon 451             103  1494520000      1.64e-03
polygon 452             133  1349380000      1.48e-03
polygon 453             158  2554290000      2.80e-03
polygon 454              54   350876000      3.85e-04
polygon 455             758  5993130000      6.57e-03
polygon 456             160  1683790000      1.85e-03
polygon 457              98  1776210000      1.95e-03
polygon 458              85    82167800      9.01e-05
polygon 459             188  2360860000      2.59e-03
polygon 460             105   334024000      3.66e-04
polygon 461             109  1532430000      1.68e-03
polygon 462             320  4951410000      5.43e-03
polygon 463             110   191551000      2.10e-04
polygon 464             152   520576000      5.71e-04
polygon 465              86   195919000      2.15e-04
polygon 466             141   576472000      6.32e-04
polygon 467             254  4353820000      4.78e-03
polygon 468             123   455568000      5.00e-04
polygon 469             135  1252810000      1.37e-03
polygon 470             148  1721300000      1.89e-03
polygon 471             142  2351420000      2.58e-03
polygon 472             138   597318000      6.55e-04
polygon 473             148   749496000      8.22e-04
polygon 474             452  2656280000      2.91e-03
polygon 475             136   274289000      3.01e-04
polygon 476              23     8661600      9.50e-06
polygon 477              66    23678500      2.60e-05
polygon 478             141  1108700000      1.22e-03
polygon 479             194   782444000      8.58e-04
polygon 480             197  1198910000      1.32e-03
polygon 481             201  3031940000      3.33e-03
polygon 482             187  1660500000      1.82e-03
polygon 483             161  2594590000      2.85e-03
polygon 484             276  2300020000      2.52e-03
polygon 485              85  1625090000      1.78e-03
polygon 486             216  3203910000      3.51e-03
polygon 487             256  1280140000      1.40e-03
polygon 488             179   836488000      9.18e-04
polygon 489              93   257794000      2.83e-04
polygon 490             421  2873420000      3.15e-03
polygon 491             249  4069250000      4.46e-03
polygon 492             335  4750130000      5.21e-03
polygon 493             133   619159000      6.79e-04
polygon 494             145   140676000      1.54e-04
polygon 495             147   964409000      1.06e-03
polygon 496             163  1364640000      1.50e-03
polygon 497             150  1340230000      1.47e-03
polygon 498             197   401654000      4.41e-04
polygon 499              60   811777000      8.90e-04
polygon 500             184   806731000      8.85e-04
polygon 501             194   805730000      8.84e-04
polygon 502             223  1609110000      1.77e-03
polygon 503             174   670373000      7.35e-04
polygon 504             173  2756620000      3.02e-03
polygon 505             288  5780750000      6.34e-03
polygon 506             109   572027000      6.27e-04
polygon 507             243  2981570000      3.27e-03
polygon 508             366  7222130000      7.92e-03
polygon 509             282  9325580000      1.02e-02
polygon 510             164   937953000      1.03e-03
polygon 511             105   539604000      5.92e-04
polygon 512             224  2115550000      2.32e-03
polygon 513             176   200015000      2.19e-04
polygon 514             261    71848700      7.88e-05
polygon 515             517   149386000      1.64e-04
polygon 516              75    13573700      1.49e-05
polygon 517              42     5665830      6.22e-06
polygon 518              24      876126      9.61e-07
polygon 519             127   816059000      8.95e-04
polygon 520             174   569034000      6.24e-04
polygon 521             143   785121000      8.61e-04
polygon 522             128   431249000      4.73e-04
polygon 523             121   998310000      1.10e-03
polygon 524             237   350136000      3.84e-04
polygon 525              64   197751000      2.17e-04
polygon 526             419  2717250000      2.98e-03
polygon 527             534  5314130000      5.83e-03
polygon 528             276  1905800000      2.09e-03
polygon 529              96   834508000      9.15e-04
polygon 530             167  3133390000      3.44e-03
polygon 531             114   758369000      8.32e-04
polygon 532             131   505935000      5.55e-04
polygon 533             153   787574000      8.64e-04
polygon 534              71    16681300      1.83e-05
polygon 535             202  2087080000      2.29e-03
polygon 536             212  1580580000      1.73e-03
polygon 537             239  1045310000      1.15e-03
polygon 538              78    41663400      4.57e-05
polygon 539             131  4852660000      5.32e-03
polygon 540             179  1257790000      1.38e-03
polygon 541             208  1610340000      1.77e-03
polygon 542             153   822692000      9.02e-04
polygon 543             165  1404280000      1.54e-03
polygon 544             194  1456450000      1.60e-03
polygon 545             255  2326850000      2.55e-03
polygon 546             179  2615440000      2.87e-03
polygon 547             257   542201000      5.95e-04
polygon 548             208   817102000      8.96e-04
polygon 549             287  4646880000      5.10e-03
polygon 550             104    78468800      8.61e-05
polygon 551              80    97463700      1.07e-04
polygon 552              89   759948000      8.34e-04
polygon 553              62   254847000      2.80e-04
polygon 554              92    35047200      3.84e-05
polygon 555              52    68604100      7.53e-05
polygon 556             103   154259000      1.69e-04
polygon 557             141   130673000      1.43e-04
polygon 558             135   130604000      1.43e-04
polygon 559             171   200856000      2.20e-04
polygon 560             162   556234000      6.10e-04
polygon 561             143   836873000      9.18e-04
polygon 562             121    69650300      7.64e-05
polygon 563             233  1484990000      1.63e-03
polygon 564             195   938380000      1.03e-03
polygon 565              72   496736000      5.45e-04
polygon 566             184  1015930000      1.11e-03
polygon 567             154   403847000      4.43e-04
polygon 568             111   257687000      2.83e-04
polygon 569             105   509979000      5.59e-04
polygon 570             167   234789000      2.58e-04
polygon 571             112    86415300      9.48e-05
polygon 572             275  1144120000      1.26e-03
polygon 573             106   467565000      5.13e-04
polygon 574             318  1445720000      1.59e-03
polygon 575             306  1885470000      2.07e-03
polygon 576              98   292058000      3.20e-04
polygon 577              92   550979000      6.04e-04
polygon 578             360  1354000000      1.49e-03
polygon 579              58    94679600      1.04e-04
polygon 580             251  1715700000      1.88e-03
polygon 581             162   958862000      1.05e-03
polygon 582              81   602543000      6.61e-04
polygon 583             115   517979000      5.68e-04
polygon 584              93   678771000      7.45e-04
polygon 585              44    91573300      1.00e-04
polygon 586              56    29135100      3.20e-05
polygon 587             112   376959000      4.14e-04
polygon 588             235   912341000      1.00e-03
polygon 589              60    79402200      8.71e-05
polygon 590              96   130008000      1.43e-04
polygon 591             310   973735000      1.07e-03
polygon 592             167   422444000      4.63e-04
polygon 593              95   439958000      4.83e-04
polygon 594             240   896223000      9.83e-04
polygon 595              94   333241000      3.66e-04
polygon 596             105   602218000      6.61e-04
polygon 597              61   598470000      6.57e-04
polygon 598              90   411357000      4.51e-04
polygon 599             135   162995000      1.79e-04
polygon 600             192  1189640000      1.31e-03
polygon 601             114   436816000      4.79e-04
polygon 602             108   661738000      7.26e-04
polygon 603             109   298589000      3.28e-04
polygon 604             231   306860000      3.37e-04
polygon 605             158   858911000      9.42e-04
polygon 606             163   300918000      3.30e-04
polygon 607             123   481140000      5.28e-04
polygon 608             109   924106000      1.01e-03
polygon 609             144   286440000      3.14e-04
polygon 610              64   327765000      3.60e-04
polygon 611             132   990260000      1.09e-03
polygon 612             133   108945000      1.20e-04
polygon 613              57  1063330000      1.17e-03
polygon 614             112   671950000      7.37e-04
polygon 615              91  1591220000      1.75e-03
polygon 616              61   158754000      1.74e-04
polygon 617             123   334217000      3.67e-04
polygon 618             176   449937000      4.94e-04
polygon 619             181   962703000      1.06e-03
polygon 620             168   439068000      4.82e-04
polygon 621              53    37632900      4.13e-05
polygon 622              44     9923540      1.09e-05
polygon 623             168   163855000      1.80e-04
polygon 624              84   114932000      1.26e-04
polygon 625             129   250954000      2.75e-04
polygon 626              48   917300000      1.01e-03
polygon 627             211  2414130000      2.65e-03
polygon 628              92  2044380000      2.24e-03
polygon 629             122   462169000      5.07e-04
polygon 630             145   122732000      1.35e-04
polygon 631              94   109715000      1.20e-04
polygon 632              75    52113900      5.72e-05
polygon 633              78    75069700      8.23e-05
polygon 634             157   131405000      1.44e-04
polygon 635             130    96737000      1.06e-04
polygon 636             212   544292000      5.97e-04
polygon 637             148   321005000      3.52e-04
polygon 638             117   188241000      2.06e-04
polygon 639             326  1427760000      1.57e-03
polygon 640              93   510484000      5.60e-04
polygon 641              84   266566000      2.92e-04
polygon 642              59    44465000      4.88e-05
polygon 643             108   174739000      1.92e-04
polygon 644              95    61239800      6.72e-05
polygon 645             135  1362500000      1.49e-03
polygon 646             441  2343080000      2.57e-03
polygon 647             443  2779220000      3.05e-03
polygon 648             201  1229570000      1.35e-03
polygon 649             148   740903000      8.13e-04
polygon 650              96    56304900      6.18e-05
polygon 651             204   193966000      2.13e-04
polygon 652             227   286364000      3.14e-04
polygon 653             195  1140690000      1.25e-03
polygon 654              69   507076000      5.56e-04
polygon 655              77   135112000      1.48e-04
polygon 656             102   247269000      2.71e-04
polygon 657             169   359335000      3.94e-04
polygon 658             171   599357000      6.57e-04
polygon 659             107   605492000      6.64e-04
polygon 660 (hole)       58   -94679600     -1.04e-04
polygon 661             278  2089500000      2.29e-03
polygon 662             215  1434320000      1.57e-03
polygon 663             109   226339000      2.48e-04
polygon 664             115  2913520000      3.20e-03
polygon 665              92   108215000      1.19e-04
polygon 666             120   576911000      6.33e-04
polygon 667             312  2539010000      2.79e-03
polygon 668             152  2397920000      2.63e-03
polygon 669             281  3685550000      4.04e-03
polygon 670             111   517132000      5.67e-04
polygon 671              71   210320000      2.31e-04
polygon 672             407  3128130000      3.43e-03
polygon 673             114   484795000      5.32e-04
polygon 674             114   266695000      2.93e-04
polygon 675             326  1020560000      1.12e-03
polygon 676             187   828074000      9.08e-04
polygon 677             118   798209000      8.76e-04
polygon 678             233   304041000      3.34e-04
polygon 679              74   262520000      2.88e-04
polygon 680              81  2379770000      2.61e-03
polygon 681             197   695308000      7.63e-04
polygon 682             178  1389470000      1.52e-03
polygon 683             218   949719000      1.04e-03
polygon 684             137  1455320000      1.60e-03
polygon 685              69  1376800000      1.51e-03
polygon 686              78  1894770000      2.08e-03
polygon 687             124   326896000      3.59e-04
polygon 688             238  1493300000      1.64e-03
polygon 689              95   429927000      4.72e-04
polygon 690             312  4603740000      5.05e-03
polygon 691             108   603505000      6.62e-04
polygon 692             124  1313750000      1.44e-03
polygon 693             207  2722740000      2.99e-03
polygon 694             205  1228890000      1.35e-03
polygon 695              89   507887000      5.57e-04
polygon 696             105  1209820000      1.33e-03
polygon 697             298  2439390000      2.68e-03
polygon 698             119   783435000      8.59e-04
polygon 699             223  1370830000      1.50e-03
polygon 700             405  5232570000      5.74e-03
polygon 701             112   869266000      9.54e-04
polygon 702              40    11266300      1.24e-05
polygon 703              85   801093000      8.79e-04
polygon 704             182  2247020000      2.46e-03
polygon 705              64    40124900      4.40e-05
polygon 706              74    28609800      3.14e-05
polygon 707             159  4057210000      4.45e-03
polygon 708             268  2711450000      2.97e-03
polygon 709             199  1232180000      1.35e-03
polygon 710              49   129161000      1.42e-04
polygon 711             181  1249020000      1.37e-03
polygon 712             153  1576310000      1.73e-03
polygon 713             102    19692500      2.16e-05
polygon 714             142  1041390000      1.14e-03
polygon 715              51   241483000      2.65e-04
polygon 716             329  2454620000      2.69e-03
polygon 717              52   160564000      1.76e-04
polygon 718             199   597976000      6.56e-04
polygon 719             165  2386710000      2.62e-03
polygon 720              96  1467640000      1.61e-03
polygon 721             165  1845440000      2.02e-03
polygon 722             125  2382560000      2.61e-03
polygon 723              56    26680100      2.93e-05
polygon 724              57   477262000      5.24e-04
polygon 725             240  4537780000      4.98e-03
polygon 726             221   655572000      7.19e-04
polygon 727              90   190575000      2.09e-04
polygon 728             366  6875030000      7.54e-03
polygon 729             111  2983120000      3.27e-03
polygon 730             282  5593540000      6.14e-03
polygon 731             178  1810650000      1.99e-03
polygon 732             111   535540000      5.87e-04
polygon 733             194  1226250000      1.35e-03
polygon 734             103  2304250000      2.53e-03
polygon 735              80   256855000      2.82e-04
polygon 736             127   890774000      9.77e-04
polygon 737              88   166099000      1.82e-04
polygon 738             118    58655100      6.43e-05
polygon 739             181   832072000      9.13e-04
polygon 740             245   771172000      8.46e-04
polygon 741              94   125983000      1.38e-04
polygon 742             201  1994300000      2.19e-03
polygon 743             119   218239000      2.39e-04
polygon 744              84  1783340000      1.96e-03
polygon 745             143   282825000      3.10e-04
polygon 746              80   277344000      3.04e-04
polygon 747              91   409149000      4.49e-04
polygon 748             113   368029000      4.04e-04
polygon 749             129   227449000      2.50e-04
polygon 750              77   135239000      1.48e-04
polygon 751             131   222742000      2.44e-04
polygon 752             108   107659000      1.18e-04
polygon 753             189   346538000      3.80e-04
polygon 754             135   115738000      1.27e-04
polygon 755             107  1379370000      1.51e-03
polygon 756              72  1495350000      1.64e-03
polygon 757              91   112635000      1.24e-04
polygon 758             279   183562000      2.01e-04
polygon 759             131   841799000      9.23e-04
polygon 760             129   977404000      1.07e-03
polygon 761             157   665252000      7.30e-04
polygon 762             167  1209890000      1.33e-03
polygon 763             102   363647000      3.99e-04
polygon 764             131   658795000      7.23e-04
polygon 765             235  1840730000      2.02e-03
polygon 766             131   586927000      6.44e-04
polygon 767             173  1699070000      1.86e-03
polygon 768             245  4102640000      4.50e-03
polygon 769             362  4981460000      5.46e-03
polygon 770             148   361846000      3.97e-04
polygon 771             185  3936310000      4.32e-03
polygon 772             105   681794000      7.48e-04
polygon 773             179  1813520000      1.99e-03
polygon 774             100   770814000      8.46e-04
polygon 775             165  1475280000      1.62e-03
polygon 776             144  1287890000      1.41e-03
polygon 777             165   658753000      7.23e-04
polygon 778             371  1782980000      1.96e-03
polygon 779             201  1964990000      2.16e-03
polygon 780             182   337903000      3.71e-04
polygon 781              39   123254000      1.35e-04
polygon 782              95   682891000      7.49e-04
polygon 783              29    63798400      7.00e-05
polygon 784             137   934702000      1.03e-03
polygon 785             196  1275510000      1.40e-03
polygon 786             312  3825490000      4.20e-03
polygon 787             430  3869200000      4.24e-03
polygon 788             251  1904040000      2.09e-03
polygon 789             106   519190000      5.70e-04
polygon 790             170  2331980000      2.56e-03
polygon 791             115   393773000      4.32e-04
polygon 792             110  1030270000      1.13e-03
polygon 793             228  2685640000      2.95e-03
polygon 794             175   699163000      7.67e-04
enclosing rectangle: [26662.7, 1344157] x [30523.4, 1096029.4] units
                     (1317000 x 1066000 units)
Window area = 9.11598e+11 square units
Fraction of frame area: 0.649
summary(osun_owin)
Window: polygonal boundary
30 separate polygons (no holes)
            vertices      area relative.area
polygon 1        204 766084000       0.08870
polygon 2         81 304399000       0.03520
polygon 3         97 465688000       0.05390
polygon 4        124 373051000       0.04320
polygon 5         60 149473000       0.01730
polygon 6         84 144820000       0.01680
polygon 7         50 102243000       0.01180
polygon 8         72 216002000       0.02500
polygon 9        112 269897000       0.03130
polygon 10       125 365142000       0.04230
polygon 11        83 111191000       0.01290
polygon 12       126 192557000       0.02230
polygon 13       219 904397000       0.10500
polygon 14       174 741131000       0.08580
polygon 15        81 138742000       0.01610
polygon 16        65 119452000       0.01380
polygon 17        90 280205000       0.03240
polygon 18        69  69814600       0.00808
polygon 19        69  42727500       0.00495
polygon 20        49  30458800       0.00353
polygon 21        62 263505000       0.03050
polygon 22        93 438930000       0.05080
polygon 23        87 274127000       0.03170
polygon 24       105 509979000       0.05910
polygon 25        98 292058000       0.03380
polygon 26        64 327765000       0.03800
polygon 27       133 108945000       0.01260
polygon 28       122 462169000       0.05350
polygon 29        94 109715000       0.01270
polygon 30        95  61239800       0.00709
enclosing rectangle: [176503.22, 291043.82] x [331434.7, 454520.1] units
                     (114500 x 123100 units)
Window area = 8635910000 square units
Fraction of frame area: 0.613

Combining waterpoints with Osun map

Functional waterpoints

wp_functional_ppp_osun = wp_functional_ppp[osun_owin]
plot(wp_functional_ppp_osun)

Loading packages

pacman::p_load(maptools, sf, raster, spatstat, tmap)

Prepping KDE plot

kde_wp_functional_bw <- density(wp_functional_ppp_osun,
                              sigma=bw.diggle,
                              edge=TRUE,
                              kernel="gaussian")

Plotting KDE for functional waterpoints

plot(kde_wp_functional_bw)

Bandwidth used

bw <- bw.diggle(wp_functional_ppp_osun)
bw
   sigma 
252.1687 

Re-scaling data

wp_functional_ppp_osun.km <- rescale(wp_functional_ppp_osun, 1000, "km")
kde_wp_functional_bw <- density(wp_functional_ppp_osun.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_wp_functional_bw)

Working with different kernel methods: Gaussian, Epanechnikov, Quartic and Discs

par(mfrow=c(2,2))
plot(density(wp_functional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="gaussian"), 
     main="Gaussian")
plot(density(wp_functional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="epanechnikov"), 
     main="Epanechnikov")
plot(density(wp_functional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="quartic"), 
     main="Quartic")
plot(density(wp_functional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="disc"), 
     main="Disc")

Non-functional waterpoints

wp_nonfunctional_ppp_osun = wp_nonfunctional_ppp[osun_owin]
plot(wp_nonfunctional_ppp_osun)

kde_wp_nonfunctional_bw <- density(wp_nonfunctional_ppp_osun,
                              sigma=bw.diggle,
                              edge=TRUE,
                            kernel="gaussian") 
plot(kde_wp_nonfunctional_bw)

Computing sigma

bw <- bw.diggle(wp_nonfunctional_ppp_osun)
bw
   sigma 
308.2061 

Re-scaling data

wp_nonfunctional_ppp_osun.km <- rescale(wp_nonfunctional_ppp_osun, 1000, "km")

Plotting re-scaled data

kde_wp_nonfunctional_bw <- density(wp_nonfunctional_ppp_osun.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_wp_nonfunctional_bw)

Working with different kernel methods: Gaussian, Epanechnikov, Quartic and Discs

par(mfrow=c(2,2))
plot(density(wp_nonfunctional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="gaussian"), 
     main="Gaussian")
plot(density(wp_nonfunctional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="epanechnikov"), 
     main="Epanechnikov")
plot(density(wp_nonfunctional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="quartic"), 
     main="Quartic")
plot(density(wp_nonfunctional_ppp_osun.km, 
             sigma=bw.ppl, 
             edge=TRUE, 
             kernel="disc"), 
     main="Disc")

Kernel density maps on openstreetmap of Osun State, Nigeria

tmap_mode('view')
tm_shape(wp_functional) +
    tm_dots(alpha=0.4, 
            size=0.05)

Converting functional waterpoints gridded output into raster

gridded_kde_wp_functional_bw <- as.SpatialGridDataFrame.im(kde_wp_functional_bw)
spplot(gridded_kde_wp_functional_bw)

kde_wp_functional_bw_raster <- raster(gridded_kde_wp_functional_bw)
kde_wp_functional_bw_raster
class      : RasterLayer 
dimensions : 128, 128, 16384  (nrow, ncol, ncell)
resolution : 0.8948485, 0.9616045  (x, y)
extent     : 176.5032, 291.0438, 331.4347, 454.5201  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : memory
names      : v 
values     : -5.092436e-15, 25.49435  (min, max)
projection(kde_wp_functional_bw_raster) <- CRS("+init=EPSG:26392")
kde_wp_functional_bw_raster
class      : RasterLayer 
dimensions : 128, 128, 16384  (nrow, ncol, ncell)
resolution : 0.8948485, 0.9616045  (x, y)
extent     : 176.5032, 291.0438, 331.4347, 454.5201  (xmin, xmax, ymin, ymax)
crs        : +init=EPSG:26392 
source     : memory
names      : v 
values     : -5.092436e-15, 25.49435  (min, max)

Plotting raster map

tm_shape(kde_wp_functional_bw_raster) + 
tm_basemap("OpenStreetMap") +
  tm_raster("v") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE)

Converting nonfunctional waterpoints gridded output into raster

gridded_kde_wp_nonfunctional_bw <- as.SpatialGridDataFrame.im(kde_wp_nonfunctional_bw)
spplot(gridded_kde_wp_nonfunctional_bw)

kde_wp_nonfunctional_bw_raster <- raster(gridded_kde_wp_nonfunctional_bw)
kde_wp_nonfunctional_bw_raster
class      : RasterLayer 
dimensions : 128, 128, 16384  (nrow, ncol, ncell)
resolution : 0.8948485, 0.9616045  (x, y)
extent     : 176.5032, 291.0438, 331.4347, 454.5201  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : memory
names      : v 
values     : -3.925434e-15, 20.49412  (min, max)

Changing projection

projection(kde_wp_nonfunctional_bw_raster) <- CRS("+init=EPSG:26392")
kde_wp_nonfunctional_bw_raster
class      : RasterLayer 
dimensions : 128, 128, 16384  (nrow, ncol, ncell)
resolution : 0.8948485, 0.9616045  (x, y)
extent     : 176.5032, 291.0438, 331.4347, 454.5201  (xmin, xmax, ymin, ymax)
crs        : +init=EPSG:26392 
source     : memory
names      : v 
values     : -3.925434e-15, 20.49412  (min, max)
tm_shape(kde_wp_nonfunctional_bw_raster) + 
  tm_basemap("OpenStreetMap") +
  tm_raster("v") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE)

Analysis:

From the plots above, we can observe that both the functional and nonfunctional waterpoints seem to scatter unevenly through the whole of Osun state in Nigeria. For the functional waterpoints, they seem to gather around the top of Osun state in Nigeria (north of Osun), leaving the other areas of Osun to have reduced accessibility to clean water points for consumption. For the nonfunctional waterpoints, they seem to be scattered around the whole Osun state unevenly as well, with some concentration of nonfunctional waterpoints at the top (north of Osun) and centre (Osun central).

Advantages of Kernel Density Map over point maps, is that it increases the visibility of the areas with higher densities of, in this case functional/nonfunctional waterpoints. Areas with higher densities of functional/nonfunctional waterpoints can be easily pin-pointed out with the darker colour intensities on the Kernel Density Map instead of having multiple points stacked together on the point maps and having to zoom in to see the actual points.

Nearest Neighbour Analysis: Clark and Evans Test

Functional waterpoints

clarkevans.test(wp_functional_ppp,
                correction="none",
                clipregion="osun_owin",
                alternative=c("clustered"),
                nsim=99)

    Clark-Evans test
    No edge correction
    Monte Carlo test based on 99 simulations of CSR with fixed n

data:  wp_functional_ppp
R = 0.38922, p-value = 0.01
alternative hypothesis: clustered (R < 1)

Nonfunctional waterpoints

clarkevans.test(wp_nonfunctional_ppp,
                correction="none",
                clipregion="osun_owin",
                alternative=c("clustered"),
                nsim=99)

    Clark-Evans test
    No edge correction
    Monte Carlo test based on 99 simulations of CSR with fixed n

data:  wp_nonfunctional_ppp
R = 0.37112, p-value = 0.01
alternative hypothesis: clustered (R < 1)

Second-order Spatial Point Patterns Analysis

Analysing Spatial Point Process Using L-Function

Computing L Function estimation of Functional Waterpoints

L_wp_functional = Lest(wp_functional_ppp, correction = "Ripley")
plot(L_wp_functional, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test of Functional Waterpoints

Hypothesis:

Ho = The distribution of functional waterpoints in Osun, Nigeria are randomly distributed.

H1= The distribution of functional waterpoints in Osun, Nigeria are not randomly distributed.

Confidence Level:

The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

L_wp_functional.csr <- envelope(wp_functional_ppp, Lest, nsim = 99, rank = 1, glocal=TRUE)
Generating 99 simulations of CSR  ...
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, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,  99.

Done.
plot(L_wp_functional.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Computing L Function estimation of Nonfunctional Waterpoints

L_wp_nonfunctional = Lest(wp_nonfunctional_ppp, correction = "Ripley")
plot(L_wp_nonfunctional, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test of Nonfunctional Waterpoints

Hypothesis:

Ho = The distribution of non-functional waterpoints in Osun, Nigeria are randomly distributed.

H1= The distribution of non-functional waterpoints in Osun, Nigeria are not randomly distributed.

Confidence Level:

The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

L_wp_nonfunctional.csr <- envelope(wp_nonfunctional_ppp, Lest, nsim = 99, rank = 1, glocal=TRUE)
Generating 99 simulations of CSR  ...
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, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,  99.

Done.
plot(L_wp_nonfunctional.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Analysis:

The L function for both functional and nonfunctional waterpoints have the same shape of an exponential curve. Since the L function is a form of descriptive statistics generally used to determine whether points have a random, dispersed or clustered distribution pattern at certain scale, we can conclude that there are some forms of clustering for both the functional and nonfunctional waterpoints in Osun, Nigeria, at 99% confidence interval.

Spatial Correlation Analysis

I will be analysis the co-location between the functional and non-functional water points’ distribution, using the LCLQ method.

Hypothesis:

Ho = Functional waterpoints are not co-located with nonfunctional water points.

H1= Functional waterpoints are co-located with nonfunctional water points.

Confidence Level:

The null hypothesis will be rejected if p-value if smaller than alpha value of 0.05

Installing package

pacman::p_load(tidyverse, tmap, sf, sfdep) 

Preparing nearest neighbours list

Determine the k (i.e. 6) nearest neighbours for given point geometry

nb <- include_self(
  st_knn(st_geometry(wp_sf), 6))

Computing kernel weights

Derive a weights list by using a kernel function

wt <- st_kernel_weights(nb, 
                        wp_sf, 
                        "gaussian", 
                        adaptive = TRUE)

Converting functional and nonfunctional waterpoints into vectors

A <- wp_functional$`#status_clean`
B <- wp_nonfunctional$`#status_clean`

Computing LCLQ values

LCLQ <- local_colocation(A,
                         B,
                         nb,
                         wt,
                         49)

Joining output table

LCLQ_wp <- cbind(wp_sf, LCLQ)

Plotting LCLQ values

tmap_mode("view")
tm_shape(LCLQ_wp)+ 
  tm_dots(col = "Non.Functional",
             size = 0.01,
             border.col = "black",
          scale=0.15,
             border.lwd = 0.5) +
  tm_view(set.zoom.limits = c(12, 16))

Analysis:

As we can observe from the map plotted above, waterpoints with their LCLQ value of 0.7 to 1.1 (in yellow to brown) are displayed. We can conclude that our null hypothesis is true; that functional waterpoints are not co-located with nonfunctional water points in Osun state (Nigeria).