-- cs = CellularSpace{ dbType = "ADO", host = "localhost", database = "c:\\TerraME\\Database\\rondonia.mdb", user = "", password = "", layer = "celulas_500_Anari_1995", theme = "celulas_500_Anari_1995", select = {"cover_", "dist_rodovia_BR", "dist_ramal_princ", "dist_ramal_sec", "dist_vicinal"} } -- CONSTRAINTS CELL_AREA = 0.25; --km2 FINAL_TIME = 5; --Ano final cs:load(); -- Carrega para memoria CreateMooreNeighbourhood(cs); demandaAtual = DEMAND; for time = 1, FINAL_TIME, 1 do demandaAtual = 20; cs:synchronize(); print("t= "..time); -- percorrendo e espaco e medindo o potencial de mudanca for i, cell in pairs (cs.cells) do count = 0; ForEachNeighbour (cell, 0, function (cell, neigh) if (neigh.past.cover_ == "deforested") and (cell ~= neigh ) then count = count + 1; end end ); cell.potential = -1000000000; --Se desflorestado o potencial da celula permanece zero if (cell.cover_ == "forest") then coefViz = 0.173*count; coefDist1 = -0.1 * math.log10 (cell.dist_rodovia_BR/1000); --Distancia em km coefDist2 = 0.053 * math.log10 (cell.dist_ramal_princ / 1000); coefDist3 = -0.157 * math.log10 (cell.dist_ramal_sec / 1000); coefDist4 = -0.012 * math.log10 (cell.dist_vicinal / 1000); cell.potential = coefViz + coefDist1 + coefDist2 + coefDist3 + coefDist4; end end -- Ordenar o espaco em funcao do potencial it = SpatialIterator { cs, function(cell) return cell.potential > -100000000; end, function(cel1,cel2) return cel1.potential > cel2.potential; end } -- Alocar as mudancas for i, cell in pairs( it.cells ) do demandaAtual = demandaAtual - CELL_AREA; if (demandaAtual < 0) then break; end; cell.cover_ = "deforested"; end end cs:save( 2000, "lucc_regressao_", {"cover_"} );