-
Notifications
You must be signed in to change notification settings - Fork 4
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
Partial composites with a subset of tiles from a full tile_grid? #12
Comments
Hey thanks for raising this, I am glad you are getting some use out of Compositing large numbers of tiles is definitely not a great idea with the package as it stands now. Regarding rasterising individual tiles: There's probably a function missing to do that. Right now you can get a list of However code to make those individual rasters already lives in raster_img <-
raster::brick(image,
crs = attr(bbox, "crs")$proj4string)
raster::extent(raster_img) <-
raster::extent(bbox[c("xmin", "xmax", "ymin", "ymax")])
raster_img So if we pull that out into a new function it can be used to combine the pieces. The one thing this wouldn't give you that you mentioned are polygons. Do you just need them as a step toward the individual rasters or are they important in their own right? Edit: Have you checked out |
If I had a nickel for every time Michael Sumner had already written the thing I needed but didn't know the correct search terms to describe... This looks great. I'm hoping to use non-Mapbox sources but the framework looks spot-on. (I want to download a ton of tiles to semi-permanent storage, which runs against Mapbox ToS.) With your answer above and the Answering your other question:
The pointer to compose_tile_grid is enough, I think -- I can make a polygon from the bbox of each tile and proceed from there. I just need to work tile-by-tile, but it's a small modification of the existing logic. If I get something working, would you want this feature in the package? (Totally cool if you want to keep the footprint small, especially since The background use-case -- I'm definitely interested in the polygons in their own right. It might be an idiosyncratic workflow. I do lots of raster computations using data stored on S3, so it's hard to merge together a huge raster once, leave it out of memory, and load cropped subsets for processing. (Most of my work uses many small and frequently-overlapping subsets, and I process them in parallel, so I rarely need to |
I actually just added 'general' branch which now includes an AWS source to ceramic, the one used by elevatr. The fastest way to merge is via VRT and use of GDAL's lazy tools. I'm going to separate that out in ceramic soon. |
I'm a few days into heavy use of
slippymath
and really enjoying it -- thank you! FWIW, I'm using it to rapidly construct training sets for some image analysis prototyping -- I don't know if you had that use-case in mind when writing the package, but I'm writing <50 lines of code to get a fantastic training set with zero overhead. Mind-blowing.With that application in mind, I started pulling and caching huge numbers of tiles at relatively high zoom. Even with only ~10k tiles pulled, compositing everything back into a raster (to recover the spatial information) is not trivial -- that amounts to a 25,600px square image. For larger areas I'm doubtful that it's a good idea to try. The next step for many types of image analyses would be to take many bite-size chunks from that large image and crop/rotate/coarsen/etc to preprocess, so compositing the full raster is a bottleneck that isn't really needed other than to return the image tile files to a raster object with the CRS/extent/resolution embedded correctly.
I've experimented with the function
compose_tile_grid
and subsets of thetile_grid
object, and I run into trouble when I don't pass in the completetile_grid
object in order to accurately staple tiles back into a raster with the spatial information correctly attributed.I'm working through package internals and think I understand what's going on here. (I think) the
bbox_to_tile_grid
object transformation is exactly invertible. If that's true, then (borrowing from the README) we could probably take a statement like this:tile_grid <- bbox_to_tile_grid(uluru_bbox, max_tiles = 15)
and come up with some corresponding process that turns a tile_grid into (eg) an
sf
polygon dataframe describing the precise boundaries of each component tile. That would allow for rasterizing each tile independently, with full spatial information for the specific tile that can be merged (or not) into a larger raster.That would also permit informed subsetting of which tiles to look at in a subsample of a larger
slippymath
pull. For example, this kind of process would be broadly useful:=> we get an enriched training set of many partially-overlapping images.
It looks like you've done a lot of work to remove the
sf
dependency before CRAN release, so this line of thinking may be better interpreted in spirit than implementation. Does the overall concept make sense? My use-case might be too idiosyncratic for a PR into the package, but if my premises seem directionally correct to you, then I'll plan to write up some logic to implement this independently. I can link a gist in case you're interested.Thanks again for all of your work on this.
The text was updated successfully, but these errors were encountered: