TerraME / terrame

TerraME is a programming environment for spatial dynamical modelling
www.terrame.org
GNU Lesser General Public License v3.0
35 stars 13 forks source link

Layer:fill with polygons using average weighted by area aborts terrame #1086

Closed pedro-andrade-inpe closed 8 years ago

pedro-andrade-inpe commented 8 years ago

This operation does not work properly and aborts terrame. In TerraView it works.

pedro-andrade-inpe commented 8 years ago

To reproduce this error just run the script below:

        local projName = "cellular_layer_fill_shape2.tview"
        import("terralib")

        local proj = Project {
            file = projName,
            clean = true
        }

        local layerName1 = "setores"
        Layer{
            project = proj,
            name = layerName1,
            file = filePath("Setores_Censitarios_2000_pol.shp", "terralib")
        }

        local clName1 = "cells_set"

        local shp1 = clName1..".shp"

        local cl = Layer{
            project = proj,
            source = "shp",
            clean = true,
            input = layerName1,
            name = clName1,
            resolution = 50000,
            file = clName1..".shp"
        }

        -- AVERAGE

        local polavgLayerName = clName1.."_polavg"
        local shp1 = polavgLayerName..".shp"

        cl:fill{
            operation = "average",
            layer = layerName1,
            attribute = "polavg",
            clean = true,
            select = "Densde_Pop",
            output = polavgLayerName,
            area = true
        }

        local cs = CellularSpace{
            project = proj,
            layer = polavgLayerName
        }

        local map = Map{
            target = cs,
            select = "polmode",
            min = 0,
            max = 20000,
            slices = 8,
            color = {"red", "green"}
        }

--      unitTest:assertSnapshot(map, "polygons-mode.png")
avancinirodrigo commented 8 years ago

@pedro-andrade-inpe, please, check terralib tests after, because this operation works there.

avancinirodrigo commented 8 years ago

@pedro-andrade-inpe This error happens even after to update terralib release-5.2. It is associeted to data, if change the data, it woks. Try to this: municipiosAML_ok.shp and select POPULACAO_

pedro-andrade-inpe commented 8 years ago

Yes, it worked.The problem is that the strategy "average weighted by area" should only be used by an attribute that represents an average and therefore the only good example is the one above. Let's see if it works when we migrate to the newest version.

avancinirodrigo commented 8 years ago

It was fixed after last update that was associated to #1087. Please, check it.