Closed pedro-andrade-inpe closed 8 years ago
TerraLib strategy: PRESENCE
The output of this operation is wrong. There cells with the presence of some point should have value one and the others should have zero. The zero values are correct, but the cells that should have one as value in fact are removed from the Layer. See the script below:
import("terralib")
local projName = "cellular_layer_basic.tview"
local proj = Project {
file = projName,
clean = true
}
local layerName1 = "Setores_2000"
Layer{
project = proj,
name = layerName1,
file = filePath("Setores_Censitarios_2000_pol.shp", "terralib")
}
local localidades = "Localidades"
Layer{
project = proj,
name = localidades,
file = filePath("Localidades_pt.shp", "terralib")
}
local rodovias = "Rodovias"
Layer{
project = proj,
name = rodovias,
file = filePath("Rodovias_lin.shp", "terralib")
}
local testDir = _Gtme.makePathCompatibleToAllOS(currentDir())
local clName1 = "Setores_Cells"
local shp1 = clName1..".shp"
local filePath1 = testDir.."/"..shp1
local fn1 = getFileName(filePath1)
fn1 = testDir.."/"..fn1
local exts = {".dbf", ".prj", ".shp", ".shx"}
for i = 1, #exts do
local f = fn1..exts[i]
if isFile(f) then
rmFile(f)
end
end
local cl = Layer{
project = proj,
source = "shp",
input = layerName1,
name = clName1,
resolution = 30000,
file = filePath1
}
local cs = CellularSpace{
project = proj,
layer = clName1
}
print(#cs)
print("---------------")
local presenceLayerName = clName1.."_Presence"
local shp2 = presenceLayerName..".shp"
local filePath2 = testDir.."/"..shp2
local fn2 = getFileName(filePath2)
fn2 = testDir.."/"..fn2
for i = 1, #exts do
local f = fn2..exts[i]
if isFile(f) then
rmFile(f)
end
end
cl:fill{
operation = "presence",
name = localidades,
attribute = "presence",
output = presenceLayerName
}
local cs = CellularSpace{
project = proj,
layer = presenceLayerName
}
print(#cs)
map = Map{
target = cs,
select = "presence",
grid = true,
value = {0, 1},
color = {"blue", "black"}
}
See that the number of cells is reduced in the prints. They are also drawn white in the Map.
@pedro-andrade-inpe have you tested in terraview with the same data?
Implement strategy "presence" for fillCell with vectorial data. #788.