একটি বৈশিষ্ট্য সংগ্রহের উপর ম্যাপিং, একটি বৈশিষ্ট্য সংগ্রহের উপর ম্যাপিং

একটি FeatureCollection এর প্রতিটি Feature একই ক্রিয়াকলাপ প্রয়োগ করতে, featureCollection.map() ব্যবহার করুন। উদাহরণস্বরূপ, একটি ওয়াটারশেড FeatureCollection প্রতিটি বৈশিষ্ট্যে অন্য একটি এলাকা বৈশিষ্ট্য যোগ করতে ব্যবহার করুন:

কোড এডিটর (জাভাস্ক্রিপ্ট)

// Load watersheds from a data table.
var sheds = ee.FeatureCollection('USGS/WBD/2017/HUC06');

// This function computes the feature's geometry area and adds it as a property.
var addArea = function(feature) {
  return feature.set({areaHa: feature.geometry().area().divide(100 * 100)});
};

// Map the area getting function over the FeatureCollection.
var areaAdded = sheds.map(addArea);

// Print the first feature from the collection with the added property.
print('First feature:', areaAdded.first());

পাইথন সেটআপ

পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।

import ee
import geemap.core as geemap

Colab (পাইথন)

# Load watersheds from a data table.
sheds = ee.FeatureCollection('USGS/WBD/2017/HUC06')

# Map an area calculation function over the FeatureCollection.
area_added = sheds.map(
    lambda feature: feature.set(
        {'areaHa': feature.geometry().area().divide(100 * 100)}
    )
)

# Print the first feature from the collection with the added property.
display('First feature:', area_added.first())

আগের উদাহরণে, লক্ষ্য করুন যে বৈশিষ্ট্যের জ্যামিতি সহ একটি গণনার উপর ভিত্তি করে একটি নতুন সম্পত্তি সেট করা হয়েছে৷ বিদ্যমান বৈশিষ্ট্যগুলি জড়িত একটি গণনা ব্যবহার করে বৈশিষ্ট্যগুলিও সেট করা যেতে পারে।

একটি সম্পূর্ণ নতুন FeatureCollection map() দিয়ে তৈরি করা যেতে পারে। নিম্নলিখিত উদাহরণটি জলাশয়গুলিকে সেন্ট্রোয়েডে রূপান্তরিত করে:

কোড এডিটর (জাভাস্ক্রিপ্ট)

// This function creates a new feature from the centroid of the geometry.
var getCentroid = function(feature) {
  // Keep this list of properties.
  var keepProperties = ['name', 'huc6', 'tnmid', 'areasqkm'];
  // Get the centroid of the feature's geometry.
  var centroid = feature.geometry().centroid();
  // Return a new Feature, copying properties from the old Feature.
  return ee.Feature(centroid).copyProperties(feature, keepProperties);
};

// Map the centroid getting function over the features.
var centroids = sheds.map(getCentroid);

// Display the results.
Map.addLayer(centroids, {color: 'FF0000'}, 'centroids');

পাইথন সেটআপ

পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।

import ee
import geemap.core as geemap

Colab (পাইথন)

# This function creates a new feature from the centroid of the geometry.
def get_centroid(feature):
  # Keep this list of properties.
  keep_properties = ['name', 'huc6', 'tnmid', 'areasqkm']
  # Get the centroid of the feature's geometry.
  centroid = feature.geometry().centroid()
  # Return a new Feature, copying properties from the old Feature.
  return ee.Feature(centroid).copyProperties(feature, keep_properties)

# Map the centroid getting function over the features.
centroids = sheds.map(get_centroid)

# Display the results.
m = geemap.Map()
m.set_center(-96.25, 40, 4)
m.add_layer(centroids, {'color': 'FF0000'}, 'centroids')
m

মনে রাখবেন যে নতুন সংগ্রহের বৈশিষ্ট্যগুলিতে শুধুমাত্র বৈশিষ্ট্যগুলির একটি উপসেট প্রচার করা হয়েছে৷

,

একটি FeatureCollection এর প্রতিটি Feature একই ক্রিয়াকলাপ প্রয়োগ করতে, featureCollection.map() ব্যবহার করুন। উদাহরণস্বরূপ, একটি ওয়াটারশেড FeatureCollection প্রতিটি বৈশিষ্ট্যে অন্য একটি এলাকা বৈশিষ্ট্য যোগ করতে ব্যবহার করুন:

কোড এডিটর (জাভাস্ক্রিপ্ট)

// Load watersheds from a data table.
var sheds = ee.FeatureCollection('USGS/WBD/2017/HUC06');

// This function computes the feature's geometry area and adds it as a property.
var addArea = function(feature) {
  return feature.set({areaHa: feature.geometry().area().divide(100 * 100)});
};

// Map the area getting function over the FeatureCollection.
var areaAdded = sheds.map(addArea);

// Print the first feature from the collection with the added property.
print('First feature:', areaAdded.first());

পাইথন সেটআপ

পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।

import ee
import geemap.core as geemap

Colab (পাইথন)

# Load watersheds from a data table.
sheds = ee.FeatureCollection('USGS/WBD/2017/HUC06')

# Map an area calculation function over the FeatureCollection.
area_added = sheds.map(
    lambda feature: feature.set(
        {'areaHa': feature.geometry().area().divide(100 * 100)}
    )
)

# Print the first feature from the collection with the added property.
display('First feature:', area_added.first())

আগের উদাহরণে, লক্ষ্য করুন যে বৈশিষ্ট্যের জ্যামিতি সহ একটি গণনার উপর ভিত্তি করে একটি নতুন সম্পত্তি সেট করা হয়েছে৷ বিদ্যমান বৈশিষ্ট্যগুলি জড়িত একটি গণনা ব্যবহার করে বৈশিষ্ট্যগুলিও সেট করা যেতে পারে।

একটি সম্পূর্ণ নতুন FeatureCollection map() দিয়ে তৈরি করা যেতে পারে। নিম্নলিখিত উদাহরণটি জলাশয়গুলিকে সেন্ট্রোয়েডে রূপান্তরিত করে:

কোড এডিটর (জাভাস্ক্রিপ্ট)

// This function creates a new feature from the centroid of the geometry.
var getCentroid = function(feature) {
  // Keep this list of properties.
  var keepProperties = ['name', 'huc6', 'tnmid', 'areasqkm'];
  // Get the centroid of the feature's geometry.
  var centroid = feature.geometry().centroid();
  // Return a new Feature, copying properties from the old Feature.
  return ee.Feature(centroid).copyProperties(feature, keepProperties);
};

// Map the centroid getting function over the features.
var centroids = sheds.map(getCentroid);

// Display the results.
Map.addLayer(centroids, {color: 'FF0000'}, 'centroids');

পাইথন সেটআপ

পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।

import ee
import geemap.core as geemap

Colab (পাইথন)

# This function creates a new feature from the centroid of the geometry.
def get_centroid(feature):
  # Keep this list of properties.
  keep_properties = ['name', 'huc6', 'tnmid', 'areasqkm']
  # Get the centroid of the feature's geometry.
  centroid = feature.geometry().centroid()
  # Return a new Feature, copying properties from the old Feature.
  return ee.Feature(centroid).copyProperties(feature, keep_properties)

# Map the centroid getting function over the features.
centroids = sheds.map(get_centroid)

# Display the results.
m = geemap.Map()
m.set_center(-96.25, 40, 4)
m.add_layer(centroids, {'color': 'FF0000'}, 'centroids')
m

মনে রাখবেন যে নতুন সংগ্রহের বৈশিষ্ট্যগুলিতে শুধুমাত্র বৈশিষ্ট্যগুলির একটি উপসেট প্রচার করা হয়েছে৷