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

get_wms return RGB layer instead of values for MNT or MNH #21

Closed
paul-carteron opened this issue Oct 10, 2023 · 2 comments
Closed

get_wms return RGB layer instead of values for MNT or MNH #21

paul-carteron opened this issue Oct 10, 2023 · 2 comments

Comments

@paul-carteron
Copy link
Owner

happign 0.1.9 work, need to go back to old method

@paul-carteron
Copy link
Owner Author

paul-carteron commented Oct 11, 2023

gdal_translate with -tr and -projwin argument work but I need to compute width and height for each tile as before. Also I cannot reproject the raster.

rm(list=ls())

library(sf)
library(tmap)
library(terra)

# x <- mapedit::drawFeatures()
x <- read_sf(system.file("extdata/penmarch.shp", package = "happign"))

apikey = "ortho"
layer = "ORTHOIMAGERY.ORTHOPHOTOS.BDORTHO"
res = 5
filename = tempfile(fileext = ".tif")
crs = 2154
overwrite = FALSE
version = "1.3.0"
styles = ""
interactive = FALSE
x <- st_make_valid(x) |>
   st_transform(st_crs(crs))
bbox <- st_bbox(x)

url <- paste0(
   "https://wxs.ign.fr/",
   apikey,
   "/geoportail/r/wms?",
   "VERSION=1.3.0",
   "&REQUEST=GetMap",
   "&LAYERS=", layer,
   "&CRS=EPSG:2154",
   "&FORMAT=image/geotiff",
   "&width=2048",
   "&height=2048",
   "&styles=",
   "&bbox=", paste(bbox["xmin"], bbox["ymin"], bbox["xmax"], bbox["ymax"], sep = ",")
)

gdal_utils("translate",
           source = url,
           destination = "temp.tif",
           quiet = FALSE,
           options = c("-tr", 2, 2, 
                       "-projwin", bbox$xmin, bbox$ymax, bbox$xmax, bbox$ymin))


rast <- rast("temp.tif")

tm_shape(rast)+
   tm_rgb()

@paul-carteron
Copy link
Owner Author

gdal warp can't be used because RGB is returned and also it's much longer

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