How to use the momepy.AverageCharacter function in momepy

To help you get started, we’ve selected a few momepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github martinfleis / momepy / tests / test_dimension.py View on Github external
self.df_tessellation["area"] = area = self.df_tessellation.geometry.area
        self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
            self.df_tessellation,
            values="area",
            spatial_weights=spatial_weights,
            unique_id="uID",
            mode="mode",
        ).mode
        self.df_tessellation["mesh_array"] = mm.AverageCharacter(
            self.df_tessellation,
            values=area,
            spatial_weights=spatial_weights,
            unique_id="uID",
            mode="median",
        ).median
        self.df_tessellation["mesh_id"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(10, 90),
            unique_id="uID",
        ).mean
        self.df_tessellation["mesh_iq"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(25, 75),
            unique_id="uID",
        ).series
        all_m = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
github martinfleis / momepy / tests / test_dimension.py View on Github external
).mode
        self.df_tessellation["mesh_array"] = mm.AverageCharacter(
            self.df_tessellation,
            values=area,
            spatial_weights=spatial_weights,
            unique_id="uID",
            mode="median",
        ).median
        self.df_tessellation["mesh_id"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(10, 90),
            unique_id="uID",
        ).mean
        self.df_tessellation["mesh_iq"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(25, 75),
            unique_id="uID",
        ).series
        all_m = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
        )
        two = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
github martinfleis / momepy / tests / test_dimension.py View on Github external
).series
        all_m = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
        )
        two = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
            mode=["mean", "median"],
        )
        with pytest.raises(ValueError):
            self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
                self.df_tessellation,
                values="area",
                spatial_weights=spatial_weights,
                unique_id="uID",
                mode="nonexistent",
            )
        with pytest.raises(ValueError):
            self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
                self.df_tessellation,
                values="area",
                spatial_weights=spatial_weights,
                unique_id="uID",
                mode=["nonexistent", "mean"],
            )
        assert self.df_tessellation["mesh_ar"][0] == approx(249.503, rel=1e-3)
        assert self.df_tessellation["mesh_array"][0] == approx(2623.996, rel=1e-3)
github martinfleis / momepy / tests / test_dimension.py View on Github external
unique_id="uID",
                mode=["nonexistent", "mean"],
            )
        assert self.df_tessellation["mesh_ar"][0] == approx(249.503, rel=1e-3)
        assert self.df_tessellation["mesh_array"][0] == approx(2623.996, rel=1e-3)
        assert self.df_tessellation["mesh_id"][38] == approx(2250.224, rel=1e-3)
        assert self.df_tessellation["mesh_iq"][38] == approx(2118.609, rel=1e-3)
        assert all_m.mean[0] == approx(2922.957, rel=1e-3)
        assert all_m.median[0] == approx(2623.996, rel=1e-3)
        assert all_m.mode[0] == approx(249.503, rel=1e-3)
        assert all_m.series[0] == approx(2922.957, rel=1e-3)
        assert two.mean[0] == approx(2922.957, rel=1e-3)
        assert two.median[0] == approx(2623.996, rel=1e-3)
        sw_drop = sw_high(k=3, gdf=self.df_tessellation[2:], ids="uID")
        assert (
            mm.AverageCharacter(
                self.df_tessellation,
                values="area",
                spatial_weights=sw_drop,
                unique_id="uID",
            )
github martinfleis / momepy / tests / test_dimension.py View on Github external
def test_AverageCharacter(self):
        spatial_weights = sw_high(k=3, gdf=self.df_tessellation, ids="uID")
        self.df_tessellation["area"] = area = self.df_tessellation.geometry.area
        self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
            self.df_tessellation,
            values="area",
            spatial_weights=spatial_weights,
            unique_id="uID",
            mode="mode",
        ).mode
        self.df_tessellation["mesh_array"] = mm.AverageCharacter(
            self.df_tessellation,
            values=area,
            spatial_weights=spatial_weights,
            unique_id="uID",
            mode="median",
        ).median
        self.df_tessellation["mesh_id"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(10, 90),
            unique_id="uID",
        ).mean
        self.df_tessellation["mesh_iq"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
github martinfleis / momepy / tests / test_dimension.py View on Github external
def test_AverageCharacter(self):
        spatial_weights = sw_high(k=3, gdf=self.df_tessellation, ids="uID")
        self.df_tessellation["area"] = area = self.df_tessellation.geometry.area
        self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
            self.df_tessellation,
            values="area",
            spatial_weights=spatial_weights,
            unique_id="uID",
            mode="mode",
        ).mode
        self.df_tessellation["mesh_array"] = mm.AverageCharacter(
            self.df_tessellation,
            values=area,
            spatial_weights=spatial_weights,
            unique_id="uID",
            mode="median",
        ).median
        self.df_tessellation["mesh_id"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
github martinfleis / momepy / tests / test_dimension.py View on Github external
).median
        self.df_tessellation["mesh_id"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(10, 90),
            unique_id="uID",
        ).mean
        self.df_tessellation["mesh_iq"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(25, 75),
            unique_id="uID",
        ).series
        all_m = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
        )
        two = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
            mode=["mean", "median"],
        )
        with pytest.raises(ValueError):
            self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
                self.df_tessellation,
                values="area",
github martinfleis / momepy / tests / test_dimension.py View on Github external
unique_id="uID",
        ).mean
        self.df_tessellation["mesh_iq"] = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            rng=(25, 75),
            unique_id="uID",
        ).series
        all_m = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
        )
        two = mm.AverageCharacter(
            self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
            mode=["mean", "median"],
        )
        with pytest.raises(ValueError):
            self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
                self.df_tessellation,
                values="area",
                spatial_weights=spatial_weights,
                unique_id="uID",
                mode="nonexistent",
            )
        with pytest.raises(ValueError):
            self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
github martinfleis / momepy / tests / test_dimension.py View on Github external
self.df_tessellation,
            spatial_weights=spatial_weights,
            values="area",
            unique_id="uID",
            mode=["mean", "median"],
        )
        with pytest.raises(ValueError):
            self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
                self.df_tessellation,
                values="area",
                spatial_weights=spatial_weights,
                unique_id="uID",
                mode="nonexistent",
            )
        with pytest.raises(ValueError):
            self.df_tessellation["mesh_ar"] = mm.AverageCharacter(
                self.df_tessellation,
                values="area",
                spatial_weights=spatial_weights,
                unique_id="uID",
                mode=["nonexistent", "mean"],
            )
        assert self.df_tessellation["mesh_ar"][0] == approx(249.503, rel=1e-3)
        assert self.df_tessellation["mesh_array"][0] == approx(2623.996, rel=1e-3)
        assert self.df_tessellation["mesh_id"][38] == approx(2250.224, rel=1e-3)
        assert self.df_tessellation["mesh_iq"][38] == approx(2118.609, rel=1e-3)
        assert all_m.mean[0] == approx(2922.957, rel=1e-3)
        assert all_m.median[0] == approx(2623.996, rel=1e-3)
        assert all_m.mode[0] == approx(249.503, rel=1e-3)
        assert all_m.series[0] == approx(2922.957, rel=1e-3)
        assert two.mean[0] == approx(2922.957, rel=1e-3)
        assert two.median[0] == approx(2623.996, rel=1e-3)