pysal / momepy

Urban Morphology Measuring Toolkit
https://docs.momepy.org
BSD 3-Clause "New" or "Revised" License
495 stars 59 forks source link

Tessellation throw 'ValueError: need at least one array to concatenate" #539

Closed virgilxw closed 10 months ago

virgilxw commented 10 months ago

Describe the problem

Hi! I am tessellating using this script

limit = study_area
enclosures = momepy.enclosures(streets, limit=study_area.iloc[0]["geometry"], additional_barriers=[rail, rivers])
tessellation = momepy.Tessellation(buildings, unique_id='uID', enclosures=enclosures).tessellation

and an error gets thrown. i had tried this on two different computers with the same error.

Steps to reproduce

ValueError                                Traceback (most recent call last)
Cell In[27], [line 3](vscode-notebook-cell:?execution_count=27&line=3)
      [1](vscode-notebook-cell:?execution_count=27&line=1) limit = study_area
      [2](vscode-notebook-cell:?execution_count=27&line=2) enclosures = momepy.enclosures(streets, limit=study_area.iloc[0]["geometry"], additional_barriers=[rail, rivers])
----> [3](vscode-notebook-cell:?execution_count=27&line=3) tessellation = momepy.Tessellation(buildings, unique_id='uID', enclosures=enclosures).tessellation

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\momepy\elements.py:232](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:232), in Tessellation.__init__(self, gdf, unique_id, limit, shrink, segment, verbose, enclosures, enclosure_id, threshold, use_dask, n_chunks)
    [227](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:227)     gdf.geometry = gdf.geometry.translate(xoff=-centre_x, yoff=-centre_y)
    [228](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:228)     enclosures.geometry = enclosures.geometry.translate(
    [229](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:229)         xoff=-centre_x, yoff=-centre_y
    [230](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:230)     )
--> [232](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:232)     self.tessellation = self._enclosed_tessellation(
    [233](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:233)         gdf,
    [234](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:234)         enclosures,
    [235](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:235)         unique_id,
    [236](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:236)         threshold,
    [237](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:237)         use_dask,
    [238](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:238)         n_chunks,
    [239](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:239)     )
    [240](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:240) else:
    [241](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:241)     if isinstance(limit, gpd.GeoSeries | gpd.GeoDataFrame):

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\momepy\elements.py:488](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:488), in Tessellation._enclosed_tessellation(self, buildings, enclosures, unique_id, threshold, use_dask, n_chunks, **kwargs)
    [478](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:478)     bag = db.from_sequence(splits, npartitions=n_chunks)
    [479](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:479)     # generate enclosed tessellation using dask
    [480](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:480)     new = bag.map(
    [481](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:481)         self._tess,
    [482](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:482)         enclosures,
    [483](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:483)         buildings,
    [484](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:484)         inp,
    [485](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:485)         res,
    [486](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:486)         threshold,
    [487](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:487)         unique_id,
--> [488](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:488)     ).compute()
    [490](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:490) else:
    [491](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:491)     new = [
    [492](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:492)         self._tess(
    [493](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:493)             i,
   (...)
    [502](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:502)         for i in splits
    [503](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:503)     ]

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\dask\base.py:342](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:342), in DaskMethodsMixin.compute(self, **kwargs)
    [318](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:318) def compute(self, **kwargs):
    [319](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:319)     """Compute this dask collection
    [320](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:320) 
    [321](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:321)     This turns a lazy Dask collection into its in-memory equivalent.
   (...)
    [340](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:340)     dask.compute
    [341](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:341)     """
--> [342](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:342)     (result,) = compute(self, traverse=False, **kwargs)
    [343](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:343)     return result

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\dask\base.py:628](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:628), in compute(traverse, optimize_graph, scheduler, get, *args, **kwargs)
    [625](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:625)     postcomputes.append(x.__dask_postcompute__())
    [627](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:627) with shorten_traceback():
