uscuni / urban_taxonomy

Morphometric taxonomy of Central Europe
1 stars 1 forks source link

Notes on primary characters #2

Open martinfleis opened 3 months ago

martinfleis commented 3 months ago

Notes from verification of measured morphometric characters in the region of Prague. Explored using this notebook.

Plus - we still need to go through the list of characters and remove some of them.

martinfleis commented 3 months ago

Street profile is wrong. The values don't make sense.

Here is the reason. Measured using streets but assigned to edges. https://github.com/uscuni/urban_taxonomy/blob/4337d6f1d91c2ec73ee58c8485d1625de69f8092/core/generate_chars.py#L158-L161

I am not going to fix and re-run that as that part is undocumented (see the point 1 above).

martinfleis commented 3 months ago

Corners ssbCor are broken, squareness as well as it is related. I would also verify ssbCCM and ssbCCD as it also uses corner detection

The reason is that some corners are essentially "rounded" or messy otherwise. We need to call .remove_repeated_points() with some reasonable tolerance (e.g. 0.1) to eliminate them as part of pre-processing. The algorithm detecting corners works fine, we just have corners with milimeter size.

Repr:

import geopandas as gpd
import momepy

chars_dir = "/data/uscuni-ulce/processed_data/chars/"
region = 69300
buildings = gpd.read_parquet(f"{chars_dir}buildings/chars_{region}.parquet")

momepy.corners(buildings[buildings.index == 272715])
# 272715    53
# dtype: int64

momepy.corners(buildings[buildings.index == 272715].remove_repeated_points(0.1))
# 272715    6
# dtype: int64

buildings[buildings.index == 272715].plot()

Screenshot 2024-07-04 at 14 24 18

Note that this can result in invalid polygons and broken topology, so it has to happen as one of the first step of pre-processing to ensure the subsequent steps (e.g. geoplanar) will fix those.

edit: it seems that remove_repeated_points may lead to GEOSExceptions I am not able to circumvent. Some can be fixed by setting the precision grid, other can not. Let me explore if it would make sense to deal with this in the corner detection in momepy.

edit2: Couldn't figure out how to solve it on momepy side but found out that calling simplify(.1) solves the issue. The original corners look like this: Screenshot 2024-07-04 at 17 16 36

We may want to consider simplification either as part of preprocessing or solely as on-the-fly fix while calling corner-related functions.