landlab / landlab

Landlab codebase, wiki, and tests
https://landlab.readthedocs.io/
MIT License
344 stars 328 forks source link

Reshaping #1947

Open ChristianMohr opened 1 week ago

ChristianMohr commented 1 week ago

Dear all, I am in the process of creating a Landlab model that combines different components, e.g. the ecohydrology and landslide components. While I had no problems using raster data provided to me, the model now has problems with the data I created myself. I created raster data via QGIS, which I exported as ASCII. All rasters have the same resolution, are correctly aligned and have the same spatial extent. Everything has been checked several times. My raster data includes rasters of plant functional types, vegetation cover, soil density, soil thickness, biomass and a DEM. When I load the data as ASCII files into Landlab, I get the following error message:

ValueError: unable to reshape array to field size (24011 != 24660)

I suspect that this problem stems from where the data is stored, i.e. nodes or cells, which leads to this form error. Do you have any idea how to solve this problem? Does anyone know this problem and have any solutions? Cheers and thanks in advance, Christian

mcflugen commented 1 week ago

@ChristianMohr I think your suspicion is correct. read_esri_ascii will try to add the data from your ASCII file to your grid's nodes. However, it sounds like your grid is sized such that the data should be placed at cells.

A couple ideas:

Your issue has reminded me that I had been working on enhancing the ESRI ASCII functionality a while ago but got distracted with something else and never finished the work. I'll get back on that and once I finish, I think it should make what you are trying to do easier.

ChristianMohr commented 1 week ago

@mcflugen Thanks for the prompt reply. Would you have some exemplary code sniplets for that?

mcflugen commented 1 week ago

Sure. Could you provide me with a minimal working example that reproduces the error? I can then modify it to, hopefully, fix your issue.

ChristianMohr commented 1 week ago

Hi @mcflugen . I solved the issue - more or less. The error occurred when using one specific DEM dataset. I tried another dataset and it worked. For now, this is ok. However, I will see why this is occurring only when using one specific dataset.