I'm splitting a national soils raster file into regional (county) rasters, and organizing the soils classifications into a database keyed by region, eventually plot- or farm-level detail.
At the moment I'm doing it the hard way: using QGIS 3.4.4 to clip big rasters to smaller polygons.
As my result will be hundreds of smaller rasters with maybe 40 - 100 soil classes each (varies by polygon), I'll be 1) making lots of errors and 2) losing precision.
Occurs to me I don't need to split the raster at all, I just need to query the classes by each polygon, and write that to my database. Something like:
FOR each polygon IN vector.layer: CREATE.MASK FROM polygon1 SELECT COUNT(raster.classes) as soil.area WRITE_DB polygon1.name, soil.area NEXT polygon
Maybe PostGIS is the better tool? Python? Dare I dig into R's formidable spatial libraries?
My original framing was vague as I didn't have a lot invested in one tool over the others. Since then I've migrated over to a PostGIS database, read up on spatial indexes, and replaced rasters with vector data.
Decision-making went like this: our datasets are big, but unlikely to get bigger than the 28 countries of Europe; if I understood correctly, R likes to load spatial data into memory - which could cause trouble in some of these big joins.
We are likely to add layers of data - perhaps water features within some countries, soil moisture data in others - and I was impressed by the speed of st_transform() function in postgis when adding layers. Hope this is a more useful thread for those researching the similar questions.