Skip to content
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

ungeoreferenced imagery #204

Open
mdsumner opened this issue Apr 24, 2023 · 2 comments
Open

ungeoreferenced imagery #204

mdsumner opened this issue Apr 24, 2023 · 2 comments

Comments

@mdsumner
Copy link
Member

we need both SRC_METHOD and DST_METHOD to be NO_GEOTRANSFORM, then we can play purely with target_dim:

im <- vapour::gdal_raster_image("https://herbariumnsw-pds.s3-ap-southeast-2.amazonaws.com/images/NSW041500.jp2", 
                               target_dim = c(0, 1024),
                               options = c("-to", "SRC_METHOD=NO_GEOTRANSFORM", "-to", "DST_METHOD=NO_GEOTRANSFORM"))
ximage(im)

even better would be the overviews, so maybe a "max_dim" argument could do

info <- vapour::vapour_raster_info("https://herbariumnsw-pds.s3-ap-southeast-2.amazonaws.com/images/NSW041500.jp2")
ovr <- matrix(info$overview, byrow = TRUE, ncol = 2)
max_dim <- 1024
if (!is.null(ovr)) {
idx <- max(c(findInterval(max_dim, rev(ovr[,1])), findInterval(max_dim, rev(ovr[,2])))
)
dimension  <- ovr[nrow(ovr):1, ][idx, ]
}
@mdsumner
Copy link
Member Author

hmm, no it doesn't work properly - the target dim screws up the extent

@mdsumner
Copy link
Member Author

the only thing that works reliably with this source is to override the original extent, and ask for specific overview dims

library(vapour)
library(ximage)
info <- vapour_raster_info("https://herbariumnsw-pds.s3-ap-southeast-2.amazonaws.com/images/NSW041500.jp2")

ovr <- matrix(info$overview, byrow = TRUE, ncol = 2)
ovr <- ovr[nrow(ovr):1, ]

im <- vapour::gdal_raster_image("vrt://https://herbariumnsw-pds.s3-ap-southeast-2.amazonaws.com/images/NSW041500.jp2?a_ullr=0,9661,7175,0", 
                               target_dim = ovr[5,])

print(attr(im, "extent"))
ximage(im)

where 'ovr' s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant