{"id":798,"date":"2020-01-18T07:00:00","date_gmt":"2020-01-18T00:00:00","guid":{"rendered":"http:\/\/www.gis2me.com\/geospatial\/?p=798"},"modified":"2025-04-30T09:36:30","modified_gmt":"2025-04-30T02:36:30","slug":"r-studio-ep04-%e0%b9%81%e0%b8%aa%e0%b8%94%e0%b8%87-polygon-shapefile-%e0%b9%83%e0%b8%99-leaflet-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2%e0%b9%82%e0%b8%9b%e0%b8%a3%e0%b9%81%e0%b8%81%e0%b8%a3","status":"publish","type":"post","link":"http:\/\/www.gis2me.com\/geospatial\/?p=798","title":{"rendered":"R-studio : ( EP#04 ) \u0e41\u0e2a\u0e14\u0e07 polygon Shapefile \u0e43\u0e19 leaflet \u0e14\u0e49\u0e27\u0e22\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21 R"},"content":{"rendered":"<p>R-studio : ( EP#04 ) \u0e41\u0e2a\u0e14\u0e07 polygon Shapefile \u0e43\u0e19 leaflet \u0e14\u0e49\u0e27\u0e22\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21 R<br \/>\u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e19\u0e23\u0e39\u0e49 <strong data-start=\"12\" data-end=\"68\">EP#04: \u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25 Polygon Shapefile \u0e1a\u0e19 Leaflet \u0e14\u0e49\u0e27\u0e22 R<\/strong> \u0e40\u0e1b\u0e47\u0e19\u0e08\u0e38\u0e14\u0e40\u0e23\u0e34\u0e48\u0e21\u0e15\u0e49\u0e19\u0e02\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 <strong data-start=\"96\" data-end=\"119\">Web GIS Interactive<\/strong> \u0e1a\u0e19\u0e41\u0e1e\u0e25\u0e15\u0e1f\u0e2d\u0e23\u0e4c\u0e21 R \u0e42\u0e14\u0e22\u0e40\u0e09\u0e1e\u0e32\u0e30\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e43\u0e0a\u0e49\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e40\u0e0a\u0e34\u0e07\u0e1e\u0e37\u0e49\u0e19\u0e17\u0e35\u0e48 (Spatial Data) \u0e40\u0e0a\u0e48\u0e19 <strong data-start=\"188\" data-end=\"201\">Shapefile<\/strong> \u0e0b\u0e36\u0e48\u0e07\u0e21\u0e35\u0e42\u0e04\u0e23\u0e07\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e40\u0e0a\u0e34\u0e07\u0e20\u0e39\u0e21\u0e34\u0e28\u0e32\u0e2a\u0e15\u0e23\u0e4c\u0e17\u0e35\u0e48\u0e2b\u0e25\u0e32\u0e01\u0e2b\u0e25\u0e32\u0e22 \u0e40\u0e0a\u0e48\u0e19 \u0e02\u0e2d\u0e1a\u0e40\u0e02\u0e15\u0e25\u0e38\u0e48\u0e21\u0e19\u0e49\u0e33 (Basin), \u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14, \u0e40\u0e02\u0e15\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e17\u0e35\u0e48\u0e14\u0e34\u0e19 \u0e2f\u0e25\u0e2f<\/p>\n<p>R script \u0e1b\u0e23\u0e30\u0e01\u0e2d\u0e1a\u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e19\u0e23\u0e39\u0e49 <a href=\"https:\/\/bit.ly\/2ArQ26w\">https:\/\/bit.ly\/2ArQ26w<\/a><\/p>\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07 shapefile [BASIN] <a href=\"https:\/\/bit.ly\/2WWDDPk\">https:\/\/bit.ly\/2WWDDPk<\/a><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/6XX-niZs8DI\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udfaf \u0e27\u0e31\u0e15\u0e16\u0e38\u0e1b\u0e23\u0e30\u0e2a\u0e07\u0e04\u0e4c\u0e02\u0e2d\u0e07\u0e1a\u0e17\u0e40\u0e23\u0e35\u0e22\u0e19<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0e40\u0e1e\u0e37\u0e48\u0e2d <strong>\u0e41\u0e2a\u0e14\u0e07\u0e02\u0e2d\u0e1a\u0e40\u0e02\u0e15\u0e40\u0e0a\u0e34\u0e07\u0e1e\u0e37\u0e49\u0e19\u0e17\u0e35\u0e48<\/strong> (Polygon) \u0e08\u0e32\u0e01 <strong>Shapefile<\/strong> \u0e25\u0e07\u0e1a\u0e19 <strong>Leaflet Map<\/strong><\/li>\n\n\n\n<li>\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19\u0e23\u0e39\u0e49\u0e01\u0e32\u0e23\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23 spatial object \u0e14\u0e49\u0e27\u0e22 <code>sf<\/code> \u0e41\u0e25\u0e30\u0e01\u0e32\u0e23 render \u0e14\u0e49\u0e27\u0e22 <code>leaflet<\/code><\/li>\n\n\n\n<li>\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e2a\u0e37\u0e48\u0e2d\u0e2a\u0e32\u0e23\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e1c\u0e48\u0e32\u0e19 <strong>popup<\/strong>, <strong>label<\/strong>, <strong>custom styling<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udce5 \u0e14\u0e32\u0e27\u0e19\u0e4c\u0e42\u0e2b\u0e25\u0e14\u0e44\u0e1f\u0e25\u0e4c\u0e40\u0e23\u0e35\u0e22\u0e19\u0e23\u0e39\u0e49<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ud83d\udcc4 <strong>R Script \u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07<\/strong>: <a class=\"\" href=\"https:\/\/bit.ly\/2ArQ26w\">https:\/\/bit.ly\/2ArQ26w<\/a><\/li>\n\n\n\n<li>\ud83d\uddfa\ufe0f <strong>Shapefile \u0e25\u0e38\u0e48\u0e21\u0e19\u0e49\u0e33 (BASIN)<\/strong>: <a class=\"\" href=\"https:\/\/bit.ly\/2WWDDPk\">https:\/\/bit.ly\/2WWDDPk<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udee0 \u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25 Shapefile \u0e43\u0e19 Leaflet<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u0e15\u0e34\u0e14\u0e15\u0e31\u0e49\u0e07\u0e41\u0e25\u0e30\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e41\u0e1e\u0e47\u0e01\u0e40\u0e01\u0e08<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">rCopyEdit<code>install.packages(\"sf\")\ninstall.packages(\"leaflet\")\n\nlibrary(sf)\nlibrary(leaflet)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u0e2d\u0e48\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 Shapefile (\u0e15\u0e49\u0e2d\u0e07\u0e23\u0e27\u0e21\u0e44\u0e1f\u0e25\u0e4c .shp, .shx, .dbf, .prj)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">rCopyEdit<code>basin &lt;- st_read(\"BASIN.shp\")  # \u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19 path \u0e43\u0e2b\u0e49\u0e15\u0e23\u0e07\u0e01\u0e31\u0e1a\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e40\u0e1a\u0e37\u0e49\u0e2d\u0e07\u0e15\u0e49\u0e19<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">rCopyEdit<code>head(basin)\nst_crs(basin)\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u0e04\u0e27\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e27\u0e48\u0e32 CRS \u0e40\u0e1b\u0e47\u0e19 <code>WGS84 (EPSG:4326)<\/code><br>\u0e2b\u0e32\u0e01\u0e44\u0e21\u0e48\u0e43\u0e0a\u0e48 \u0e43\u0e2b\u0e49\u0e41\u0e1b\u0e25\u0e07\u0e14\u0e49\u0e27\u0e22:<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-preformatted\">rCopyEdit<code>basin &lt;- st_transform(basin, crs = 4326)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25\u0e14\u0e49\u0e27\u0e22 Leaflet<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">rCopyEdit<code>leaflet(data = basin) %&gt;%\n  addTiles() %&gt;%\n  addPolygons(\n    fillColor = \"lightgreen\",\n    weight = 1,\n    color = \"darkgreen\",\n    fillOpacity = 0.5,\n    popup = ~BASIN_NAME  # \u0e0a\u0e37\u0e48\u0e2d\u0e1f\u0e34\u0e25\u0e14\u0e4c\u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e2b\u0e49\u0e41\u0e2a\u0e14\u0e07\n  )\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udca1 \u0e40\u0e17\u0e04\u0e19\u0e34\u0e04\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u0e1f\u0e35\u0e40\u0e08\u0e2d\u0e23\u0e4c<\/th><th>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07<\/th><\/tr><\/thead><tbody><tr><td>\u0e41\u0e2a\u0e14\u0e07 Tooltip<\/td><td><code>label = ~BASIN_NAME<\/code><\/td><\/tr><tr><td>\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e2a\u0e35\u0e15\u0e32\u0e21\u0e04\u0e48\u0e32\u0e1f\u0e34\u0e25\u0e14\u0e4c<\/td><td>\u0e43\u0e0a\u0e49 <code>colorBin()<\/code> \u0e2b\u0e23\u0e37\u0e2d <code>colorFactor()<\/code> \u0e08\u0e32\u0e01 <code>RColorBrewer<\/code><\/td><\/tr><tr><td>\u0e40\u0e1e\u0e34\u0e48\u0e21 Layer Control<\/td><td><code>addLayersControl()<\/code> \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e40\u0e1b\u0e34\u0e14-\u0e1b\u0e34\u0e14\u0e0a\u0e31\u0e49\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25<\/td><\/tr><tr><td>\u0e43\u0e0a\u0e49 GeoJSON \u0e41\u0e17\u0e19 SHP<\/td><td>\u0e43\u0e0a\u0e49 <code>geojsonio::geojson_read()<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udf0d \u0e01\u0e32\u0e23\u0e1b\u0e23\u0e30\u0e22\u0e38\u0e01\u0e15\u0e4c\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0e41\u0e2a\u0e14\u0e07 <strong>\u0e02\u0e2d\u0e1a\u0e40\u0e02\u0e15\u0e25\u0e38\u0e48\u0e21\u0e19\u0e49\u0e33<\/strong> \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e40\u0e0a\u0e34\u0e07\u0e19\u0e34\u0e40\u0e27\u0e28\u0e2b\u0e23\u0e37\u0e2d\u0e2d\u0e38\u0e17\u0e01\u0e27\u0e34\u0e17\u0e22\u0e32<\/li>\n\n\n\n<li>\u0e41\u0e2a\u0e14\u0e07 <strong>\u0e1e\u0e37\u0e49\u0e19\u0e17\u0e35\u0e48\u0e40\u0e2a\u0e35\u0e48\u0e22\u0e07\u0e19\u0e49\u0e33\u0e17\u0e48\u0e27\u0e21<\/strong> \u0e2b\u0e23\u0e37\u0e2d <strong>\u0e1e\u0e37\u0e49\u0e19\u0e17\u0e35\u0e48\u0e40\u0e1e\u0e32\u0e30\u0e1b\u0e25\u0e39\u0e01<\/strong><\/li>\n\n\n\n<li>\u0e2a\u0e23\u0e49\u0e32\u0e07 <strong>WebGIS Dashboard<\/strong> \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e17\u0e31\u0e48\u0e27\u0e44\u0e1b<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd17 \u0e41\u0e2b\u0e25\u0e48\u0e07\u0e40\u0e23\u0e35\u0e22\u0e19\u0e23\u0e39\u0e49\u0e40\u0e2a\u0e23\u0e34\u0e21<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a class=\"\" href=\"https:\/\/youtu.be\/UaEtZ5XzVeE\">\u0e15\u0e34\u0e14\u0e15\u0e31\u0e49\u0e07 R \u0e41\u0e25\u0e30 RStudio \u0e1a\u0e19 Windows<\/a><\/li>\n\n\n\n<li><a class=\"\">\u0e41\u0e2b\u0e25\u0e48\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 GIS \u0e40\u0e1b\u0e34\u0e14<\/a> \u0e40\u0e0a\u0e48\u0e19 \u0e08\u0e32\u0e01 GISTDA, ONEP, \u0e2a\u0e2a\u0e19\u0e01.<\/li>\n\n\n\n<li><a class=\"\">R Spatial Cheat Sheet by RStudio<\/a><\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc \u0e2a\u0e23\u0e38\u0e1b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25 Polygon Shapefile \u0e43\u0e19 Leaflet \u0e14\u0e49\u0e27\u0e22 R \u0e40\u0e1b\u0e47\u0e19\u0e1e\u0e37\u0e49\u0e19\u0e10\u0e32\u0e19\u0e02\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e41\u0e1c\u0e19\u0e17\u0e35\u0e48\u0e42\u0e15\u0e49\u0e15\u0e2d\u0e1a\u0e40\u0e0a\u0e34\u0e07\u0e1e\u0e37\u0e49\u0e19\u0e17\u0e35\u0e48\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e27\u0e34\u0e08\u0e31\u0e22 \u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e19\u0e01\u0e32\u0e23\u0e2a\u0e2d\u0e19 \u0e41\u0e25\u0e30\u0e23\u0e30\u0e1a\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e20\u0e39\u0e21\u0e34\u0e28\u0e32\u0e2a\u0e15\u0e23\u0e4c\u0e1a\u0e19\u0e40\u0e27\u0e47\u0e1a \u0e0a\u0e48\u0e27\u0e22\u0e40\u0e1b\u0e34\u0e14\u0e42\u0e2d\u0e01\u0e32\u0e2a\u0e43\u0e19\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e23\u0e30\u0e1a\u0e1a GIS \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e2b\u0e19\u0e48\u0e27\u0e22\u0e07\u0e32\u0e19\u0e17\u0e49\u0e2d\u0e07\u0e16\u0e34\u0e48\u0e19\u0e2b\u0e23\u0e37\u0e2d\u0e0a\u0e38\u0e21\u0e0a\u0e19\u0e14\u0e49\u0e27\u0e22\u0e40\u0e17\u0e04\u0e42\u0e19\u0e42\u0e25\u0e22\u0e35\u0e42\u0e2d\u0e40\u0e1e\u0e19\u0e0b\u0e2d\u0e23\u0e4c\u0e2a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>R-studio : ( EP#04 ) \u0e41\u0e2a\u0e14\u0e07 polygon Shapefile \u0e43\u0e19 leaflet  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[21],"tags":[440,633,477,631,636,439,486,632,90,635,62,634,630,638,637],"class_list":["post-798","post","type-post","status-publish","format-standard","hentry","category--r-studio","tag-gis--r","tag-leaflet-polygon","tag-leaflet-r","tag-polygon-map-r","tag-r-leaflet-shapefile","tag-r-studio","tag-sf-package","tag-shapefile--leaflet","tag-web-gis","tag-web-gis--r","tag-62","tag-634","tag--shapefile","tag--r--polygon","tag--shapefile-"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=\/wp\/v2\/posts\/798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=798"}],"version-history":[{"count":1,"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=\/wp\/v2\/posts\/798\/revisions"}],"predecessor-version":[{"id":799,"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=\/wp\/v2\/posts\/798\/revisions\/799"}],"wp:attachment":[{"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=798"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gis2me.com\/geospatial\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}