Springe direkt zu Inhalt

الراستر والفيكتور: الوصول والمرشحات

كما هو مذكور في بنية البيانات، يتم تخزين بيانات الصورة في مجموعات الصور. لمعرفة مجموعات الصور الموجودة وكيفية الوصول إليها، أدخل اسم المستشعر الذي تهتم به في شريط البحث أعلى واجهة المتصفح. 

في هذا المثال، سنبحث عن بيانات Sentinel 2. من خلال كتابة "sentinel 2" في شريط البحث، فإنه يعرض جميع مجموعات البيانات النقطية المتاحة التي تتضمن الكلمتين "Sentinel" و "2". سنختار "Sentinel-2 MSI: MultiSpectral Instrument، Level-2A”، حيث تمت معالجته مسبقًا من أجل انعكاس السطح. انقر فوق الرابط للوصول إلى صفحة التوثيق، حيث يمكنك العثور على جميع المعلومات الضرورية حول مجموعة البيانات، والنطاقات المتاحة، وخصائص الصورة بالإضافة إلى مقتطف الشفرة البرمجية الذي يوضح كيفية استيراد المجموعة إلى البرنامج النصي الخاص بك. 

دعونا نحاول العمل مع مجموعة الصور من خلال تحديد متغير لها وطباعتها على مجموعتنا. 

var IC = ee.ImageCollection('COPERNICUS/S2_SR')

print(IC)

بعد فترة قصيرة من الحساب، سوف نتلقى رسالة خطأ؛

 مجموعة الصور (خطأ): تم إحباط استعلام المجموعة بعد تجميع أكثر من 5000 عنصر.

فقط للتذكير: ما حاولنا فعله للتو هو الوصول إلى أرشيف Sentinel 2 Level 2-A بالكامل غير المصفاة، عالميًا ومنذ أن بدأ الإرسال في عام 2017. ليس من المستغرب أنه حتى GEE سيتعين عليه الانحناء إلى هذا المقدار من البيانات، وذلك بعد تجميع أكثر من 5000 عنصر. 

يلفت هذا الانتباه إلى ضرورة أمرين: التحديد المكاني لمنطقة البحث وتصفية بيانات الصورة. 

تحديد منطقة البحث مكانيا

هناك طرق متعددة لتحديد مجال اهتمامك في GEE. الطريقة الأساسية والأسرع التي يمكنك الرجوع إليها دائمًا هي ببساطة رسم نقطة أو شكل مضلع باستخدام أدوات الهندسة واستخدام نطاقاتها كمرشح الحدود.

هناك طريقة أخرى تتمثل في استخدام أحد مجموعات بيانات الراستر العديدة في كتالوجات بيانات GEE وتصفيتها وفقًا للشرائح الجغرافية التي تحتاجها.

إذا كنت تريد التأكد من الحصول على صور للطبقات الإدارية الكاملة على سبيل المثال، فيمكنك الاستفادة من مجموعات بيانات الفيكتور "طبقات الوحدة الإدارية العالمية 2015" المتنوعة. بدلاً من ذلك، يمكنك أيضًا تحميل ملفات الأشكال الهندسية الخاصة بك المُعدة والجاهزة عبر علامة التبويب الأصول في اللوحة اليمنى.

var dataset = ee.FeatureCollection('FAO/GAUL/2015/level0')
var dataset = ee.FeatureCollection('FAO/GAUL/2015/level1')
var dataset = ee.FeatureCollection('FAO/GAUL/2015/level2')

مجموعات تصفية الصورة

تسمح لنا تصفية البيانات بالوصول فقط إلى البيانات ذات الصلة بأسئلتنا البحثية. لصياغة مثال جذري: إذا كنا مهتمين بمراقبة حرائق الغابات في سوريا، فلا داعي على الإطلاق لحساب صور أمريكا الشمالية لأنها ستؤدي فقط إلى تدمير أوقات المعالجة وقدراتنا. يمكن إضافة المرشحات بسهولة إلى مجموعة الصور التي تريدها عن طريق إضافة. filter (). هناك الكثير من الفلاتر الممكنة لصورك، على سبيل المثال: 

.filterBounds() //filters for images that lie within your Area of Interest

.filterDate() //filters for images within the selected range of dates (YYYY-MM-DD)

ee.filter.eq('ImageProperty', 'Name') //filters 'equals' for Metadata (a comprehensive list of every sensors Image Properties can be found in the sensor documentation from the search bar)

ee.filter.lt('ImageProperty', 'Name') //filters 'less than' for Metadata

ee.filter.gt('ImageProperty', 'Name') //filters 'greater than' for metadata


تتضمن الأوامر المفيدة الأخرى لتصفية مجموعة الصور الخاصة بك ما يلي:

.select() //selects specific bands of your imagery, can also be used as a list

.sort('Imageproperty') //sorts imagery for specific image properties, for example 'Cloudy_Pixel_Percentage' for Sentinel-2 data

.mean() //generates a single image composed of the mean values of all images in the IC

في الواقع الوصول إلى البيانات وتصفيتها

بعد هذا التدفق على المعلومات، دعونا نلقي نظرة على كيفية الوصول إلى بيانات الصور وتصفيتها في الممارسة العملية.

سترى أنه ليس معقدًا على الإطلاق. في هذا الدرس، سنلقي نظرة على مثال بسيط للغاية يتيح لنا الوصول إلى صور Sentinel-2 Level-2A لعام 2020 بأكمله لمنطقة البحث المختارة. 

من فضلك، افتح GEE في متصفح الويب الخاص بك، وانسخ مقتطف الكود التالي في محرر الكود الخاص بك وقم بتشغيله.

//Step 1: Use the map panel to browse to your research area. Define an Area of Interest by defining a point or polygon geometrie, or upload a shapefile to your assets.
//In this example, we use the Global Administration Units Layer(GAUL) 2015 to access geometry data of Lebanon. Please check the official documentation to learn more about its table schema.
//Keep in mind that this will not clip the imagery to the extents of Lebanon, so we will have a lot of excess data!

var extent_lebanon = ee.FeatureCollection('FAO/GAUL/2015/level0')
                  .filter(ee.Filter.eq('ADM0_NAME', 'Lebanon')) //filter for entry that equals the UN country name 'Lebanon'


//Step 2: Access the Sentinel-2 Level-2A data and filter it for all the the images of the year 2020 that lie within the geometries boundaries. Keep only the relevant bands.
var s2a = ee.ImageCollection('COPERNICUS/S2_SR')
                  .filterBounds(extent_lebanon)
                  .filterDate('2020-01-01', '2020-12-31')
                  .select('B1','B2','B3','B4','B5','B6','B7','B8','B8A','B9','B11','B12')

//Print your ImageCollection to your console tab to inspect it
print(s2a, 'Image Collection 2020')

/*
You can now check the printed ImageCollection in your Console to see that we have 678 images that we can freely use for further analysis and processing. 
By clicking on the arrows, you can look at further details and properties of the single Images of the ImageCollection.
*/

//if we want to shrink this ImageCollection further down by reducing bloating images that are not of much use, we can filter for clouds as well.

var s2a_cloudfree = s2a
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10)) //filters for entries with less than 10% cloudy pixel percentage

print(s2a_cloudfree, 'Image Collection 2020 < 10% Cloud Cover')  // now, only 363 images are left
 
 
//if we are interested in getting the 20 least cloudy images of 2020, this can also be easily achieved:

var s2a_leastcloudy = s2a_cloudfree
                  .sort('CLOUD_COVERAGE_ASSESSMENT', true)
                  .limit(20);
                  
print(s2a_leastcloudy, 'Image Collection 2020 20 least cloudy images')
 
 
 
//Alternatively, add .mean() to generate a single image that is composed of the mean values of all images in the IC. 
var s2a_mean = ee.ImageCollection('COPERNICUS/S2_SR')
                  .filterBounds(extent_lebanon)
                  .filterDate('2020-01-01', '2020-12-31')
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',10))
                  .mean();

print(s2a_mean, 'Image Collection 2020 mean')