Giter VIP home page Giter VIP logo

Comments (7)

edzer avatar edzer commented on August 18, 2024

stars still considers the object to be in a curvilinear grid (which doesn't make sense imo because it isn't anymore)

yes, because it does not contain information about what the original CRS was, in which it was regular

it's plotted slightly different on mapview (surprising)

mapview will do some warping, which is lossy

from stars.

jfsalzmann avatar jfsalzmann commented on August 18, 2024

yes, because it does not contain information about what the original CRS was, in which it was regular

hmm, doesn't it? I thought I've passed it this information.

# transforming back
back = transf %>% st_transform(st_crs(temperature))

and, this is TRUE:

identical(st_crs(temperature),st_crs(back))

maybe I misunderstand what you mean here.

mapview will do some warping, which is lossy

I would expect identical warping results of identical matrix data and CRS, which I indeed get, but just after using st_warp.

from stars.

edzer avatar edzer commented on August 18, 2024

In transf %>% st_transform(st_crs(temperature)), trans doesn't know its grid can be represented by a regular grid in st_crs(temperature).

from stars.

jfsalzmann avatar jfsalzmann commented on August 18, 2024

So that means, transforming a raster to another CRS always comes with some sort of informational loss regarding the grid, which cannot be recovered without warping the data? or is there a way I can provide that information when re-transforming?
I have difficulties understanding the reasoning behind it.

At least, it seems somewhat inefficient that the second line in the example below takes overproportionally long to compute, given that in the end, the matrix data is exactly identical. I admit it may seem like an unrealistic special case to do that..

back = transf %>% st_transform(st_crs(temperature))
back_w = transf %>% st_transform(st_crs(temperature)) %>% st_warp(dest = temperature)

So I would suggest the following behavior: when (re-)transforming to the CRS that a raster had originally, assume a regular grid again, as no re-calculation / warping is required in fact. Possibly store the original CRS (I assume it would be stored somehow already).
Or alternatively, add a special case to st_warp that skips the re-computation of the matrix in that case.

from stars.

edzer avatar edzer commented on August 18, 2024

So I would suggest the following behavior: when (re-)transforming to the CRS that a raster had originally, assume a regular grid again, as no re-calculation / warping is required in fact. Possibly store the original CRS (I assume it would be stored somehow already).

Yes, of course one can do all that, the question is how large the benefit is compared to the cost, and how this can be made waterproof such that all kind of operations in between (cropping, downsampling) lead to the right regular grid again. In your case, going from CRS A to B to A and no messing, you can set back the dimension table by

st_dimensions(back) = st_dimensions(temperature)

but only because you know that this is OK: no cost, also no guarantee or checking from the software side.

from stars.

jfsalzmann avatar jfsalzmann commented on August 18, 2024

Ah, that was the missing piece of the puzzle, thank you very much, that solves my problem.

and how this can be made waterproof such that all kind of operations in between (cropping, downsampling) lead to the right regular grid again

I agree, that may be tricky. Thanks for explaining!

from stars.

jfsalzmann avatar jfsalzmann commented on August 18, 2024

(can be closed)

from stars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.