Beispiel #1
0
    def test_survey_land_with_ara(self):
        self.maxDiff = None
        # NLCD + ARA Histogram of Little Neshaminy HUC-12
        histogram = {
            'List(11, -2147483648)': 5,
            'List(11, 1)': 34,
            'List(21, -2147483648)': 31228,
            'List(21, 1)': 9330,
            'List(22, -2147483648)': 20546,
            'List(22, 1)': 4684,
            'List(23, -2147483648)': 9019,
            'List(23, 1)': 1957,
            'List(24, -2147483648)': 3303,
            'List(24, 1)': 490,
            'List(31, -2147483648)': 232,
            'List(31, 1)': 132,
            'List(41, -2147483648)': 11964,
            'List(41, 1)': 7254,
            'List(42, -2147483648)': 138,
            'List(42, 1)': 15,
            'List(43, -2147483648)': 212,
            'List(43, 1)': 117,
            'List(52, -2147483648)': 2346,
            'List(52, 1)': 963,
            'List(71, -2147483648)': 424,
            'List(71, 1)': 260,
            'List(81, -2147483648)': 6814,
            'List(81, 1)': 2108,
            'List(82, -2147483648)': 4713,
            'List(82, 1)': 1632,
            'List(90, -2147483648)': 184,
            'List(90, 1)': 3756,
            'List(95, -2147483648)': 7,
            'List(95, 1)': 105
        }
        expected = {
            "survey": {
                "categories": [
                    {
                        "active_river_area": 34,
                        "area": 39,
                        "code": "open_water",
                        "coverage": 0.00031458716484367437,
                        "nlcd": 11,
                        "type": "Open Water"
                    },
                    {
                        "active_river_area": 0,
                        "area": 0,
                        "code": "perennial_ice",
                        "coverage": 0.0,
                        "nlcd": 12,
                        "type": "Perennial Ice/Snow"
                    },
                    {
                        "active_river_area": 9330,
                        "area": 40558,
                        "code": "developed_open",
                        "coverage": 0.32715451876230117,
                        "nlcd": 21,
                        "type": "Developed, Open Space"
                    },
                    {
                        "active_river_area": 4684,
                        "area": 25230,
                        "code": "developed_low",
                        "coverage": 0.20351369664117705,
                        "nlcd": 22,
                        "type": "Developed, Low Intensity"
                    },
                    {
                        "active_river_area": 1957,
                        "area": 10976,
                        "code": "developed_med",
                        "coverage": 0.0885361210595941,
                        "nlcd": 23,
                        "type": "Developed, Medium Intensity"
                    },
                    {
                        "active_river_area": 490,
                        "area": 3793,
                        "code": "developed_high",
                        "coverage": 0.030595618365437355,
                        "nlcd": 24,
                        "type": "Developed, High Intensity"
                    },
                    {
                        "active_river_area": 132,
                        "area": 364,
                        "code": "barren_land",
                        "coverage": 0.0029361468718742943,
                        "nlcd": 31,
                        "type": "Barren Land (Rock/Sand/Clay)"
                    },
                    {
                        "active_river_area": 7254,
                        "area": 19218,
                        "code": "deciduous_forest",
                        "coverage": 0.1550188752298906,
                        "nlcd": 41,
                        "type": "Deciduous Forest"
                    },
                    {
                        "active_river_area": 15,
                        "area": 153,
                        "code": "evergreen_forest",
                        "coverage": 0.001234149646694415,
                        "nlcd": 42,
                        "type": "Evergreen Forest"
                    },
                    {
                        "active_river_area": 117,
                        "area": 329,
                        "code": "mixed_forest",
                        "coverage": 0.002653825057270997,
                        "nlcd": 43,
                        "type": "Mixed Forest"
                    },
                    {
                        "active_river_area": 963,
                        "area": 3309,
                        "code": "shrub",
                        "coverage": 0.026691510986351755,
                        "nlcd": 52,
                        "type": "Shrub/Scrub"
                    },
                    {
                        "active_river_area": 260,
                        "area": 684,
                        "code": "grassland",
                        "coverage": 0.005517374891104443,
                        "nlcd": 71,
                        "type": "Grassland/Herbaceous"
                    },
                    {
                        "active_river_area": 2108,
                        "area": 8922,
                        "code": "pasture",
                        "coverage": 0.07196786371116058,
                        "nlcd": 81,
                        "type": "Pasture/Hay"
                    },
                    {
                        "active_river_area": 1632,
                        "area": 6345,
                        "code": "cultivated_crops",
                        "coverage": 0.051180911818797796,
                        "nlcd": 82,
                        "type": "Cultivated Crops"
                    },
                    {
                        "active_river_area": 3756,
                        "area": 3940,
                        "code": "woody_wetlands",
                        "coverage": 0.0317813699867712,
                        "nlcd": 90,
                        "type": "Woody Wetlands"
                    },
                    {
                        "active_river_area": 105,
                        "area": 112,
                        "code": "herbaceous_wetlands",
                        "coverage": 0.000903429806730552,
                        "nlcd": 95,
                        "type": "Emergent Herbaceous Wetlands"
                    },
                ],
                "displayName": "Land Use/Cover 2011 (NLCD11)",
                "name": "land_2011_2011"
            }
        }

        actual = tasks.analyze_nlcd(histogram, nlcd_year='2011_2011')
        self.assertEqual(actual, expected)