--> [628](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:628)     results = schedule(dsk, keys, **kwargs)
    [630](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/base.py:630) return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\dask\bag\core.py:1860](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:1860), in reify()
   [1858](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:1858) def reify(seq):
   [1859](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:1859)     if isinstance(seq, Iterator):
-> [1860](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:1860)         seq = list(seq)
   [1861](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:1861)     if len(seq) and isinstance(seq[0], Iterator):
   [1862](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:1862)         seq = list(map(list, seq))

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\dask\bag\core.py:2048](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:2048), in __next__()
   [2046](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:2046)     kwargs = dict(zip(self.kwarg_keys, vals[-self.nkws :]))
   [2047](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:2047)     return self.f(*args, **kwargs)
-> [2048](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/dask/bag/core.py:2048) return self.f(*vals)

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\momepy\elements.py:531](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:531), in _tess()
    [526](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:526) within = blg[
    [527](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:527)     shapely.area(shapely.intersection(blg.geometry.array, poly))
    [528](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:528)     > (shapely.area(blg.geometry.array) * threshold)
    [529](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:529) ].copy()
    [530](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:530) if len(within) > 1:
--> [531](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:531)     tess = self._morphological_tessellation(
    [532](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:532)         within,
    [533](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:533)         unique_id,
    [534](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:534)         poly,
    [535](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:535)         shrink=self.shrink,
    [536](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:536)         segment=self.segment,
    [537](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:537)         verbose=False,
    [538](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:538)         check=False,
    [539](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:539)     )
    [540](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:540)     tess[self.enclosure_id] = enclosure[self.enclosure_id].iloc[ix]
    [541](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:541)     return tess

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\momepy\elements.py:279](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:279), in _morphological_tessellation()
    [276](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:276) objects = objects.set_index(unique_id)
    [278](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:278) print("Generating input point array...") if verbose else None
--> [279](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:279) points, ids = self._dense_point_array(
    [280](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:280)     objects.geometry.array, distance=segment, index=objects.index
    [281](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:281) )
    [283](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:283) hull = shapely.convex_hull(limit)
    [284](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:284) bounds = shapely.bounds(hull)

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\momepy\elements.py:337](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:337), in _dense_point_array()
    [334](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:334)         points.append(shapely.get_coordinates(pts))
    [335](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:335)         ids += [ix] * len(pts)
--> [337](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:337) points = np.vstack(points)
    [339](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/momepy/elements.py:339) return points, ids

File [c:\Users\reube\anaconda3\envs\nbprocessor\Lib\site-packages\numpy\core\shape_base.py:289](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/numpy/core/shape_base.py:289), in vstack()
    [287](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/numpy/core/shape_base.py:287) if not isinstance(arrs, list):
    [288](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/numpy/core/shape_base.py:288)     arrs = [arrs]
