-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to link segmentations based on lon and lat coordinates? #98
Comments
We have some code here that we've been working on to do basically that. It's close but not yet ready for a PR. Hopefully, we can get this in for v1.4 or v1.5. |
Transferring detected features and segmentations across different grids is definitely a feature on the radar for tobac v2.0. This sounds like a subset of that situation, where it's only applied to two lat/lon grids (rather than grids on different coordinates). A couple of questions to see how complex this is:
There are two approaches to this I've considered. The first, more direct approach is simply to regrid from one grid to the other. This is pretty straightforward, but more computationally intensive and slightly less satisfactory, particularly if you want to preserve resolution. The second approach is to turn each segmentation mask into a set of geometric objects that contain each of the segmented features, which could then be mapped to any other grid without having the regrid the data on the second grid itself |
@w-k-jones Thanks for the idea. For polar-orbiting satellite data, the lon/lat, spacing, and spatial extent are all different. Here's an example. I guess I can use geopandas to convert segmentations into geometric objects, but how to map it to another grid? |
Here's a quick mock-up of what I'm thinking: The idea is that it's much easier to map a geopandas/shapely boundary formed from a set of points from one coordinate system to a different coordinate system than it is an entire grid (this isn't even necessary if they're both in lat/lon coords). Then you just need to check which pixels on the new grid are within the boundary of segmentation on the old grid, giving you the mask in the new grid. This is fairly straightforward for 2d, but I'm not sure if there are any libraries which could do the same for 3d data |
Ah- I see what the two of you are thinking. I misunderstood the original question. We don't have code that does that yet here. What we have is code that allows one to take feature detection output from one grid (with lat/lons) and use that to seed watershedding on a different grid (with lats/lons). I think what the two of you are discussing is very interesting and I agree with @w-k-jones that it would be great to get something like that into v2.x. |
@w-k-jones Thanks for the detailed explanation. I make a simple draft to accomplish your idea by pyresample: The orange grid contains the mask and I get the mask in another grid (blue one) by resampling the blue grid to the mask points (lon/lat) of the orange grid. Core code:
|
Note that pyresample can deal with both swath and grid data. It means that the model data, GEO, and polar-orbiting satellite observations can be all supported! The I suppose this solution can't deal with 3d data .... |
I see @JuliaKukulies has added the lon/lat support (#65), is it possible to link the 2D segmentations with different shapes? Let's assume we have two segmentations: seg1 (y:200, x: 100) and seg2 (y: 190, x: 120). Both of them have 2D lon and lat coordinates. If we can utilize the lon/lat coordinates with segmentation info together. that would be awesome!
The text was updated successfully, but these errors were encountered: