LEGAL - Examples

EXAMPLE 1

       //Example – the crossing of 2 thematic information layers
      {
      //Defining variables and their categories
      Thematic soil(“Soil”), slop(“Slope”), apt(“Suitability”);
      //Recovering information layers
      slop=Retrieve (Name = “dec”);
      soil=Retrieve (Name = “soi”);
      //Creating a new information layer
      suit=New(Name=“Suitability”, ResX=200, ResY=200, Scale=100000);
      //Defining the relations between classes
      suit = Assign (CategoryOut = “Suitability”)
      {
      “good”: (soil.Class == “Cd1“ && slope.Class == “0-3“),
      “medium”: (soil.Class == “Cd1“ && slope.Class == “3-8“),
      “low”: (soil.Class == “Cd1“ && slope.Class == “8-20“)
      }

EXAMPLE 2

      //Example of slicing using some soil data 
      {
      Numeric grd ("Numeric_slope");
      Thematic fat ("Slope");
      Table fati (Slicing);
      grd = Retrieve(Name="decliv-30x30");
      fat = New(Name= "decli_fat_30x30", ResX=30, ResY=30, Scale=100000);
      fati=New(CategoryIn="Numeric_slope",CategoryOut = Slope",
      [0.0,3.0] : "A-0a3",
      [3.0, 8.0] : "B-3a8",
      [8.0, 12.0] : "C-8a12",
      [12.0, 20.0] : "D-12a20",
      [20.0, 45.0] : "E-20a45",
      [45.0 ,90.0] : "F>45",
      [90 , 900] : "F>45");
      fat = Slice(grd,fati);
      }


EXAMPLE 3

      //Example of Weighting using soil data
      {
      Thematic soil("Soils");
      Numeric solero ("Erosion");
      Image solima ("Image");
      Table pond (Weighting);
      soil = Retrieve (Name = "solos");
      solero=New(Name="soloPond",ResX=30,ResY=30,Scale=100000,Min=0,Max=100);
      solima = New (Name ="soloPond", ResX=30, ResY=30);
      pond = New (CategoryIni = "Soils", CategoryOut = "Erosion",
      "LV1" : 0,
      "AR" : 50,
      "LV2" : 100,
      "PV1" : 150);
      solero = Weight (solo,pond);
      solima = Image (solero); }


EXAMPLE 4

      //Example of reclassification using soil data
      {
      Thematic uso, recl ("usoatual");
      Table juntar (Reclassificacao);
      uso = Retrieve (Name="usoatual");
      recl = New (Name= "recla_alg", ResX=30, ResY=30, Scale = 100000);
      juntar = New (CategoryIn = "usoatual", CategoryOut = "usoatual",
      "mata": "Veg_nat",
      "cap+mato": "Veg_nat",
      "capoeira" : "Veg_nat",
      "acude": "agua",
      "cultura": "agricola",
      "capoeira+cult" : "agricola",
      "pasto": "pastoril",
      "pasto+pastosujo": "pastoril",
      "pasto+cult": "pastoril",
      "pasto": "pastoril",
      "pastosujo" : "pastoril",
      "eucalipto" : "silvicola",
      "escola" : "urbano",
      "terraco" : "terraco",
      "erosao" : "erosao");
      recl = Reclassify (uso, juntar);
      }


EXAMPLE 5

      //Example: converting a DN-Image to a Image-Apparent reflectance using the
      //general equation proposed by Markham & Baker (1987) {
      Image IV255, ima3, ima4, tm3, tm4,IV2("Image_TM");
      Numeric re3("Numeric"), re4("Numeric"), IVNAl ("Numeric") ;
      tm3 = Retrieve (Name="tm3_030895");
      tm4 = Retrieve (Name="tm4_030895");
      re3=New(Name="tm3_refl",ResX=30,ResY=30,Scale=100000,Min=0,Max=50);
      re4=New(Name="tm4_refl",ResX=30,ResY=30,Scale=100000,Min=0,Max=50);
      IVNAl=New(Name="IV_Refalg",ResX=30,ResY=30,Scale=100000,Min=0,Max=50);
      IV2 = New (Name = "IVDN_RefAlg", ResX = 30, ResY = 30);
      IV255 = New (Name = "IV255", ResX = 30, ResY = 30);
      ima3 = New (Name = "ima3reflect", ResX = 30, ResY = 30);
      ima4 = New (Name = "ima4reflect", ResX = 30, ResY = 30);
      c1 = 1.0119;
      c2 = 0.607735;
      re3=Digital((PI*(C1^2)/155.7*C2)*((tm3/255)*(20.43-(-0.12))+(-0.12)));
      re4=Digital((PI*(C1^2)/104.7*C2)*((tm4/255)*(20.62-(-0.15))+(-0.15)));
      ima3= Image (re3 * 255);
      ima4= Image (re4 * 255);
      IVNAl = (re4-re3)/(re4+re3);
      IV2= Image ((re4-re3)/(re4+re3));
      IV255 = Image (255*((re4-re3)/(re4+re3)));
      }


EXAMPLE 6

       
      // Example of the vegetation index from a TM Image
      {
      {
      Image tm3, tm4, viimg("Image_TM");
      Digital ndvi("Numeric");
      Thematic veget("Vegetation");
      tm3 = Retrieve (Name = "tm3_86");
      tm4 = Retrieve (Name = "tm4_86");
      viimg = New (Name = "Vegetation", ResX = 120, ResY = 120);
      viimg = 40*((tm4-tm3)/(tm4+tm3))+64;
      Table slice(Slicing);
      slice = New(CategoryOut = "Vegetation",
      [0.0,0.2] : "Non_forest",
      [0.2,0.5] : "Transition",
      [0.5,1.0] : "Forest");
      veget = New(Name="SoilCoverage",ResX=120,ResY=120,Scale=250000);
      veget = Slice(Digital((tm4-tm3)/(tm4+tm3)), slice);
      }

 

How to Execute Map Algebra

  LEGAL