GithubHelp home page GithubHelp logo

nusantr's Introduction

nusantr: Indonesia R package

We R Nusantara!

nusantr is an R package which contains:

  • Indonesia map in spatial data frame format (Indonesia map should be downloaded first on GADM)
  • Datasets related to Indonesia such as: Transjakarta data, KRL data, Indonesia name data, etc.
  • A simple function to convert NIK to location, gender and birthdate.

Installation

You need to use sf package to enable the class of sf data frame.

# install.packages("devtools")
install.packages("sf")
install.packages("tidyverse")
devtools::install_github("rasyidstat/nusantr")

Example

Indonesia Map

You can get Indonesia map by using id_map function that will return sf spatial data frame. It contains two parameters: region and level and currently only contains two regions: "indonesia" and "jakarta".

  • "indonesia" consists of two geographical levels such as "provinsi" and "kota".
  • "jakarta" consists of three geographical levels such as "kecamatan", "kelurahan" and "rw".

The data for Indonesia map will be dowloaded from GADM and the data for Jakarta map is get from from Jakarta Smart City.

library(sf)
library(nusantr)
# get jakarta map for 'kelurahan' level
jakarta_kelurahan <- id_map("jakarta", "kelurahan")
jakarta_kelurahan
#> Simple feature collection with 377 features and 8 fields
#> geometry type:  POLYGON
#> dimension:      XY
#> bbox:           xmin: 106.4 ymin: -6.373 xmax: 107 ymax: -5.184
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#> # A tibble: 377 x 9
#>   provinsi_id provinsi kota_id kota  kecamatan_id kecamatan kelurahan_id
#>   <chr>       <chr>    <chr>   <chr> <chr>        <chr>     <chr>       
#> 1 31          DKI Jak… 3171    Jaka… 3171010      Jagakarsa 3171010001  
#> 2 31          DKI Jak… 3172    Jaka… 3172020      Ciracas   3172020001  
#> 3 31          DKI Jak… 3172    Jaka… 3172030      Cipayung  3172030001  
#> 4 31          DKI Jak… 3172    Jaka… 3172030      Cipayung  3172030003  
#> 5 31          DKI Jak… 3172    Jaka… 3172010      Pasar Re… 3172010001  
#> # … with 372 more rows, and 2 more variables: kelurahan <chr>,
#> #   geometry <POLYGON [°]>

Datasets

There are various datasets included on this package such as: Transjakarta data, KRL data, Indonesia name data, etc.

# transjakarta halte data
transjakarta
#> # A tibble: 1,555 x 6
#>   halte_id          halte_name  latitude longitude corridor_cnt schedule_id
#>   <chr>             <chr>          <dbl>     <dbl>        <int> <list>     
#> 1 idjkb_1-10 Sarin… Sarinah        -6.19      107.           10 <chr [10]> 
#> 2 idjkb_1-11 Bank … Bank Indon…    -6.18      107.            9 <chr [9]>  
#> 3 idjkb_1-12 Monas  Monumen Na…    -6.18      107.           16 <chr [16]> 
#> 4 idjkb_1-13 Harmo… Harmoni        -6.17      107.           18 <chr [18]> 
#> 5 idjkb_1-14 Sawah… Sawah Besar    -6.16      107.            5 <chr [5]>  
#> # … with 1,550 more rows

# transjakarta route data
transjakarta_route
#> Simple feature collection with 482 features and 11 fields
#> geometry type:  LINESTRING
#> dimension:      XY
#> bbox:           xmin: 106.6 ymin: -6.396 xmax: 107 ymax: -6.091
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#> # A tibble: 482 x 12
#>   transport_id schedule_id corridor_id corridor_name corridor_color
#>   <chr>        <chr>       <chr>       <chr>         <chr>         
#> 1 idjkb_brt    idjkb_1     1           Blok M - Kota D02027        
#> 2 idjkb_brt    idjkb_1     1           Blok M - Kota D02027        
#> 3 idjkb_brt    idjkb_1     1           Blok M - Kota D02027        
#> 4 idjkb_brt    idjkb_1     1           Blok M - Kota D02027        
#> 5 idjkb_brt    idjkb_1     1           Blok M - Kota D02027        
#> # … with 477 more rows, and 7 more variables: route_id <chr>,
#> #   route_name <chr>, direction <int>, validity <chr>, is_main <lgl>,
#> #   is_main_reverse <lgl>, geometry <LINESTRING [°]>

NIK

You also can convert NIK (Nomor Induk Kependudukan) or KTP ID to location (city and province), gender and birthdate using nik_to_all, nik_to_gender, nik_to_bd, nik_to_city or nik_to_prov.

nik_to_all("3173060101000010")
#> $gender
#> [1] Laki-laki
#> Levels: Laki-laki Perempuan
#> 
#> $bd
#> [1] "2000-01-01"
#> 
#> $city
#> [1] "KOTA JAKARTA PUSAT"
#> 
#> $prov
#> [1] "DKI JAKARTA"

nusantr's People

Contributors

rasyidstat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nusantr's Issues

NPWP

Hi Pak Rasyid,

I am currently working on a project that looks at the oil palm industry in Indonesia and the sustainability issues surrounding it. I really like your package and it will be extremely useful for me in some of my tasks on this project. One really useful dataset that would nice to have in your package in NPWP info on companies. I believe there is a database out there but it will be nice to be able to query that directly through an R package. Not sure if that's possible but just thought I'd put it out there.

Thanks again for all your effort on this package and keep up the good work!

Best,
Jason

Export data transjakarta

Halo pak Rasyid,
Mohon info bagaimana cara export data transjakarta ke csv? Saya coba write.csv dan write.table selalu error.

write.csv(transjakarta, "C:/Temp/transjakarta_halte.csv")
Error in write.table(transjakarta, "C:/Temp/transjakarta_halte.csv", col.names = NA, :
unimplemented type 'list' in 'EncodeElement'

Terima kasih

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.