Closed connor-french closed 4 months ago
Trying to run plot_landscape for an example in the documentation and get this error:
plot_landscape
ValueError Traceback (most recent call last) File /Users/connorfrench/Dropbox/Old_Mac/software-dev/spaceprime/docs/index.qmd:1 ----> 1 sp.plot_landscape(demo, r, 1, basemap=False)
File ~/Dropbox/Old_Mac/software-dev/spaceprime/spaceprime/plot.py:207, in plot_landscape(demo, raster, timestep, cmap, legend, basemap) 205 gdf = gpd.GeoDataFrame({"dummy": dummy_vals, "geometry": geometry}, crs=raster.crs) 206 # add the deme sizes to this gdf --> 207 gdf["deme_size"] = demes_matrix.flatten() 209 # use gdf.plot to plot the demes matrix 210 plot = gdf.plot(column="deme_size", cmap=cmap, legend=legend)
File ~/miniforge3/envs/spaceprime/lib/python3.11/site-packages/geopandas/geodataframe.py:1525, in GeoDataFrame.setitem(self, key, value) 1520 except TypeError: 1521 warnings.warn( 1522 "Geometry column does not contain geometry.", 1523 stacklevel=2, 1524 ) -> 1525 super().setitem(key, value)
File ~/miniforge3/envs/spaceprime/lib/python3.11/site-packages/pandas/core/frame.py:4311, in DataFrame.setitem(self, key, value) 4308 self._setitem_array([key], value) 4309 else: 4310 # set column -> 4311 self._set_item(key, value) ... 576 "does not match length of index " 577 f"({len(index)})" 578 )
ValueError: Length of values (3480) does not match length of index (1750)
Paste the command(s) you ran and the output. If there was a crash, please include the traceback here.
Description
Trying to run
plot_landscape
for an example in the documentation and get this error:ValueError Traceback (most recent call last) File /Users/connorfrench/Dropbox/Old_Mac/software-dev/spaceprime/docs/index.qmd:1 ----> 1 sp.plot_landscape(demo, r, 1, basemap=False)
File ~/Dropbox/Old_Mac/software-dev/spaceprime/spaceprime/plot.py:207, in plot_landscape(demo, raster, timestep, cmap, legend, basemap) 205 gdf = gpd.GeoDataFrame({"dummy": dummy_vals, "geometry": geometry}, crs=raster.crs) 206 # add the deme sizes to this gdf --> 207 gdf["deme_size"] = demes_matrix.flatten() 209 # use gdf.plot to plot the demes matrix 210 plot = gdf.plot(column="deme_size", cmap=cmap, legend=legend)
File ~/miniforge3/envs/spaceprime/lib/python3.11/site-packages/geopandas/geodataframe.py:1525, in GeoDataFrame.setitem(self, key, value) 1520 except TypeError: 1521 warnings.warn( 1522 "Geometry column does not contain geometry.", 1523 stacklevel=2, 1524 ) -> 1525 super().setitem(key, value)
File ~/miniforge3/envs/spaceprime/lib/python3.11/site-packages/pandas/core/frame.py:4311, in DataFrame.setitem(self, key, value) 4308 self._setitem_array([key], value) 4309 else: 4310 # set column -> 4311 self._set_item(key, value) ... 576 "does not match length of index " 577 f"({len(index)})" 578 )
ValueError: Length of values (3480) does not match length of index (1750)
What I Did