{"id":44,"date":"2022-05-23T10:00:00","date_gmt":"2022-05-23T03:00:00","guid":{"rendered":"https:\/\/opengis.vn\/?p=44"},"modified":"2024-03-28T09:18:30","modified_gmt":"2024-03-28T02:18:30","slug":"gee-co-ban-huong-dan-loc-tap-anh-theo-ranh-gioi-khong-gian","status":"publish","type":"post","link":"https:\/\/opengis.vn\/en\/blog\/gee-co-ban-huong-dan-loc-tap-anh-theo-ranh-gioi-khong-gian\/","title":{"rendered":"[GEE C\u01a1 b\u1ea3n #2] H\u01b0\u1edbng d\u1eabn l\u1ecdc t\u1eadp \u1ea3nh theo ranh gi\u1edbi kh\u00f4ng gian trong Google Earth Engine"},"content":{"rendered":"<p>===============================================<\/p>\n<h2>Th\u00eam t\u1eadp \u1ea3nh<\/h2>\n<p>\u0110\u1ea7u ti\u00ean, c\u00e1c b\u1ea1n t\u00ecm t\u1eadp \u1ea3nh b\u1ea1n mu\u1ed1n s\u1eed d\u1ee5ng tr\u00ean thanh t\u00ecm ki\u1ebfm<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/72865384\/164989610-e4cf8244-609c-4a62-a72a-78238d34fdab.png\" alt=\"image\" \/><\/p>\n<p>Sau \u0111\u00f3 b\u1ea1n copy d\u00f2ng code c\u1ee7a t\u1eadp \u1ea3nh ho\u1eb7c click Import.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/72865384\/164990392-228785d5-e416-48bd-8e1e-5691390a5e2d.png\" alt=\"image\" \/><\/p>\n<p>T\u1eadp \u1ea3nh m\u1edbi \u0111\u01b0\u1ee3c khai b\u00e1o th\u00e0nh bi\u1ebfn ImageCollection.<\/p>\n<p>Ch\u00fang ta c\u00f3 th\u1ec3 \u0111\u1ed5i t\u00ean bi\u1ebfn theo \u00fd mu\u1ed1n, m\u00ecnh s\u1ebd \u0111\u1ed5i th\u00e0nh L8_collection.<\/p>\n<p>M\u00ecnh s\u1ebd d\u00f9ng h\u00e0m <code>Map.addLayer<\/code> v\u00e0 <code>Map.setCenter<\/code> \u0111\u1ec3 hi\u1ec3n th\u1ecb t\u1eadp \u1ea3nh l\u00ean c\u1eeda s\u1ed5 b\u1ea3n \u0111\u1ed3.<\/p>\n<pre><code class=\"language-javascript\">Map.addLayer(L8_collection, { min:0.05, max: 0.8, bands: 'B6,B5,B4' }, 'Landsat Collection');\nMap.setCenter(100.56, 13.94, 7);<\/code><\/pre>\n<p>T\u1eadp \u1ea3nh g\u1ed3m nhi\u1ec1u \u1ea3nh, nh\u01b0ng kh\u00f4ng ph\u1ea3i t\u1ea5t c\u1ea3 \u0111\u1ec1u \u0111\u01b0\u1ee3c hi\u1ec7n l\u00ean. Khi ch\u00fang ta s\u1eed d\u1ee5ng h\u00e0m <code>Map.addLayer<\/code> \u0111\u1ec3 \u0111\u01b0a m\u1ed9t t\u1eadp \u1ea3nh v\u00e0o c\u1eeda s\u1ed5 b\u1ea3n \u0111\u1ed3, theo m\u1eb7c \u0111\u1ecbnh th\u00ec ch\u1ec9 c\u00e1c pixel m\u1edbi nh\u1ea5t s\u1ebd \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb.<\/p>\n<p>N\u1ebfu b\u1ea1n th\u00eam v\u00e0o d\u00f2ng l\u1ec7nh print\/in, b\u1ea1n c\u00f3 th\u1ec3 x\u00e1c \u0111\u1ecbnh c\u00f3 bao nhi\u00eau \u1ea3nh \u1edf trong t\u1eadp h\u1ee3p.<\/p>\n<pre><code class=\"language-javascript\">\/\/Get the number of images\nprint(L8_collection);<\/code><\/pre>\n<p>Tuy nhi\u00ean, v\u00ec t\u1eadp \u1ea3nh c\u1ee7a ch\u00fang ta t\u01b0\u01a1ng \u0111\u1ed1i l\u1edbn, ch\u00fang ta s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c b\u00e1o l\u1ed7i tr\u00ean Console. V\u00ec th\u1ebf, ch\u00fang ta s\u1ebd l\u1ecdc t\u1eadp \u1ea3nh theo khu v\u1ef1c ch\u00fang ta c\u1ea7n nghi\u00ean c\u1ee9u.<\/p>\n<p><strong>Comment out (\/\/)<\/strong> l\u00ean tr\u01b0\u1edbc l\u1ec7nh <code>print<\/code>. Ch\u00fang ta s\u1ebd tr\u1edf l\u1ea1i sau.<\/p>\n<pre><code class=\"language-javascript\">\/\/ print(L8_collection);<\/code><\/pre>\n<h2>L\u1ecdc t\u1eadp \u1ea3nh theo \u0111\u1ed1i t\u01b0\u1ee3ng h\u00ecnh h\u1ecdc ch\u00fang ta v\u1ebd<\/h2>\n<p>Ph\u00eda g\u00f3c tr\u00ean b\u00ean tr\u00e1i c\u1ee7a c\u1eeda s\u1ed5 b\u1ea3n \u0111\u1ed3\/map window, c\u00f3 m\u1ed9t s\u1ed1 n\u00fat ch\u1ee9c n\u0103ng b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng \u0111\u1ec3 v\u1ebd c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng h\u00ecnh h\u1ecdc. Ch\u00fang ta <strong>click<\/strong> v\u00e0o bi\u1ec3u t\u01b0\u1ee3ng <strong>v\u00f9ng\/ polygon<\/strong> hay <strong>\u00f4 vu\u00f4ng\/square.<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/72865384\/164990330-eaa535c9-dd23-4d22-9c52-53a6453cc85e.JPG\" alt=\"Capture\" \/><\/p>\n<p>C\u00f4ng c\u1ee5 n\u00e0y cho ph\u00e9p b\u1ea1n v\u1ebd m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng h\u00ecnh h\u1ecdc th\u1ec3 hi\u1ec7n v\u00f9ng nghi\u00ean c\u1ee9u c\u1ee7a m\u00ecnh. <strong>Click<\/strong> v\u00e0o c\u1eeda s\u1ed5 b\u1ea3n \u0111\u1ed3 \u0111\u1ec3 t\u1ea1o m\u1ed9t v\u00f9ng hay \u00f4 vu\u00f4ng xung quanh khu v\u1ef1c nghi\u00ean c\u1ee9u c\u1ee7a b\u1ea1n.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/72865384\/164990422-ec569f50-934b-47dc-8525-0bb6429779fc.JPG\" alt=\"Capture2\" \/><\/p>\n<p>Sau khi b\u1ea1n c\u00f3 m\u1ed9t v\u00f9ng\/\u00f4 vu\u00f4ng k\u00edn, s\u1ebd xu\u1ea5t hi\u1ec7n m\u1ed9t b\u1ea3n ghi tr\u00ean code editor v\u1ec1 v\u00f9ng\/\u00f4 vu\u00f4ng v\u1eeba \u0111\u01b0\u1ee3c t\u1ea1o ra. M\u1ed9t bi\u1ebfn t\u00ean geometry \u0111\u01b0\u1ee3c khai b\u00e1o.<\/p>\n<p>Ta c\u00f3 th\u1ec3 <strong>Click<\/strong> v\u00e0o t\u1eeb <strong>geometry<\/strong>, thay <strong>geometry<\/strong> b\u1eb1ng <strong>StudyArea.<\/strong><\/p>\n<p>(<strong>Click<\/strong> v\u00e0o bi\u1ec3u t\u01b0\u1ee3ng \u0111\u1ea7u m\u0169i t\u00ean c\u1ea1nh d\u00f2ng <strong>var StudyArea<\/strong> \u0111\u1ec3 xem th\u00f4ng tin c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng h\u00ecnh h\u1ecdc ch\u00fang ta v\u1eeba t\u1ea1o ra.)<\/p>\n<p>B\u1ea1n c\u00f3 th\u1ec3 l\u00e0m hi\u1ec7n code v\u1eeba t\u1ea1o b\u1eb1ng c\u00e1ch click v\u00e0o box\/h\u1ed9p m\u00e0u xanh lam c\u1ea1nh d\u00f2ng Import.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/72865384\/164990578-9808bffb-8347-4a49-8a02-530a0e353359.png\" alt=\"image\" \/><\/p>\n<p>B\u00e2y gi\u1edd ch\u00fang ta \u0111\u00e3 s\u1eb5n s\u00e0ng \u0111\u1ec3 l\u1ecdc t\u1eadp \u1ea3nh L8_collection b\u1eb1ng h\u00e0m filterBounds.<\/p>\n<pre><code class=\"language-js\">\/\/ Filter to scenes that intersect your boundary\nvar L8_StudyArea = L8_collection.filterBounds(StudyArea);<\/code><\/pre>\n<p>Thay \u0111\u1ed5i bi\u1ebfn trong c\u00e2u l\u1ec7nh <code>Map.addlayer<\/code> th\u00e0nh L8_StudyArea (nh\u01b0 d\u00f2ng l\u1ec7nh ph\u00eda sau \u0111\u00e2y). \u0110\u01b0a n\u00f3 xu\u1ed1ng d\u01b0\u1edbi d\u00f2ng l\u1ec7nh t\u1ea1o bi\u1ebfn <strong>L8_StudyArea<\/strong>.<\/p>\n<pre><code class=\"language-javascript\">Map.addLayer(L8_StudyArea, {min:0.05, max: 0.8, bands: 'B6, B5, B4'}, 'Landsat 8 in study region');<\/code><\/pre>\n<p>Thay \u0111\u1ed5i d\u00f2ng l\u1ec7nh <code>Map.setCenter<\/code> th\u00e0nh <code>map.centerObject<\/code> v\u00e0 c\u1eadp nh\u1eadt c\u00e1c tham s\u1ed1 \u0111\u1ea7u v\u00e0o. C\u00e2u l\u1ec7nh n\u00e0y s\u1ebd gi\u00fap d\u1ecbch chuy\u1ec3n trung t\u00e2m c\u1ee7a c\u1eeda s\u1ed5 b\u1ea3n \u0111\u1ed3 v\u1ec1 \u0111\u1ed1i t\u01b0\u1ee3ng h\u00ecnh h\u1ecdc ch\u00fang ta v\u1eeba t\u1ea1o.<\/p>\n<pre><code class=\"language-javascript\">Map.centerObject(StudyArea,7);<\/code><\/pre>\n<p><strong>Click Run.<\/strong> B\u00e2y gi\u1edd t\u1eadp \u1ea3nh s\u1ebd l\u1ecdc v\u00e0 ch\u1ec9 ch\u1ecdn nh\u1eefng \u1ea3nh giao v\u1edbi v\u00f9ng\/\u00f4 vu\u00f4ng m\u00e0 b\u1ea1n \u0111\u00e3 t\u1ea1o.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/user-images.githubusercontent.com\/72865384\/164990502-f0364783-4fb4-402f-81c9-72d22ce0673e.JPG\" alt=\"Capture3\" \/><\/p>\n<p>B\u00e2y gi\u1edd ch\u00fang ta c\u00f3 th\u1ec3 ch\u1ea1y l\u1ec7nh print \u0111\u1ec3 in chi ti\u1ebft c\u1ee7a t\u1eadp \u1ea3nh m\u1edbi<\/p>\n<pre><code class=\"language-javascript\">print(L8_StudyArea);<\/code><\/pre>\n<p>Khi l\u1ec7nh ho\u00e0n th\u00e0nh, k\u1ebft qu\u1ea3 c\u00f3 744 th\u00e0nh ph\u1ea7n\/elements trong t\u1eadp \u1ea3nh c\u1ee7a t\u00f4i (S\u1ed1 l\u01b0\u1ee3ng \u1ea3nh c\u1ee7a b\u1ea1n c\u00f3 th\u1ec3 kh\u00e1c ph\u1ee5 thu\u1ed9c v\u00e0o k\u00edch th\u01b0\u1edbc c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng h\u00ecnh h\u1ecdc m\u00e0 b\u1ea1n \u0111\u00e3 s\u1ed1 h\u00f3a)<\/p>\n<p>Ch\u00fang ta c\u0169ng c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ph\u01b0\u01a1ng ph\u00e1p \u0111\u1ecbnh k\u00edch th\u01b0\u1edbc c\u1ee7a t\u1eadp \u1ea3nh \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh bao nhi\u00eau \u1ea3nh s\u1ebd c\u00f3 trong t\u1eadp \u1ea3nh c\u1ee7a b\u1ea1n<\/p>\n<pre><code class=\"language-javascript\">\/\/ 2nd method to get the number of images\nvar count = L8_StudyArea.size();\nprint('Count of L8_StudyArea: ', count);<\/code><\/pre>\n<p><strong>Link script \u0111\u1ea7y \u0111\u1ee7:<\/strong><br \/>\n<a href=\"https:\/\/code.earthengine.google.com\/?scriptPath=users%2Fnkthanh2812%2FOpenGIS%3AGEE2_SpatialFilter\">https:\/\/code.earthengine.google.com\/?scriptPath=users%2Fnkthanh2812%2FOpenGIS%3AGEE2_SpatialFilter<\/a><\/p>\n<h2>Video h\u01b0\u1edbng d\u1eabn l\u1ecdc t\u1eadp \u1ea3nh trong Google Earth Engine b\u1eb1ng c\u00e1ch v\u1ebd m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng h\u00ecnh h\u1ecdc \u0111\u1ec3 t\u1ea1o ranh gi\u1edbi kh\u00f4ng gian<\/h2>\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/4YK6n6rf4Zs\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>","protected":false},"excerpt":{"rendered":"<p>=============================================== Th\u00eam t\u1eadp \u1ea3nh \u0110\u1ea7u ti\u00ean, c\u00e1c b\u1ea1n t\u00ecm t\u1eadp \u1ea3nh b\u1ea1n mu\u1ed1n s\u1eed d\u1ee5ng tr\u00ean thanh t\u00ecm ki\u1ebfm Sau \u0111\u00f3 b\u1ea1n copy d\u00f2ng code c\u1ee7a t\u1eadp&#8230; <\/p>","protected":false},"author":2,"featured_media":50,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[8,9,10,12,11],"class_list":["post-44","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-earth-engine-vien-tham","tag-google-earth-engine","tag-image-collection","tag-remote-sensing","tag-spatial-filter","tag-vien-tham"],"_links":{"self":[{"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":7,"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":2910,"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/posts\/44\/revisions\/2910"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/media\/50"}],"wp:attachment":[{"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opengis.vn\/en\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}