0

I am trying to associate presence points (where a bird was sighted) in a given month (e.g. December 2022) to the most recent fire that occurred in that area. I am planning on generating a raster (5km resolution (to match my other variables), so it's pretty low resolution) that I can use for MaxEnt modeling.

I have a multi-polygon shapefile that represents all historic fires (source: https://digital.atlas.gov.au/datasets/digitalatlas::historical-bushfire-boundaries-3/about). Each polygon on this shapefile represents a different fire, and some polygons overlap. I want to get rid of this overlap and prioritise the most recent fire dates.

For my December 2022 presence points, I filter the fire shapefile to only show me fires that started on or before December 2022, and then I try to do the following:

  1. Union (no overlay)
  2. Then Aggregate (group by $geometry, aggregate by the end date of the fire)
  3. Then Dissolve (by the end date of the fire)

However, I keep getting errors during the 'union'. When I try to run v.clean (with or without snap set to 0.1), it crashes QGIS.

The results of my attempts so far:

  • No step prior to running 'Union' --> I receive the error: 'Could not add feature with geometry type MultiLineString to layer of type MultiPolygon' --> buffering did not help. Multipart to singlepart did not help. Fixing geometries did not help. v.clean crashes.

  • Filtering out polygons of a certain size (only keep $area > 0.1) --> I receive the error: 'Difference failed' --> dissolve & then fix geometries did not help. v.clean crashes.

  • Filtering out polygons of a certain size (only keep areaha > 0) --> I receive the error: 'Intersect failed' --> dissolve & then fix geometries did not help. v.clean crashes.

Note: I am using QGIS and can also use R.

bonus: little diagram to demonstrate my ideal end result idealendresultremovalofoverlap

2
  • Does this help? gis.stackexchange.com/questions/479636/… If your question is really just about the original layer not being usable, even when run in v.clean, you might contact the providers. In v.clean what parameters are you using? I would include break, snap and bpol and try different snap tolerances.
    – John
    Commented Apr 7 at 10:26
  • @John thank you kindly for your response! Since my end goal is to have a raster layer, I was able to circumnavigate this issue and achieve my goal by using the terra package in R to rasterise this vector in order of maximum date values / minimum 'months since last fire' values. These two threads in particular helped me: stackoverflow.com/questions/78193977/… & stackoverflow.com/questions/77628082/…
    – Frek
    Commented Apr 13 at 5:22

1 Answer 1

0

I figured it out (thanks to the three threads I linked at the bottom of this post)! Since my end goal is to have a raster, I used the terra package in R to rasterise the overlapping polygons in priority of 'max' fire end date or 'min' months-since-fire value.

Steps I am taking:

  1. For each month, filtering the fire data in QGIS to only show the fires present before or during that month and then exporting that to a new layer/shapefile
  2. Using the field calculator in QGIS to calculate the number of months between the current month and the end date of each fire (polygon)*. Output is stored in a new column/field in my attribute table called 'monthssinc'.

*this doesn't need to be super accurate (i.e. I don't need decimals) so I'm just using this expression:

IF(((MODELYEAR * 12)+MODELMONTH) - ((year("new_end_da")*12) + month( "new_end_da" ))<0, 0, ((MODELYEAR * 12)+MODELMONTH) - ((year("new_end_da")*12) + month( "new_end_da" )))

MODELYEAR = year of the time period I'm currently looking at (e.g. 2022) MODELMONTH = month of the time period I'm currently looking at (e.g. 12 = december) "new_end_da" = field in my fire data that represents the end date of a fire

(e.g. so if I'm looking at Dec 2022, and a fire ended in Nov 2022, it will say '1' month since fire (no decimals). If a fire ended in Dec 2022 or later, it will say '0')

  1. Using this code in R to rasterise these overlapping polygons in order of minimum months since fire (i.e. newest fires (less months since last fire) should be prioritised over older fires), and to my desired resolution (5km = 5000m) in my equal area projection (GDA2020 Australia Albers).
    library(terra) 
    
    df <- "D:/WRE/R or GIS Outputs/Fire/TEST 4/monthssincefire202212.shp"    
    v <- vect(df)    
    r <- rast(v, res=5000)    
    x <- rasterize(v, r, "monthssinc", fun="min")    
    writeRaster(x, "D:/WRE/R or GIS Outputs/Fire/TEST 4/2022/monthssincefire202212.asc", overwrite=TRUE, NAflag=-9999)

(NAflag because I want the end result to be in an .asc file, and the terra package seems to use 'nan' to indicate NA which .asc doesn't like, so the NAflag turns it into a value outside of the range of values in my data (-9999))

  1. Then stretching it to the correct extent in QGIS to match the extent of my other raster layers and make sure the pixels align perfectly

These three threads helped me: Rasterising overlapping polygons: https://stackoverflow.com/questions/78193977/rasterize-overlapping-polygons-summarising-time-intervals

https://stackoverflow.com/questions/77628082/rasterize-overlapping-sf-objects-in-r-and-specify-which-values-to-use-for-pixels

Saving something as .asc requires you to flag the NA values: https://stackoverflow.com/questions/78189012/issues-with-saving-terra-asc-files-couldnt-find-data-values-in-ascii-grid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.