pachterlab / SpatialFeatureExperiment

Extension of SpatialExperiment with sf
https://pachterlab.github.io/SpatialFeatureExperiment
Artistic License 2.0
43 stars 7 forks source link

New implementation of affine transformations of SFE objects #54

Open lambdamoses opened 3 weeks ago

lambdamoses commented 3 weeks ago

So it's more like BioFormatsImage, storing the transformation info in metadata, only evaluating it last ditch say when plotting. I'm thinking about this because the user may add more geometries say from QuPath annotations to the SFE object. If the SFE object is already transformed, then the new geometries have to be transformed separately, which would be difficult if the transformation info for the SFE object isn't save somewhere. So at least the transformation info should be saved. The disadvantage of being like BioFormatsImage is that the transformation has to be applied every time spatial data from the SFE object is plotted and I know that users can make a lot of plots. That can be slow when there're hundreds of thousands of polygons but I wouldn't plot that many polygons since we can't see them anyway so I'd rather use scattermore to plot the centroids. Furthermore, while spatial methods that use the spatial neighborhood graph are not affected by the transformation, distance view methods like the variogram may be affected, say by rotation (for anisotropic variograms), scaling, shearing, etc.

lambdamoses commented 2 days ago

Also try using proj, if I don't want to read the confusing WKT engineering CRS specification. https://proj.org/en/9.2/operations/transformations/affine.html https://r-spatial.github.io/lwgeom/reference/st_transform_proj.html If it works, then it might be faster than my crude homemade approach.