# Habitat Quality: An error occured while writing a dirty block

**URL:** <https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418>\
**Category:** Software Support\
**Tags:** habitat-quality\
**Created:** [August 27, 2019, 1:45am UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418 "2019-08-27T01:45:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [August 27, 2019, 1:45am UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/1 "2019-08-27T01:45:02Z")

</div>

Hello! I’ve been running the HQ model and this error appears thousands of times: An error occured while writing a dirty block. I’m attaching the log. I have no idea what this error means or how I can fix it.  
Thank you so much in advance for your help.

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [August 30, 2019, 9:34pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/2 "2019-08-30T21:34:08Z")

</div>

Hi @Lara, could you attach the logfile from your model run so we can take a look? It will help a lot with debugging.

Thanks,  
Jame

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [August 30, 2019, 9:51pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/4 "2019-08-30T21:51:26Z")

</div>

Apparently I can’t upload the file, I don’t know why, I have tried several times and it’s not working… How can I deliver the log to you?

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [August 30, 2019, 11:14pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/5 "2019-08-30T23:14:23Z")

</div>

Curious! If you could email it to me (jdouglass@stanford.edu, and please be sure to include a link to this post for reference), I’ll be able to take a look.

James

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [September 3, 2019, 4:58pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/6 "2019-09-03T16:58:41Z")

</div>

@Lara, thanks for sending your logfile! So, based on the logfile, there are a couple things I’d suggest:

The first thing I notice is:

```auto
08/26/2019 18:18:53 root INFO Running InVEST version "3.3.3"

```

InVEST 3.3.3 is pretty old and it’s quite likely that we’ve fixed a variety of issues with the model (possibly even including this one). If possible, I’d strongly suggest upgrading to the latest development version ([download here](https://storage.googleapis.com/releases.naturalcapitalproject.org/invest/3.6.0.post525%2Bh31b10cfee0d4/InVEST_3.6.0.post525%2Bh31b10cfee0d4_x86_Setup.exe)).

There’s another line, though, that I think is related to the raster creation error messages:

```auto
08/26/2019 18:18:58 natcap.invest.habitat_quality DEBUG Max distance in pixels: 17500000.000000

```

That’s a lot of pixels! So many, in fact, that it looks like it’s overflowed the integer counter that GDAL is using internally. Could you make sure that the threat rasters are all projected in meters and that they all have the same projection as the lulc raster? I’ve seen similarly large pixel distances appear when the threat rasters are unprojected.

Let us know how this goes!  
James

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [September 3, 2019, 6:05pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/7 "2019-09-03T18:05:45Z")

</div>

Ach, I just realized I attached the wrong development build in my last post … could you try this development build instead?

Download link: [https://storage.googleapis.com/releases.naturalcapitalproject.org/invest/3.7.0.post366+hc94dfedffddd/InVEST\_3.7.0.post366+hc94dfedffddd\_x86\_Setup.exe](https://storage.googleapis.com/releases.naturalcapitalproject.org/invest/3.7.0.post366+hc94dfedffddd/InVEST_3.7.0.post366+hc94dfedffddd_x86_Setup.exe)

Thanks, and sorry about the confusion!  
James

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [September 4, 2019, 9:51pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/8 "2019-09-04T21:51:55Z")

</div>

Hi! So I just updated my InVEST version and all my theat rasters have the same projection. Now I have a new error…[InVEST-Habitat-Quality-log-2019-09-04–14\_41\_04.txt](https://community.naturalcapitalalliance.org/uploads/short-url/gxoUamHulFrWJTFeVmUFWMs6Cgl.txt) (1.5 KB)

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [September 4, 2019, 10:07pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/9 "2019-09-04T22:07:14Z")

</div>

Hmm … another user just posted this same error. I suspect it has to do with the formatting of your sensitivity table, so could you attach your sensitivity table so we can take a look?

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [September 4, 2019, 10:50pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/10 "2019-09-04T22:50:41Z")

</div>

Sure! Here it is:  
[sensitivity.csv](https://community.naturalcapitalalliance.org/uploads/short-url/trPMwNkIWmBiyiLivTMSDaD8vB6.csv) (495 Bytes)

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [September 5, 2019, 10:13pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/11 "2019-09-05T22:13:54Z")

</div>

Ah! Ok, that’s really helpful … thank you! It turns out that there’s a bug early on in Habitat Quality that’s causing this error (due to an assumption it makes about the structure of the sensitivity table). Could you try this development build and make sure it runs through for you?

[https://storage.googleapis.com/natcap-dev-build-artifacts/invest/jdouglass/3.7.0.post367+h11eff01a4d13/InVEST\_3.7.0.post367+h11eff01a4d13\_x86\_Setup.exe](https://storage.googleapis.com/natcap-dev-build-artifacts/invest/jdouglass/3.7.0.post367+h11eff01a4d13/InVEST_3.7.0.post367+h11eff01a4d13_x86_Setup.exe)

Thanks!

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [October 8, 2019, 12:34am UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/12 "2019-10-08T00:34:40Z")

</div>

Hello! I keep having troubles with the Habitt Quality model… I’m using the latest version you recomended (3.7.0), and all my threat files are in meters and have the same projection as my LULC raster. I’m attaching the log: [InVEST-Habitat-Quality-log-2019-10-07–17\_25\_03.txt](https://community.naturalcapitalalliance.org/uploads/short-url/ckNlWFoKRHM0pih8yUKhvVp17e8.txt) (2.4 KB)

Thank you!

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [October 8, 2019, 12:39am UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/13 "2019-10-08T00:39:42Z")

</div>

Hi @Lara,

Based on the error, it looks like there’s an issue in the quoting of fields in your threats CSV. The issue might become clearer in a text editor such as notepad than it will be in excel. If it isn’t clear there, could you attache your table so we can take a look?

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [October 8, 2019, 12:43am UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/14 "2019-10-08T00:43:04Z")

</div>

I just looked at it in notepad but can’t find anything abnormal. Here goes the excel file: [Threats.csv](https://community.naturalcapitalalliance.org/uploads/short-url/8dedPcWbIVtpRL5bfemv8lpzj3x.csv) (206 Bytes)

Thanks for your help

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [October 8, 2019, 5:15pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/15 "2019-10-08T17:15:57Z")

</div>

Looks like the table had an issue with how it was saved: I was able to reproduce the issue by re-exporting the table from excel as the type “CSV (Macintosh)”. The attached table ([Threats-export.csv](https://community.naturalcapitalalliance.org/uploads/short-url/tz7DMbdifAkowp8UFg9AfRQly2t.csv) (213 Bytes)) was created with type “CSV MS-DOS” and should work just fine.

The type used when exporting from excel matters a lot, so please do be sure to use either the normal “CSV (Comma delimited)” type or “CSV (MS-DOS)” type!

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [October 8, 2019, 6:32pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/16 "2019-10-08T18:32:31Z")

</div>

Ok, sorry about that… I already checked the table’s format… Now I’m having a different error related to a threat raster, the weird thing is that there is no raster with that name (Asent\_c), the actual name is just Asent. I already checked that the names of the threat rasters match the names on both csv tables, and also changed the working directory three times and transfered all the input data again to new folders, and the same error keeps appearing… [InVEST-Habitat-Quality-log-2019-10-08–11\_19\_57.txt](https://community.naturalcapitalalliance.org/uploads/short-url/uILfsPwZIemwRzmWmbvKKSRnp6U.txt) (2.0 KB)

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [October 8, 2019, 8:38pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/17 "2019-10-08T20:38:18Z")

</div>

So, I converted all my threat files to raster datasets (TIFF), they all have the same projection as well as the LULC raster (which is also a TIFF), and now I’m having this error: Bounding boxes do not intersect. I was exploring the forum for some information and found another post with this subject, to work this around all they did was change the projection, but I already have everything in the same projection. What could this be? [InVEST-Habitat-Quality-log-2019-10-08–13\_37\_13.txt](https://community.naturalcapitalalliance.org/uploads/short-url/3LejwpMsSBmTWfjB6qh14apIUv5.txt) (2.7 KB)

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [October 9, 2019, 5:47pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/18 "2019-10-09T17:47:51Z")

</div>

> [@Lara](#):
>
> the weird thing is that there is no raster with that name (Asent\_c), the actual name is just Asent

This error is happening because the model expects various threats to be available for the various scenarios. So, the `Asent` threat will need a corresponding `Asent_c` if evaluating the current scenario, `Asent_b` for the baseline, `Asent_f` for the future. The details for how threats need to be named is described in the [HQ User’s Guide chapter](http://releases.naturalcapitalproject.org/invest-userguide/latest/habitat_quality.html#data-needs) under “Raster naming requirements”.

> [@Lara](#):
>
> So, I converted all my threat files to raster datasets (TIFF), they all have the same projection as well as the LULC raster (which is also a TIFF), and now I’m having this error: Bounding boxes do not intersect. I was exploring the forum for some information and found another post with this subject, to work this around all they did was change the projection, but I already have everything in the same projection. What could this be?

Honestly, it’s tough to say for certain without taking a close look at all of your inputs. Certainly mismatched projections are a usual culprit, but they do also all need to overlap as well if they are in the same coordinate system and projection. It is _also_ possible that these inputs are projected into a coordinate system that GDAL doesn’t handle well. If this is still an issue, could you share these inputs with us so we can take a closer look?

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [October 9, 2019, 6:42pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/19 "2019-10-09T18:42:33Z")

</div>

Ok, I just send you all my inputs to your email. Thanks again.

---

<div class="post-metadata">

**Author:** ![Lara](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/lara/32/375_2.png) [@Lara](https://community.naturalcapitalalliance.org/u/Lara)\
**Post date:** [October 9, 2019, 6:52pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/20 "2019-10-09T18:52:53Z")

</div>

The email rebounded. Do you have another email address?

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [October 9, 2019, 7:06pm UTC](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418/21 "2019-10-09T19:06:39Z")

</div>

It might be easiest to upload them to a filesharing service like dropbox or google drive … Stanford’s email does bounce emails with attachments that are too large.

[Next page](https://community.naturalcapitalalliance.org/t/habitat-quality-an-error-occured-while-writing-a-dirty-block/418.md?page=2)