--> [289](file:///C:/Users/reube/anaconda3/envs/nbprocessor/Lib/site-packages/numpy/core/shape_base.py:289) return _nx.concatenate(arrs, 0, dtype=dtype, casting=casting)

ValueError: need at least one array to concatenate

Versions of your packages

packages in environment at C:\Users\reube\anaconda3\envs\nbprocessor:

#

Name Version Build Channel

affine 2.4.0 pyhd8ed1ab_0 conda-forge ansiwrap 0.8.4 py_0 conda-forge attrs 23.2.0 pyh71513ae_0 conda-forge aws-c-auth 0.7.11 hcf9e330_1 conda-forge aws-c-cal 0.6.9 hd33547d_3 conda-forge aws-c-common 0.9.12 hcfcfb64_0 conda-forge aws-c-compression 0.2.17 hd33547d_8 conda-forge aws-c-event-stream 0.4.1 h875930a_2 conda-forge aws-c-http 0.8.0 ha1a3518_2 conda-forge aws-c-io 0.14.0 hf372335_1 conda-forge aws-c-mqtt 0.10.1 hda1dad8_0 conda-forge aws-c-s3 0.4.9 hef93162_0 conda-forge aws-c-sdkutils 0.1.13 hd33547d_1 conda-forge aws-checksums 0.1.17 hd33547d_7 conda-forge aws-crt-cpp 0.26.0 hed7b20b_8 conda-forge aws-sdk-cpp 1.11.210 h20b5662_10 conda-forge azure-core-cpp 1.11.0 h249a519_0 conda-forge azure-storage-blobs-cpp 12.10.0 h91493d7_0 conda-forge azure-storage-common-cpp 12.5.0 h91493d7_2 conda-forge beautifulsoup4 4.12.2 pyha770c72_0 conda-forge black 23.12.1 py311h1ea47a8_0 conda-forge blosc 1.21.5 hdccc3a2_0 conda-forge bokeh 3.3.3 pyhd8ed1ab_0 conda-forge branca 0.7.0 pyhd8ed1ab_1 conda-forge brotli 1.1.0 hcfcfb64_1 conda-forge brotli-bin 1.1.0 hcfcfb64_1 conda-forge brotli-python 1.1.0 py311h12c1d0e_1 conda-forge bzip2 1.0.8 hcfcfb64_5 conda-forge c-ares 1.25.0 hcfcfb64_0 conda-forge ca-certificates 2023.11.17 h56e8100_0 conda-forge cairo 1.18.0 h1fef639_0 conda-forge certifi 2023.11.17 pyhd8ed1ab_0 conda-forge cfitsio 4.3.1 h9b0cee5_0 conda-forge charset-normalizer 3.3.2 pyhd8ed1ab_0 conda-forge click 8.1.7 win_pyh7428d3b_0 conda-forge click-plugins 1.1.1 py_0 conda-forge cligj 0.7.2 pyhd8ed1ab_1 conda-forge cloudpickle 3.0.0 pyhd8ed1ab_0 conda-forge clustergram 0.8.0 pyhd8ed1ab_1 conda-forge colorama 0.4.6 pyhd8ed1ab_0 conda-forge colorcet 3.0.1 pyhd8ed1ab_0 conda-forge colorspacious 1.1.2 pyh24bf2e0_0 conda-forge contextily 1.5.0 pyhd8ed1ab_0 conda-forge contourpy 1.2.0 py311h005e61a_0 conda-forge cramjam 2.7.0 py311h9a9e57f_1 conda-forge cycler 0.12.1 pyhd8ed1ab_0 conda-forge cytoolz 0.12.2 py311ha68e1ae_1 conda-forge daal4py 2024.0.1 py311h12feb9d_0 conda-forge dal 2024.0.1 h66d3029_26 conda-forge dask 2023.12.1 pyhd8ed1ab_0 conda-forge dask-core 2023.12.1 pyhd8ed1ab_0 conda-forge distributed 2023.12.1 pyhd8ed1ab_0 conda-forge entrypoints 0.4 pyhd8ed1ab_0 conda-forge expat 2.5.0 h63175ca_1 conda-forge fastparquet 2023.10.1 py311h59ca53f_0 conda-forge fiona 1.9.5 py311hbcf8545_3 conda-forge folium 0.15.1 pyhd8ed1ab_0 conda-forge font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge font-ttf-inconsolata 3.000 h77eed37_0 conda-forge font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge font-ttf-ubuntu 0.83 h77eed37_1 conda-forge fontconfig 2.14.2 hbde0cde_0 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge fonttools 4.47.2 py311ha68e1ae_0 conda-forge freetype 2.12.1 hdaf720e_2 conda-forge freexl 2.0.0 h8276f4a_0 conda-forge fsspec 2023.12.2 pyhca7485f_0 conda-forge gdal 3.8.3 py311hff9a05f_0 conda-forge geographiclib 1.52 pyhd8ed1ab_0 conda-forge geopandas 0.14.2 pyhd8ed1ab_0 conda-forge geopandas-base 0.14.2 pyha770c72_0 conda-forge geopy 2.4.1 pyhd8ed1ab_0 conda-forge geos 3.12.1 h1537add_0 conda-forge geotiff 1.7.1 hbf5ca3a_15 conda-forge gettext 0.21.1 h5728263_0 conda-forge glasbey 0.2.0 pyhd8ed1ab_0 conda-forge glib 2.78.3 h12be248_0 conda-forge glib-tools 2.78.3 h12be248_0 conda-forge glpk 5.0 h8ffe710_0 conda-forge gst-plugins-base 1.22.8 h001b923_1 conda-forge gstreamer 1.22.8 hb4038d2_1 conda-forge hdf4 4.2.15 h5557f11_7 conda-forge hdf5 1.14.3 nompi_h73e8ff5_100 conda-forge icu 73.2 h63175ca_0 conda-forge idna 3.6 pyhd8ed1ab_0 conda-forge importlib-metadata 7.0.1 pyha770c72_0 conda-forge importlib_metadata 7.0.1 hd8ed1ab_0 conda-forge importlib_resources 6.1.1 pyhd8ed1ab_0 conda-forge inequality 1.0.1 pyhd8ed1ab_0 conda-forge intel-openmp 2023.2.0 h57928b3_50497 conda-forge jinja2 3.1.3 pyhd8ed1ab_0 conda-forge joblib 1.3.2 pyhd8ed1ab_0 conda-forge jsonschema 4.20.0 pyhd8ed1ab_0 conda-forge jsonschema-specifications 2023.12.1 pyhd8ed1ab_0 conda-forge jupyter_client 8.6.0 pyhd8ed1ab_0 conda-forge jupyter_core 5.7.1 py311h1ea47a8_0 conda-forge kealib 1.5.3 hd248416_0 conda-forge kiwisolver 1.4.5 py311h005e61a_1 conda-forge krb5 1.21.2 heb0366b_0 conda-forge lcms2 2.16 h67d730c_0 conda-forge lerc 4.0.0 h63175ca_0 conda-forge libabseil 20230802.1 cxx17_h63175ca_0 conda-forge libaec 1.1.2 h63175ca_1 conda-forge libarchive 3.7.2 h313118b_1 conda-forge libarrow 14.0.2 he5f67d5_2_cpu conda-forge libarrow-acero 14.0.2 h63175ca_2_cpu conda-forge libarrow-dataset 14.0.2 h63175ca_2_cpu conda-forge libarrow-flight 14.0.2 h53b1db0_2_cpu conda-forge libarrow-flight-sql 14.0.2 h78eab7c_2_cpu conda-forge libarrow-gandiva 14.0.2 hb2eaab1_2_cpu conda-forge libarrow-substrait 14.0.2 hd4c9904_2_cpu conda-forge libblas 3.9.0 20_win64_mkl conda-forge libboost-headers 1.84.0 h57928b3_0 conda-forge libbrotlicommon 1.1.0 hcfcfb64_1 conda-forge libbrotlidec 1.1.0 hcfcfb64_1 conda-forge libbrotlienc 1.1.0 hcfcfb64_1 conda-forge libcblas 3.9.0 20_win64_mkl conda-forge libclang 15.0.7 default_hde6756a_4 conda-forge libclang13 15.0.7 default_h85b4d89_4 conda-forge libcrc32c 1.1.2 h0e60522_0 conda-forge libcurl 8.5.0 hd5e4a3a_0 conda-forge libdeflate 1.19 hcfcfb64_0 conda-forge libevent 2.1.12 h3671451_1 conda-forge libexpat 2.5.0 h63175ca_1 conda-forge libffi 3.4.2 h8ffe710_5 conda-forge libgdal 3.8.3 h576f4c1_0 conda-forge libglib 2.78.3 h16e383f_0 conda-forge libgoogle-cloud 2.12.0 h39f2fc6_4 conda-forge libgrpc 1.59.3 h5bbd4a7_0 conda-forge libiconv 1.17 hcfcfb64_2 conda-forge libjpeg-turbo 3.0.0 hcfcfb64_1 conda-forge libkml 1.3.0 haf3e7a6_1018 conda-forge liblapack 3.9.0 20_win64_mkl conda-forge libnetcdf 4.9.2 nompi_h07c049d_113 conda-forge libogg 1.3.4 h8ffe710_1 conda-forge libparquet 14.0.2 h7ec3a38_2_cpu conda-forge libpng 1.6.39 h19919ed_0 conda-forge libpq 16.1 hdb24f17_7 conda-forge libprotobuf 4.24.4 hb8276f3_0 conda-forge libpysal 4.9.2 pyhd8ed1ab_1 conda-forge libre2-11 2023.06.02 h8c5ae5e_0 conda-forge librttopo 1.1.0 h94c4f80_15 conda-forge libsodium 1.0.18 h8d14728_1 conda-forge libspatialindex 1.9.3 h39d44d4_4 conda-forge libspatialite 5.1.0 hf2f0abc_4 conda-forge libsqlite 3.44.2 hcfcfb64_0 conda-forge libssh2 1.11.0 h7dfc565_0 conda-forge libthrift 0.19.0 ha2b3283_1 conda-forge libtiff 4.6.0 h6e2ebb7_2 conda-forge libutf8proc 2.8.0 h82a8f57_0 conda-forge libvorbis 1.3.7 h0e60522_0 conda-forge libwebp-base 1.3.2 hcfcfb64_0 conda-forge libxcb 1.15 hcd874cb_0 conda-forge libxml2 2.12.3 hc3477c8_0 conda-forge libzip 1.10.1 h1d365fa_3 conda-forge libzlib 1.2.13 hcfcfb64_5 conda-forge llvmlite 0.41.1 py311h5bc0dda_0 conda-forge locket 1.0.0 pyhd8ed1ab_0 conda-forge lz4 4.3.3 py311haddf500_0 conda-forge lz4-c 1.9.4 hcfcfb64_0 conda-forge lzo 2.10 he774522_1000 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge mapclassify 2.6.1 pyhd8ed1ab_0 conda-forge markupsafe 2.1.3 py311ha68e1ae_1 conda-forge matplotlib 3.8.2 py311h1ea47a8_0 conda-forge matplotlib-base 3.8.2 py311h6e989c2_0 conda-forge mercantile 1.2.1 pyhd8ed1ab_0 conda-forge minizip 4.0.4 h5bed578_0 conda-forge mkl 2023.2.0 h6a75c08_50497 conda-forge momepy 0.7.0 pyhd8ed1ab_0 conda-forge mpir 3.0.0 he025d50_1002 conda-forge msgpack-python 1.0.7 py311h005e61a_0 conda-forge msys2-conda-epoch 20160418 1 conda-forge munkres 1.1.4 pyh9f0ad1d_0 conda-forge mypy_extensions 1.0.0 pyha770c72_0 conda-forge nbclient 0.8.0 pyhd8ed1ab_0 conda-forge nbformat 5.9.2 pyhd8ed1ab_0 conda-forge networkx 3.2.1 pyhd8ed1ab_0 conda-forge numba 0.58.1 py311h2c0921f_0 conda-forge numpy 1.26.3 py311h0b4df5a_0 conda-forge openjpeg 2.5.0 h3d672ee_3 conda-forge openssl 3.2.0 hcfcfb64_1 conda-forge orc 1.9.2 hf0b6bd4_0 conda-forge osmnx 1.8.1 pyhd8ed1ab_0 conda-forge packaging 23.2 pyhd8ed1ab_0 conda-forge pandas 2.1.4 py311hf63dbb6_0 conda-forge papermill 2.4.0 pyhd8ed1ab_0 conda-forge param 2.0.1 pyhca7485f_0 conda-forge partd 1.4.1 pyhd8ed1ab_0 conda-forge pathspec 0.12.1 pyhd8ed1ab_0 conda-forge patsy 0.5.6 pyhd8ed1ab_0 conda-forge pcre2 10.42 h17e33f8_0 conda-forge pillow 10.2.0 py311h4dd8a23_0 conda-forge pip 23.3.2 pyhd8ed1ab_0 conda-forge pixman 0.43.0 h63175ca_0 conda-forge pkgutil-resolve-name 1.3.10 pyhd8ed1ab_1 conda-forge platformdirs 4.1.0 pyhd8ed1ab_0 conda-forge ply 3.11 py_1 conda-forge poppler 23.12.0 hc2f3c52_0 conda-forge poppler-data 0.4.12 hd8ed1ab_0 conda-forge postgresql 16.1 h1beaf6b_7 conda-forge proj 9.3.1 he13c7e8_0 conda-forge psutil 5.9.7 py311ha68e1ae_0 conda-forge pthread-stubs 0.4 hcd874cb_1001 conda-forge pyarrow 14.0.2 py311h6a6099b_2_cpu conda-forge pyarrow-hotfix 0.6 pyhd8ed1ab_0 conda-forge pyct 0.5.0 pyhd8ed1ab_0 conda-forge pyparsing 3.1.1 pyhd8ed1ab_0 conda-forge pyproj 3.6.1 py311h82130bc_5 conda-forge pyqt 5.15.9 py311h125bc19_5 conda-forge pyqt5-sip 12.12.2 py311h12c1d0e_5 conda-forge pysocks 1.7.1 pyh0701188_6 conda-forge python 3.11.7 h2628c8c_1_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-fastjsonschema 2.19.1 pyhd8ed1ab_0 conda-forge python-igraph 0.11.3 py311h9092318_1 conda-forge python-tzdata 2023.4 pyhd8ed1ab_0 conda-forge python_abi 3.11 4_cp311 conda-forge pytz 2023.3.post1 pyhd8ed1ab_0 conda-forge pywin32 306 py311h12c1d0e_2 conda-forge pyyaml 6.0.1 py311ha68e1ae_1 conda-forge pyzmq 25.1.2 py311h9250fbb_0 conda-forge qt-main 5.15.8 h9e85ed6_18 conda-forge rasterio 1.3.9 py311h02f6225_2 conda-forge re2 2023.06.02 hcbb65ff_0 conda-forge referencing 0.32.1 pyhd8ed1ab_0 conda-forge requests 2.31.0 pyhd8ed1ab_0 conda-forge rpds-py 0.16.2 py311hc37eb10_0 conda-forge rtree 1.1.0 py311hcacb13a_0 conda-forge scikit-learn 1.3.2 py311h142b183_2 conda-forge scikit-learn-intelex 2024.0.1 py311h1ea47a8_0 conda-forge scipy 1.11.4 py311h0b4df5a_0 conda-forge seaborn 0.13.1 hd8ed1ab_0 conda-forge seaborn-base 0.13.1 pyhd8ed1ab_0 conda-forge setuptools 69.0.3 pyhd8ed1ab_0 conda-forge shapely 2.0.2 py311h16bee0b_1 conda-forge sip 6.7.12 py311h12c1d0e_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.10 hfb803bf_0 conda-forge snuggs 1.4.7 py_0 conda-forge sortedcontainers 2.4.0 pyhd8ed1ab_0 conda-forge soupsieve 2.5 pyhd8ed1ab_1 conda-forge sqlite 3.44.2 hcfcfb64_0 conda-forge statsmodels 0.14.1 py311h59ca53f_0 conda-forge tbb 2021.7.0 h91493d7_0 conda-forge tblib 3.0.0 pyhd8ed1ab_0 conda-forge tenacity 8.2.3 pyhd8ed1ab_0 conda-forge texttable 1.7.0 pyhd8ed1ab_0 conda-forge textwrap3 0.9.2 py_0 conda-forge threadpoolctl 3.2.0 pyha21a80b_0 conda-forge tiledb 2.19.0 h8e52ccb_0 conda-forge tk 8.6.13 h5226925_1 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge tomli 2.0.1 pyhd8ed1ab_0 conda-forge toolz 0.12.0 pyhd8ed1ab_0 conda-forge tornado 6.3.3 py311ha68e1ae_1 conda-forge tqdm 4.66.1 pyhd8ed1ab_0 conda-forge traitlets 5.14.1 pyhd8ed1ab_0 conda-forge tzdata 2023d h0c530f3_0 conda-forge ucrt 10.0.22621.0 h57928b3_0 conda-forge uriparser 0.9.7 h1537add_1 conda-forge urllib3 2.1.0 pyhd8ed1ab_0 conda-forge vc 14.3 hcf57466_18 conda-forge vc14_runtime 14.38.33130 h82b7239_18 conda-forge vs2015_runtime 14.38.33130 hcb4865c_18 conda-forge wheel 0.42.0 pyhd8ed1ab_0 conda-forge win_inet_pton 1.1.0 pyhd8ed1ab_6 conda-forge xerces-c 3.2.5 h63175ca_0 conda-forge xorg-libxau 1.0.11 hcd874cb_0 conda-forge xorg-libxdmcp 1.1.3 hcd874cb_0 conda-forge xyzservices 2023.10.1 pyhd8ed1ab_0 conda-forge xz 5.2.6 h8d14728_0 conda-forge yaml 0.2.5 h8ffe710_2 conda-forge zeromq 4.3.5 h63175ca_0 conda-forge zict 3.0.0 pyhd8ed1ab_0 conda-forge zipp 3.17.0 pyhd8ed1ab_0 conda-forge zlib 1.2.13 hcfcfb64_5 conda-forge zstd 1.5.5 h12be248_0 conda-forge

Your operating system

No response

Additional context

No response

martinfleis commented 10 months ago

Which CRS are your GeoDataFrames in?

virgilxw commented 10 months ago
Name: OSGB36 / British National Grid Axis Info [cartesian]: - E[east]: Easting (metre) - N[north]: Northing (metre) Area of Use: - name: United Kingdom (UK) - offshore to boundary of UKCS within 49°45'N to 61°N and 9°W to 2°E; onshore Great Britain (England, Wales and Scotland). Isle of Man onshore. - bounds: (-9.01, 49.75, 2.01, 61.01) Coordinate Operation: - name: British National Grid - method: Transverse Mercator Datum: Ordnance Survey of Great Britain 1936 - Ellipsoid: Airy 1830 - Prime Meridian: Greenwich
jGaboardi commented 10 months ago

We'll need more information to troubleshoot properly, but from your code snippet above I have two initial Qs after Martin's

limit = study_area
enclosures = momepy.enclosures(streets, limit=study_area.iloc[0]["geometry"], additional_barriers=[rail, rivers])
tessellation = momepy.Tessellation(buildings, unique_id='uID', enclosures=enclosures).tessellation
  1. What is study_area? It seems to be a geopandas.GeoDataFrame. Can you share that data?
  2. In the momepy.enclosures() it seems like you are setting the limit to only the first geometry in study_area?
virgilxw commented 10 months ago

it's uploading currently but here's the dataset: https://strath-my.sharepoint.com/:f:/g/personal/reuben_xianwei_wang_strath_ac_uk/EhOaE5kYzGJBqAL01vrpmQgB-69YWWKQ93NseXfdh_F78g?e=1DPBAg

the study_area is the land polygon taken from openstreetmap subtracted by water polygons, the limit is just taking the first entry of the geodatframe with the study_area I think but am I using it wrong?

martinfleis commented 10 months ago

Your data needs some cleaning prior using it in morphometric analysis. See

>>> buildings.area.sort_values().head(10)
1518630    0.00150
363559     0.00650
1744216    0.00750
1815046    0.01250
1532250    0.01300
3449993    0.01805
423824     0.01875
3820240    0.02000
3492165    0.02005
1143626    0.03125
dtype: float64

No real building is this small and these are what is causing the issue. I suggest dropping every polygon smaller than a certain threshold (10, 20 or 30sqm) or figuring out another way how to remove these.

virgilxw commented 10 months ago

roger!