HQ model - 'NoneType' object has no attribute 'SetGeoTransform'

Hello,
I work on the HQ model. I gave it a try with one single threat, but it did not run well and I cant get the output results about habitat quality and degradation. The error message was saying ‘NoneType’ object has no attribute ‘SetGeoTransform’. I have already looked at some posts on this forum and checked some of previous recommendations (such as using a projected coordinate system) but still it does not work. I attach the files used in the model and log file FYI, and any support would be highly appreciated!

InVEST-Habitat-Quality-log-2021-03-25–17_49_56.txt (7.4 KB) [road_c.tif|attachment]

Hi @melbroquet,

Welcome to the forums and thanks for trying InVEST. The error might be related to:
2021-03-25 17:51:11,976 utils._log_gdal_errors(80) ERROR [errno 6] D:/NOVA/U7.MODSIG/Final project/Data/Habitat Quality\intermediate\kernels\kernel_road_c.tif: File too large regarding tile size. This would result in a file with tile arrays larger than 2GB

Could you say how big the roads raster is and what resolution it is? If you wanted to share a link to your zipped data I’d be happy to take a quick look.

Cheers,

Doug

Dear Doug,
A huge thank for your very prompt response! I really try to find answers by myself but my search skills/understanding get exhausted :slight_smile:
Attached is the road_c.tif I’ve used, any advice is most welcome,
Best
Mélanie

road_c.tif (290 KB)

Hi @melbroquet ,

Thanks for sharing that raster. It looks like the projection is set as:

EPSG:5641 SIRGAS 2000 / Brazil Mercator

But when looking at the raster in QGIS I noticed it had:

Origin -59.7142,-14.1364
Pixel Size 0.02299999999999998573,-0.0229999999999999892
Extent -59.7141998492435988,-22.3013685274355993 : -53.1361998492436030,-14.1363685274356037

Which made me suspect it was actually projected in Lat / Long. So I re-projected / warped the raster you sent and have attached it here

updated_road_c.tif (196.6 KB)

Please try using this raster instead, which should no properly be projected in meters.

Cheers,

Doug

1 Like

Hey Doug,
Thanks for sharing the new layer. If I understand well, it was a problem with projection which was not done in meters but in degrees, right?
I ran the model again, but still it does not run properly (please see attach the last log file, a bit different than the previous one)…
Looking forward to your recommendations, with my thanks,
Mélanie

InVEST-Habitat-Quality-log-2021-03-26–09_43_37.txt (7.79 KB)

Hi @melbroquet ,

That’s right, I don’t think the projection was properly set on roads_c.tif. Since it was showing degrees for spatial properties I assumed it was EPSG:4326 WGS 84 when I projected it to EPSG:5641 - SIRGAS 2000 / Brazil Mercator.

Could you make sure that your landcover raster is projected properly as well? If you’d like to zip up all your inputs and share them I would be happy to try and reproduce the problem on my end. Currently the issue is related to:
2021-03-25 17:51:11,976 habitat_quality._create_decay_kernel(859) DEBUG Max distance in pixels: 18553248.465545632
So I think something is still a little off with the input projections. A max distance of 5 KM, as is set in your table, shouldn’t be creating a kernel with this many pixels.

Cheers,

Doug

Hi
The LULC is actually too voluminous (700,000KB); and looking at the different files, i can see that there are mix in coordinates and extent… I think as messed up the things by not setting rightly CRS and extent for map and layers…
As I cannot sent the LULC I was using, and as I will have to repeat the procedure for many layers and potentially many works, would you be kind enough to detail the procedure to set common projections and extent to all raster and vector layers that may come with different CRS and extents?
Sorry for inconvenience :frowning:
Mélanie

Hi again,
I redo everything from scratch based on your comments (that something went wrong with coordinates and file size). How could I send you the files?
I project to espg3857, and use JPEG compression when exporting the TIFF (which reduced significantly the size of the LULC while keeping the classes).
But again and again, same error messages… I have a deadline in one few days and still at point zero :weary:
Do you think that a full disk may generate this error message?
Best
Mélanie

Hi @melbroquet,

If you zip up your files you could share them via Google Drive, Dropbox, or any other file sharing service you use.

would you be kind enough to detail the procedure to set common projections and extent to all raster and vector layers that may come with different CRS and extents?

I used QGIS to re-project (warp) the raster you sent. I did this by using the top menu bar to Raster -> Projections -> Warp. It brings up a window like this:


The yellow mark is what I presumed the actual projection to be and the green mark is what I thought the intended projection was to be.

What is the resolution of the LULC raster? What are the pixel sizes?

Cheers,

Doug

Hey Doug,
Sending files through WeTransfer…
Regarding LULC, please find info abour cell size below
I feel terribly sorry for being so lost, but so many hours doing, redoing, reredoing = dead brain!
Best :slightly_smiling_face:

Hi @melbroquet ,

That cell size looks problematic and like it still is projected in Lat / Long or degrees. I would expect the cell size to be 30m , 30m for a raster projected in meters. My email is ddenu@stanford.edu if that helps for sharing files.

