-
Notifications
You must be signed in to change notification settings - Fork 95
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
Utilise a function when rasterizing overlapping polygons #1041
Comments
Here is another approach (that I would not want to use with large datasets)
|
Thanks @rhijmans. Really interesting to see that work around and appreciate you adding to the rasterize function. I'm weaning some folks off long running vector work in a GIS and this will go a very long way. Regards |
Hello @rhijmans , Will there be a possibility to use a custom function to rasterize polygons in the future? A typical example would be calculating rasters of species richness from IUCN range maps, like the good old example of raster's rasterize: Switching from raster to terra in teaching practicals has made this task more complex to explain than in raster. It requires pre-processing of polygons which makes the process much slower in terra's rasterize than with raster's raterize. See for example how @damariszurell handled it by rasterizing all polygons individually here. In my own practicals I opted to union the polygons beforehand and use the sum function (an example in section #3.3 here). |
@Farewe: you can use
|
It is now possible to do:
|
Hi,
I am wondering if there is a way to apply a function to rasterization when working on overlapping polygons?
Context. I have a large multi-polygon dataset where each polygon represents the footprint of a bushfire and is attributed with the year it occurred. The dataset contains records back to 1937 for the whole of Western Australia. One task is to calculate the year since an area (or the whole State) last burnt.
I rasterize the vectors but I need to order them first by the year for this to create the correct output and the ordering imposes a time penalty when compared to something like
fasterize::fasterize
which can accept a function such as "max" which does the job.Here's a toy example.
What I am after can be created by:
or
Either of these methods when plotted produce the below which has the rasterized polygons layered in descending order, with 2023 (green) on top, followed by 2021 then 1990. With multi-polygon datasets in the order of 1000's + polygons
rasterize
is half as fast when ordering first and I note that a function can only be applied to a point vector dataset.Thanks
Bart
The text was updated successfully, but these errors were encountered: