inbo / n2khab

R package with preprocessing functions and standard reference data for Flemish Natura 2000 (N2K) habitat (HAB) analyses
https://inbo.github.io/n2khab
GNU General Public License v3.0
2 stars 1 forks source link

Expose the query argument of sf::read_sf() where useful #188

Open florisvdh opened 20 hours ago

florisvdh commented 20 hours ago

Functions that read a spatial vector data source could expose the query argument of sf::read_sf() in order to pass an SQL statement to the GDAL driver (https://gdal.org/en/latest/user/ogr_sql_dialect.html).

This could be useful in functions that read large datasets (such as the raw soilmap and habitatmap data sources), when interest is only in a filtered part of the data source. To be investigated is whether the gain in reading timing is large enough, as executing the query will also take some time. The gain in memory should be obvious anyway; it will depend on the relative object sizes.

At least one pitfall to be investigated is whether this could cause unwanted side effects during the preprocessing done by the function. One example may be a different number of factor levels that might result for a specific column. Whether that is a problem in need of another solution, must be assessed on a case-by-case basis.