Getting that LULC raster to be projected properly is probably the missing piece here.

Doug

Hi @melbroquet,

I was able to successfully run the model by reprojecting your LULC raster in the same way that I did the threat raster. I have uploaded the results and the reprojected LULC raster to a zip file via Google Drive.

https://drive.google.com/file/d/1qkBvGRP9gzzL9VTOKvUxA2MmzqdWP-Tg/view?usp=sharing

Let me know if you have any trouble accessing it.

Please note that I just reprojected the data from standard EPSG 4326. I don’t in fact know that this is what the data CRS actually was. Depending on where you got the data it would be worth figuring out what the data CRS was supposed to be, as a better reprojection might be available.

Cheers,

Doug

Hey, looking forward to look at that! just sent you a request to access the files

Okay, access granted.

Hello!
Just to tell you that now that I have clarified the procedure, thanks to your iputs, I am able to run the model without any problem (so far!).
I have additional questions regarding to the inputs - outputs:

  1. If agriculture is a threat, is it correct to get agricultural data to extract data from the current land use raster and to make a new raster “agriculture”, that will be used as a threat raster?
  2. It is not clear to me how we must interpret the outputs maps depending on the scenario chosen:
  • current land use only
  • current land use + baseline
  • current land use + future
  • current land use + baseline + future
  1. What is accoridngto you the most interesting scenario?
  2. If I use baseline and/or future land use maps, I should have set of threat rasters associated to each time (one group for baseline, one for current, oen for future). However, I was able to run baseline + current model with only threat maps for current (but not for baseline) and it works. If I dont include these set of threat rasters, what is the consequence on the outputs? Is it stil relevant to run the models witrh a baseline and/or future maps?
  3. If I use baselin/andor future land use maps, how to get the data for the threat rasters? Is the method I mentioned in point 1 would be appropriate (reclassify baseline map in differnet threat rasters for agricture, mining, etc for instance?)

Would be enlighting to have your views on these different questions, and anyway thanks again for your prompt and effective support :slightly_smiling_face:
Mélanie

Great to hear Mélanie,

  1. If agriculture is a threat, is it correct to get agricultural data to extract data from the current land use raster and to make a new raster “agriculture”, that will be used as a threat raster?

That sounds like the right process to me.

  1. It is not clear to me how we must interpret the outputs maps depending on the scenario chosen:

Current and future land use scenarios will allow comparison between current and future habitat quality and degradation. Adding in Baseline LULC will compute Habitat Rarity maps for current and future scenarios. Documentation for Habitat Rarity.

  1. What is accoridngto you the most interesting scenario?

I won’t be much help with this question, I’m just a software engineer! This will really depend on your study area and the research questions you’re trying to answer. If by chance you are referring to question number 2, then I think just comparing a current and future landscape and threats is a great place to start.

  1. If I use baseline and/or future land use maps, I should have set of threat rasters associated to each time (one group for baseline, one for current, oen for future). However, I was able to run baseline + current model with only threat maps for current (but not for baseline) and it works. If I dont include these set of threat rasters, what is the consequence on the outputs? Is it stil relevant to run the models witrh a baseline and/or future maps?

Baseline does NOT require associated threat rasters. If no threat rasters are found for Baseline then only Rarity outputs will be generated. If threat rasters are found for Baseline, then Habitat Quality and Degradation are also computed for the Baseline LULC. A future scenario LULC and associated threat rasters will allow you to compare against a current scenario. If Baseline is included then Rarity will be computed for current and future scenarios.

  1. If I use baselin/andor future land use maps, how to get the data for the threat rasters? Is the method I mentioned in point 1 would be appropriate (reclassify baseline map in differnet threat rasters for agricture, mining, etc for instance?)

I think that makes sense. If you have a baseline and future LULC maps then generating the threat rasters from them seems reasonable. Please refer to the Data Needs section of the Users’ Guide for information on Baseline LULC codes.

Cheers,

Doug

Great! Thanks +++ for your time and hope that I could complete the process without more trouble!

Mél

Télécharger Outlook pour Android

Hey Doug,
I now run the model with different threat rasters, all bout the same size.
As the process is very very slow (will take at least hours to complete!), I wonder if there is a limitation in the number of threat rasters.
Also, I notice that the process seems slow when I deal with raster reclassed from land use map (whereas it seems going well wtih raster build from shp) - does it make sense? Is there a way to imrove that?
Thanks
Mél

Hi @melbroquet ,

For the HQ model the time consuming part will be calculating decay of a threat over the raster. So, larger MAX_DIST threats will take longer as will rasters with higher resolution. Because the decay is a gaussian convolution under the hood we normally recommend a 30m x 30m resolution or larger resolution for the threat rasters. So if your LULC is at a finer resolution and that is what you created the new threat rasters from, that could be causing the slower progress. If this is the case you might try upsampling the threat rasters to see how that improves performance.

Cheers,

Doug