Closed timtreis closed 1 year ago
Quick question @timtreis. Running the code produces this:
I think I need to use one of the new branches of spatialdata-plot
that will make it into the next release. Which one?
I guess https://github.com/scverse/spatialdata-plot/pull/162, gonna try now.
Yes, this one. Can you reproduce?
Yes thanks. This is the cause of the bug:
Ahhh yeah, makes sense. That's why it scales with r
The current approach works for raster data, the affected part is points, shapes and polygons. I will implement the exact calculation for the vector data, enabled by default, but I will also make it optional with a parameter of get_extent.
I suspect that the current implementation can be a lot faster since it doesn't need to transform the data, and for most cases actually one doesn't need the exact extent.
Fixed
Gonna make a PR to the get_extent()
PR, I will also fix the failing tests.
I am adding tests, not just for circles but also for points, polygons and multipolygons.
These are the plots that one would get with the old code (note that I have changed the positions of the circles in the "global" coordinate system). 4 circles 4 polygons 4 multipolygons 4 points
This is with the new code. 4 circles 4 polygons 4 multipolygons 4 points
Things work, except for points. I will:
spatialdata-plot
spatialdata-plot
to add tests for the cases above; in fact in the tests in spatialdata
I will just check that the coordinates are correct; I am making the plots now just to see what's going onAll correctly computed. I have opened the aforementioned issues in spatialdata-plot
and I have made a PR to merge against the get_extent()
PR.
Fixed by https://github.com/scverse/spatialdata/pull/373 and merged via https://github.com/scverse/spatialdata/pull/318
MRE
Produces the following plot:
We expect the axis of the
transformed
plot to also touch the circles. This is not the case since the extent is calculated totransformed {'y': (-0.07071067811865475, 1.48492424049175), 'x': (-0.7778174593052023, 0.7778174593052024)}
.However, the error doesn't come from the extent calculation, but from L305 in
_compute_extent_in_coordinate_system
:Bounding box before and after transformation:
Since we're rotating by 45°, we'd expect them to be
(+/- the radius of the circle 0.05) which would result in a different bounding box. With larger radii, the inaccuracy becomes bigger
radius = 0.5