Beispiel #2
0
    def test_survey_land_only(self):
        self.maxDiff = None
        # NLCD Histogram of Cave Creek-Arizona Canal Diversion Channel HUC-10
        histogram = {
            'List(0, -2147483648)': 95,
            'List(43, -2147483648)': 35,
            'List(71, -2147483648)': 3228,
            'List(42, -2147483648)': 5758,
            'List(11, -2147483648)': 279,
            'List(81, -2147483648)': 57,
            'List(82, -2147483648)': 682,
            'List(52, -2147483648)': 499636,
            'List(21, -2147483648)': 73992,
            'List(22, -2147483648)': 110043,
            'List(23, -2147483648)': 105894,
            'List(24, -2147483648)': 20719,
            'List(90, -2147483648)': 461,
            'List(31, -2147483648)': 25,
            'List(95, -2147483648)': 159
        }

        expected = {
            "survey": {
                "displayName": "Land Use/Cover 2011 (NLCD11)",
                "name": "land_2011_2011",
                "categories": [
                    {
                        "code": "open_water",
                        "active_river_area": None,
                        "area": 279,
                        "nlcd": 11,
                        "coverage": 0.0003398034012006387,
                        "type": "Open Water"
                    }, {
                        "code": "perennial_ice",
                        "active_river_area": None,
                        "area": 0,
                        "nlcd": 12,
                        "coverage": 0.0,
                        "type": "Perennial Ice/Snow"
                    }, {
                        "code": "developed_open",
                        "active_river_area": None,
                        "area": 73992,
                        "nlcd": 21,
                        "coverage": 0.09011732351841455,
                        "type": "Developed, Open Space"
                    }, {
                        "code": "developed_low",
                        "active_river_area": None,
                        "area": 110043,
                        "nlcd": 22,
                        "coverage": 0.13402503827355514,
                        "type": "Developed, Low Intensity"
                    }, {
                        "code": "developed_med",
                        "active_river_area": None,
                        "area": 105894,
                        "nlcd": 23,
                        "coverage": 0.12897183285570046,
                        "type": "Developed, Medium Intensity"
                    }, {
                        "code": "developed_high",
                        "active_river_area": None,
                        "area": 20719,
                        "nlcd": 24,
                        "coverage": 0.025234360822494743,
                        "type": "Developed, High Intensity"
                    }, {
                        "code": "barren_land",
                        "active_river_area": None,
                        "area": 25,
                        "nlcd": 31,
                        "coverage": 3.0448333440917446e-05,
                        "type": "Barren Land (Rock/Sand/Clay)"
                    }, {
                        "code": "deciduous_forest",
                        "active_river_area": None,
                        "area": 0,
                        "nlcd": 41,
                        "coverage": 0.0,
                        "type": "Deciduous Forest"
                    }, {
                        "code": "evergreen_forest",
                        "active_river_area": None,
                        "area": 5758,
                        "nlcd": 42,
                        "coverage": 0.007012860158112106,
                        "type": "Evergreen Forest"
                    }, {
                        "code": "mixed_forest",
                        "active_river_area": None,
                        "area": 35,
                        "nlcd": 43,
                        "coverage": 4.2627666817284424e-05,
                        "type": "Mixed Forest"
                    }, {
                        "code": "shrub",
                        "active_river_area": None,
                        "area": 499636,
                        "nlcd": 52,
                        "coverage": 0.6085233410834492,
                        "type": "Shrub/Scrub"
                    }, {
                        "code": "grassland",
                        "active_river_area": None,
                        "area": 3228,
                        "nlcd": 71,
                        "coverage": 0.00393148881389126,
                        "type": "Grassland/Herbaceous"
                    }, {
                        "code": "pasture",
                        "active_river_area": None,
                        "area": 57,
                        "nlcd": 81,
                        "coverage": 6.942220024529177e-05,
                        "type": "Pasture/Hay"
                    }, {
                        "code": "cultivated_crops",
                        "active_river_area": None,
                        "area": 682,
                        "nlcd": 82,
                        "coverage": 0.0008306305362682279,
                        "type": "Cultivated Crops"
                    }, {
                        "code": "woody_wetlands",
                        "active_river_area": None,
                        "area": 461,
                        "nlcd": 90,
                        "coverage": 0.0005614672686505177,
                        "type": "Woody Wetlands"
                    }, {
                        "code": "herbaceous_wetlands",
                        "active_river_area": None,
                        "area": 159,
                        "nlcd": 95,
                        "coverage": 0.00019365140068423496,
                        "type": "Emergent Herbaceous Wetlands"
                    }
                ]
            }
        }

        actual = tasks.analyze_nlcd(histogram, nlcd_year='2011_2011')
        self.assertEqual(actual, expected)