Skip to content
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

Support for raster::RasterLayer #5

Open
michelk opened this issue Nov 30, 2020 · 4 comments
Open

Support for raster::RasterLayer #5

michelk opened this issue Nov 30, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@michelk
Copy link
Contributor

michelk commented Nov 30, 2020

This is a follow up of r-lib/isoband#17, where I wanted to smooth contour lines of a digital terrain model. Since your smooth function operates on the polygons separately, the resulting data sets contain little overlaps and gaps.

Does it make sens in your opinion to add raster support in the smooth R-package?

@mstrimas
Copy link
Owner

Smoothing isolines is an interesting use case. As you've already discovered, smoothr uses a very simple approach to smoothing where each feature is treated independently, which means it doesn't preserve the relationships between features. In addition to not being suitable for isolines, this also means smoothr doesn't work on things like country borders where you'd want to preserve the boundary between countries. It would be amazing if the package did preserve topological relationships, however, implementing that is way beyond what I'm capable of. I've added a warning to the package README that smoothing doesn't preserve topological relationships so shouldn't be used on isolines.

Regarding your specific question in this issue about adding raster smoothing to the package. The intention of the package was to be for vector data, but I suppose I'm potentially open to adding a smooth_raster() method. I have no experience smoothing raster data though, so I'd need to understand what the best approach for smoothing is. I see in the linked issue you disaggregate the raster then apply a moving window filter via focal(), is that generally considered the best practice for this sort of task?

@michelk
Copy link
Contributor Author

michelk commented Nov 30, 2020

I'm also not into those topics and couldn't tell anything about best-practices. Maybe the raster::interpolate function could also be used for that.

@mstrimas mstrimas added the enhancement New feature or request label Nov 30, 2020
@mstrimas
Copy link
Owner

Ok, I'll leave this issue open for now, when I have some spare time I'll investigate the best approach for this and consider adding a function for raster smoothing.

@michelk
Copy link
Contributor Author

michelk commented Nov 30, 2020

https://geocompr.robinlovelace.net/geometric-operations.html#simplification mentions rmapshaper::ms_simplify, where topology is preserved in the simplification process. Maybe this could also inspire smoothing where topology is preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants