-
Notifications
You must be signed in to change notification settings - Fork 44
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
Raster Map and on land check #145
Comments
The rasterized map is used during the model run for beaching -- so we want to use exactly the same map for checking the "spillability" as for beaching. Yes, this is influenced by the resolution of the raster -- but so is the entire beaching process, so it makes sense. We've wanted for years to use a beaching algorithm that uses the full vector map -- but that is computationally substantially more expensive. A simple implementation would be O(N) in the number of polygon segments, and even with a smart spatial index, it would be O(logN) -- for complex polygons, that would be a substantial performance hit. With modern computers, you can increase the resolution of the raster substantially if need be. |
Thanks @ChrisBarker-NOAA. I was implementing a shape file based map instead of the default BNA and I fall into this issue. But now it makes sense to me. Is it the same also for mover? Let’s say that I have a grid current mover, the evaluation of “delta” done for each step is done using raster or passed mover grid? How extrapolation is handled in that case(e.g. if the grid is not extended up to the “rasterized” coastline)? thanks |
Ahh -- we've been meaning to add a way to build a map from a shapefile (or geojson, or ...) If you share you code, be way be able to include it -- should be pretty straightforward.
The rasterized map is only used for beaching. the Movers do whatever they will do, unaware of the map. For a Grid Mover, the native grid is interpolated to get the velocity at the time and place of the element. If the element is off the grid, it will get a velocity of zero. If there is a gap between the velocity grid and the land map, the element could get stuck, but usually there's a random diffusion and/or wind that will move it along. |
Thanks for the details about mover working principle!
Yes of course. Now the basic implementation is to load a land polygon shape file and pass each polygons to the Polygon class as has been implemented for the BNA polygons. But we are working in order to speed up the process. I'll let you know. Of course the Outputter Renderer will have the same implementation. |
Actually, we've been meaning to refactor that -- at this point, the Map stores the land polygons anyway (set up so they can be passed to the Web client), so the Renderer should be refactored to use the polygons that the Map stores anyway, so no need to duplicate that code. e.g. the Renderer can use the
|
hi @ChrisBarker-NOAA, we are now testing a maps from polygons function that works pretty well with multi polygons shape file map like the one available here for the European Coast Line. At the moment we create a child class (MapFromShape) that inherit method from the standard MapFromBNA class. The same should be done for Renderer.
|
Thanks! I"ll try to give this a test soon. However, would it be possible to refactor it to use shapely, rather than geopandas? WE already have a shapely dependency, and it would be nice to have one less. @jay-hennen: This might be an opportunity to refactor the Map code to jsu tuse shapely for everything. When I wrote that code years ago, Shapely was a troublesome dependency (or maybe even didn't exist yet!) -- maybe it's time to just buy into it. @tommasogallingani: As I suggested earlier, I think we should refactor the Renderer code to use the polygons from the Map object, instead of re-loading it from the vector file -- that would be one less place that has to understand file formats :-) |
Hi Chris, I'll give it a try also with shapely. Concerning the renderer, you cannot just pass land polygons to the renderer getting the from map?
|
I apologize for the insufficient documentation for the Renderer. The land_polygons keyword argument is expecting an iterable (list/set) of In my opinion it would be an improvement if we replaced the |
Yes, you can! Sorry about that, I had forgotten we'd added that. @jay-hennen: I think our examples and demo scripts don't take advantage of that -- we should go in and edit those! As for Shapely polygons internally, yes no duck-typing replacement, though we may be able to add a little wrapper or something that would extract the coords from Shapely Polygons. But as you say, this is an internal detail -- I dont think it's exposed anywhere to scripting (Or save files?) so we could refactor that without breaking anything. |
I've just updated (in the develop branch) the Renderer to be able to take a GnomeMap object, rather than a BNA filename for the land polygons. This call These are not hard to create from numpy arrays of points, so you should be able to read the shapefile, and then make these polygons, and have the whole thing integrate with the rest of the system. Note that refactoring to use Shapely everywhere would be good, but it's a bigger refactor than we're going to do anytime soon. Final Note: I think a "polygons_from_file" that can read BNA, shapefile (and geoJSON, and ...) could be handy -- then we could just call that everywhere we need the polygons, and turn PRs welcome :-) |
Hi all,
I've one question about the reason why during the modeling step, the spill start position is checked on map using the on_land_pixel method in the RasterMap class (that is the father class for MapFromBNA). It seems that in that way the "on land" position could be influenced by the raster size that can be passed to the class during init.
Why the "spillability" is not checked on Polygons instead?
Thanks
The text was updated successfully, but these errors were encountered: