propertypricebn / bruneimap

Plot Brunei maps in R
GNU General Public License v3.0
0 stars 0 forks source link

Missing values in the `kpg_sf` #1

Open haziqj opened 1 year ago

haziqj commented 1 year ago

Several areas in Brunei were found to be nameless (as pulled from the Survey department data). Perhaps we could name them somehow. If anyone knows suitable names for these areas, would love to hear them!

kpg_sf %>%
    filter(is.na(kampong)) %>%
    print(n = Inf)
#> Simple feature collection with 33 features and 7 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 114.2895 ymin: 4.339887 xmax: 115.1593 ymax: 5.044288
#> Geodetic CRS:  WGS 84
#> # A tibble: 33 × 8
#>       id kampong mukim       area                  geometry district     X     Y
#>  * <dbl> <chr>   <chr>      <dbl>             <POLYGON [°]> <chr>    <dbl> <dbl>
#>  1   249 <NA>    Mukim G…  9.66e5 ((114.873 4.905794, 114.… Brunei …  115.  4.90
#>  2   299 <NA>    Mukim K…  2.69e8 ((114.4216 4.557172, 114… Belait    114.  4.45
#>  3   370 <NA>    Mukim L…  6.21e7 ((114.4742 4.608617, 114… Belait    114.  4.60
#>  4   882 <NA>    <NA>     NA      ((115.0622 4.982716, 115… <NA>      115.  4.98
#>  5   883 <NA>    <NA>     NA      ((115.1302 4.996881, 115… <NA>      115.  5.00
#>  6   884 <NA>    <NA>     NA      ((115.1004 5.040252, 115… <NA>      115.  5.04
#>  7   893 <NA>    <NA>     NA      ((115.0451 4.981587, 115… <NA>      115.  4.98
#>  8   894 <NA>    <NA>     NA      ((115.0415 4.999762, 115… <NA>      115.  5.00
#>  9   895 <NA>    <NA>     NA      ((115.0435 4.997858, 115… <NA>      115.  5.00
#> 10   896 <NA>    <NA>     NA      ((115.0419 4.995619, 115… <NA>      115.  5.00
#> 11   901 <NA>    <NA>     NA      ((115.025 4.931068, 115.… <NA>      115.  4.93
#> 12   902 <NA>    <NA>     NA      ((115.029 4.950193, 115.… <NA>      115.  4.95
#> 13   908 <NA>    <NA>     NA      ((115.0413 4.908514, 115… <NA>      115.  4.90
#> 14   910 <NA>    <NA>     NA      ((115.0469 4.896099, 115… <NA>      115.  4.89
#> 15   911 <NA>    <NA>     NA      ((115.0997 4.876362, 115… <NA>      115.  4.88
#> 16   913 <NA>    <NA>     NA      ((115.1071 4.872158, 115… <NA>      115.  4.89
#> 17   914 <NA>    <NA>     NA      ((115.1292 4.86113, 115.… <NA>      115.  4.88
#> 18   915 <NA>    <NA>     NA      ((115.0518 4.81406, 115.… <NA>      115.  4.81
#> 19   917 <NA>    <NA>     NA      ((114.9557 4.866652, 114… <NA>      115.  4.87
#> 20   920 <NA>    <NA>     NA      ((114.9567 4.860957, 114… <NA>      115.  4.86
#> 21   921 <NA>    <NA>     NA      ((114.6245 4.788118, 114… <NA>      115.  4.79
#> 22   922 <NA>    <NA>     NA      ((114.6257 4.788173, 114… <NA>      115.  4.79
#> 23   923 <NA>    <NA>     NA      ((114.6283 4.788625, 114… <NA>      115.  4.79
#> 24   924 <NA>    <NA>     NA      ((114.6285 4.789095, 114… <NA>      115.  4.79
#> 25   925 <NA>    <NA>     NA      ((115.0733 4.836794, 115… <NA>      115.  4.83
#> 26   926 <NA>    <NA>     NA      ((115.0662 4.829475, 115… <NA>      115.  4.82
#> 27   927 <NA>    <NA>     NA      ((114.6283 4.788625, 114… <NA>      115.  4.79
#> 28   928 <NA>    <NA>     NA      ((114.6257 4.788173, 114… <NA>      115.  4.79
#> 29   929 <NA>    <NA>     NA      ((114.6285 4.789095, 114… <NA>      115.  4.79
#> 30   930 <NA>    <NA>     NA      ((114.6245 4.788118, 114… <NA>      115.  4.79
#> 31   932 <NA>    <NA>     NA      ((115.0402 5.000592, 115… <NA>      115.  5.00
#> 32   933 <NA>    <NA>     NA      ((114.6043 4.773572, 114… <NA>      115.  4.77
#> 33   983 <NA>    <NA>     NA      ((115.0443 4.910401, 115… <NA>      115.  4.92
ggplot(filter(kpg_sf, is.na(kampong))) +
  geom_sf(data = dis_sf, fill = NA) +
  geom_sf(fill = "red3", col = "red3") +
  ggsflabel::geom_sf_text_repel(aes(label = id), max.overlaps = Inf)

image

haziqj commented 1 year ago

Managed to clean up these NA values. Majority of them are islands, so it is hard to pinpoint an administrative area for them (Mukim). For house price analysis, these are extremely unlikely to be inhabited (possibly some of them are protected too). Anyway, for posterity, here's the clean up code:

https://github.com/propertypricebn/bruneimap/blob/665b45227ad930e1c1ecbdb8bb8223c22521f66b/datasrc/20-surveydept.R#L166-L250

haziqj commented 1 year ago

All that's left is to find out the names for the two islands with ids 895 and 896.

Screenshot 2023-09-13 at 11 19 38 PM