Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError in livestock #40

Open
muc-martin opened this issue Apr 28, 2020 · 6 comments
Open

AttributeError in livestock #40

muc-martin opened this issue Apr 28, 2020 · 6 comments

Comments

@muc-martin
Copy link

I installed livestock and anaconda according to the following tutorial https://kongsgaard.eu/install-livestock.html. However, I cannot get the example files to work as I get the following error.

from livestock.hydrology import run_model
File "H:\Anaconda\envs\livestock_env\lib\site-packages\livestock\hydrology.py", line 22, in
from livestock import geometry as lg
File "H:\Anaconda\envs\livestock_env\lib\site-packages\livestock\geometry.py", line 261, in
-> shapefile._Shape:
AttributeError: module 'shapefile' has no attribute '_Shape'

@muc-martin
Copy link
Author

muc-martin commented Apr 28, 2020

Could the error be possibly due to pyshp being version 2.x instead 1.x?
After downgrading pyshp to 1.2.12 I get following error:

File "H:\Anaconda\envs\livestock_env\lib\site-packages\livestock\hydrology.py", line 606, in run_model
project, mesh_info = mesh_to_cells(project, mesh_paths)
File "H:\Anaconda\envs\livestock_env\lib\site-packages\livestock\hydrology.py", line 55, in mesh_to_cells
polygon.height, polygon.id)
File "H:\Anaconda\envs\livestock_env\lib\site-packages\cmf\geometry\geocell.py", line 48, in create_cell
c = project.NewCell(*center, area=polygon.area, with_surfacewater=with_surfacewater)
RuntimeError: Can't create cell #0. Area<=0.0

@ocni-dtu
Copy link
Member

Hi @HerrHansDampf
I haven't used Livestock since sometime in 2018. So it is very likely that the dependencies are not working.

@muc-martin
Copy link
Author

muc-martin commented Apr 29, 2020

Hi @ocni-dtu ,
do you by any chance still have the conda environment you worked with, so I can reproduce it?
Attached is my cmf folder as well as the debug info
cmf.zip
livestock_debug.log

Traceback.log

@ocni-dtu
Copy link
Member

ocni-dtu commented May 2, 2020

@Martin-TUM it says in the traceback that the area of the cell is less than 0. Can you check that your geometry is correct?

@ocni-dtu
Copy link
Member

ocni-dtu commented May 2, 2020

I unfortunately doesn't have the environment anymore.
Try to use a version of CMF before 1.2. It looks like they changed how the handled geotry in 1.2: https://github.com/philippkraft/cmf/releases

@muc-martin
Copy link
Author

I checked the geometry and it is a valid .obj file with all geometry included. Downgrading CMF to 1.1.1 (or lower) results in the following error:

Traceback (most recent call last):
File "C:\livestock\Examples1\CMF_Slope_v1\cmf\cmf_template.py", line 2, in
from livestock.hydrology import run_model
File "C:\Anaconda\envs\test1\lib\site-packages\livestock\hydrology.py", line 10, in
import cmf.geometry
ModuleNotFoundError: No module named 'cmf.geometry'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants