paul-carteron / happign

Happign allows you to use the APIs provided by the IGN (France) to download their public data.
https://paul-carteron.github.io/happign/
GNU General Public License v3.0
30 stars 2 forks source link

rgdal can't read some url even if browser can #1

Closed paul-carteron closed 2 years ago

paul-carteron commented 2 years ago

When I try to manually download the conflict_url by putting it in browser, it works. When I use the get_wms_raster function it doesn't.

This doesn't work for layers from "economie" "lambert93" "orthohisto" "satellite" "transports" (all layer at the end)

Because it's rgdal problem I should look in this way. Also I should compare xml good request and bad request to find difference.

library(happign)

shape <- st_polygon(list(matrix(c(-4.373937, 47.79859,
                                  -4.375615, 47.79738,
                                  -4.375147, 47.79683,
                                  -4.373898, 47.79790,
                                  -4.373937, 47.79859),
                                ncol = 2, byrow = TRUE)))
#> Error in st_polygon(list(matrix(c(-4.373937, 47.79859, -4.375615, 47.79738, : could not find function "st_polygon"
shape <- st_sfc(shape, crs = st_crs(4326))
#> Error in st_sfc(shape, crs = st_crs(4326)): could not find function "st_sfc"

conflict_url = "https://wxs.ign.fr/economie/geoportail/r/wms?VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fgeotiff&LAYERS=INSEE.FILOSOFI.POPULATION&STYLES=&WIDTH=2048&HEIGHT=2048&CRS=EPSG%3A4326&BBOX=44.651138%2C0%2C48.22335%2C3.515625"

raster = get_wms_raster(shape, apikey = "economie", layer_name = "INSEE.FILOSOFI.POPULATION", resolution = 25)
#> Error in st_make_valid(shape): object 'shape' not found

good_url = "https://wxs.ign.fr/administratif/geoportail/r/wms?VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fgeotiff&LAYERS=ADMINEXPRESS-COG-CARTO.LATEST&STYLES=&WIDTH=8&HEIGHT=6&CRS=EPSG%3A4326&BBOX=47.79683%2C-4.375615%2C47.79859%2C-4.373898"

raster = get_wms_raster(shape, apikey = "administratif", layer_name = "ADMINEXPRESS-COG-CARTO.LATEST", resolution = 25)
#> Error in st_make_valid(shape): object 'shape' not found

Created on 2022-01-19 by the reprex package (v2.0.1)

Bad layer ``` r https://wxs.ign.fr/APIKEY/geoportail/r/wms?VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fgeotiff&LAYERS=LAYER_NAME&STYLES=&WIDTH=4&HEIGHT=3&CRS=EPSG%3A4326&BBOX=47.79683%2C-4.375615%2C47.79859%2C-4.373898) DREAL.ZONAGE_PINEL INSEE.FILOSOFI.LOGEMENTS.SURFACE.MOYENNE.SECRET INSEE.FILOSOFI.NIVEAU.DE.VIE.SECRET INSEE.FILOSOFI.PART.ENFANTS.0.17.ANS.SECRET INSEE.FILOSOFI.PART.FAMILLES.MONOPARENTALES.SECRET INSEE.FILOSOFI.PART.INDIVIDUS.25.39.ANS.SECRET INSEE.FILOSOFI.PART.INDIVIDUS.40.54.ANS.SECRET INSEE.FILOSOFI.PART.INDIVIDUS.55.64.ANS.SECRET INSEE.FILOSOFI.PART.LOGEMENTS.APRES.1990.SECRET INSEE.FILOSOFI.PART.LOGEMENTS.AVANT.1945.SECRET INSEE.FILOSOFI.PART.LOGEMENTS.COLLECTIFS.SECRET INSEE.FILOSOFI.PART.LOGEMENTS.CONSTRUITS.1945.1970.SECRET INSEE.FILOSOFI.PART.LOGEMENTS.CONSTRUITS.1970.1990.SECRET INSEE.FILOSOFI.PART.LOGEMENTS.SOCIAUX.SECRET INSEE.FILOSOFI.PART.MENAGES.1.PERSONNE.SECRET INSEE.FILOSOFI.PART.MENAGES.5.PERSONNES.OUPLUS.SECRET INSEE.FILOSOFI.PART.MENAGES.MAISON.SECRET INSEE.FILOSOFI.PART.MENAGES.PAUVRES.SECRET INSEE.FILOSOFI.PART.MENAGES.PROPRIETAIRES.SECRET INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET INSEE.FILOSOFI.POPULATION SCANEM40_PYR_PNG_FXX_LAMB93 ORTHOIMAGERY.ORTHOPHOTOS.1950-1965 ORTHOIMAGERY.ORTHOPHOTOS.1980-1995 ORTHOIMAGERY.ORTHOPHOTOS.IRC-EXPRESS.2018 ORTHOIMAGERY.ORTHOPHOTOS.IRC-EXPRESS.2019 ORTHOIMAGERY.ORTHOPHOTOS.IRC-EXPRESS.2020 ORTHOIMAGERY.ORTHOPHOTOS.IRC.2012 ORTHOIMAGERY.ORTHOPHOTOS.IRC.2013 ORTHOIMAGERY.ORTHOPHOTOS.IRC.2014 ORTHOIMAGERY.ORTHOPHOTOS.IRC.2015 ORTHOIMAGERY.ORTHOPHOTOS.IRC.2016 ORTHOIMAGERY.ORTHOPHOTOS.IRC.2017 ORTHOIMAGERY.ORTHOPHOTOS.ORTHO-ASP_PAC2020 ORTHOIMAGERY.ORTHOPHOTOS.ORTHO-EXPRESS.2017 ORTHOIMAGERY.ORTHOPHOTOS.ORTHO-EXPRESS.2019 ORTHOIMAGERY.ORTHOPHOTOS.ORTHO-EXPRESS.2020 ORTHOIMAGERY.ORTHOPHOTOS.SOCLE-ASP.2018 ORTHOIMAGERY.ORTHOPHOTOS.URGENCE.ALEX ORTHOIMAGERY.ORTHOPHOTOS2000 ORTHOIMAGERY.ORTHOPHOTOS2000-2005 ORTHOIMAGERY.ORTHOPHOTOS2001 ORTHOIMAGERY.ORTHOPHOTOS2002 ORTHOIMAGERY.ORTHOPHOTOS2003 ORTHOIMAGERY.ORTHOPHOTOS2004 ORTHOIMAGERY.ORTHOPHOTOS2005 ORTHOIMAGERY.ORTHOPHOTOS2006 ORTHOIMAGERY.ORTHOPHOTOS2006-2010 ORTHOIMAGERY.ORTHOPHOTOS2007 ORTHOIMAGERY.ORTHOPHOTOS2008 ORTHOIMAGERY.ORTHOPHOTOS2009 ORTHOIMAGERY.ORTHOPHOTOS2010 ORTHOIMAGERY.ORTHOPHOTOS2011 ORTHOIMAGERY.ORTHOPHOTOS2011-2015 ORTHOIMAGERY.ORTHOPHOTOS2012 ORTHOIMAGERY.ORTHOPHOTOS2013 ORTHOIMAGERY.ORTHOPHOTOS2014 ORTHOIMAGERY.ORTHOPHOTOS2015 ORTHOIMAGERY.ORTHOPHOTOS2016 ORTHOIMAGERY.ORTHOPHOTOS2017 ORTHOIMAGERY.ORTHOPHOTOS2018 ORTHOIMAGERY.ORTHOPHOTOS2019 ORTHO-SAT-RAPIDEYE-2011_PYR-JPEG_WLD_WM_20160801 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2012 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2013 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2014 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2015 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2016 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2017 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2018 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2019 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2020 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2021 ORTHOIMAGERY.ORTHO-SAT.PLEIADES.2022 ORTHOIMAGERY.ORTHO-SAT.RAPIDEYE.2010 ORTHOIMAGERY.ORTHO-SAT.SPOT.2013 ORTHOIMAGERY.ORTHO-SAT.SPOT.2014 ORTHOIMAGERY.ORTHO-SAT.SPOT.2015 ORTHOIMAGERY.ORTHO-SAT.SPOT.2016 ORTHOIMAGERY.ORTHO-SAT.SPOT.2017 ORTHOIMAGERY.ORTHO-SAT.SPOT.2018 ORTHOIMAGERY.ORTHO-SAT.SPOT.2019 ORTHOIMAGERY.ORTHO-SAT.SPOT.2020 ORTHOIMAGERY.ORTHO-SAT.SPOT.2021 SECUROUTE.TE.1TE SECUROUTE.TE.2TE48 SECUROUTE.TE.ALL SECUROUTE.TE.OA SECUROUTE.TE.PN SECUROUTE.TE.PND SECUROUTE.TE.TE120 SECUROUTE.TE.TE72 SECUROUTE.TE.TE94 TRANSPORTNETWORKS.ROADS.DIRECTION TRANSPORTS.DRONES.RESTRICTIONS ```
Session info ``` r sessioninfo::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 4.1.0 (2021-05-18) #> os Windows 10 x64 (build 19043) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate French_France.1252 #> ctype French_France.1252 #> tz Europe/Paris #> date 2022-01-19 #> pandoc 2.14.2 @ C:/PROGRA~1/Pandoc/ (via rmarkdown) #> #> - Packages ------------------------------------------------------------------- #> package * version date (UTC) lib source #> abind 1.4-5 2016-07-21 [1] CRAN (R 4.1.1) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.2) #> backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.2) #> class 7.3-19 2021-05-03 [2] CRAN (R 4.1.0) #> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.1.2) #> cli 3.1.0 2021-10-27 [1] CRAN (R 4.1.2) #> crayon 1.4.2 2021-10-29 [1] CRAN (R 4.1.2) #> DBI 1.1.2 2021-12-20 [1] CRAN (R 4.1.2) #> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2) #> dplyr 1.0.7 2021-06-18 [1] CRAN (R 4.1.2) #> e1071 1.7-9 2021-09-16 [1] CRAN (R 4.1.2) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.2) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.2) #> fansi 1.0.2 2022-01-14 [1] CRAN (R 4.1.0) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.2) #> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.2) #> generics 0.1.1 2021-10-25 [1] CRAN (R 4.1.2) #> glue 1.6.0 2021-12-17 [1] CRAN (R 4.1.2) #> happign * 0.1.0 2022-01-19 [1] Github (paul-carteron/happign@2af36ae) #> highr 0.9 2021-04-16 [1] CRAN (R 4.1.2) #> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.2) #> httr 1.4.2 2020-07-20 [1] CRAN (R 4.1.2) #> KernSmooth 2.23-20 2021-05-03 [2] CRAN (R 4.1.0) #> knitr 1.37 2021-12-16 [1] CRAN (R 4.1.2) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.2) #> lwgeom 0.2-8 2021-10-06 [1] CRAN (R 4.1.2) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.2) #> pillar 1.6.4 2021-10-18 [1] CRAN (R 4.1.2) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.2) #> proxy 0.4-26 2021-06-07 [1] CRAN (R 4.1.2) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.2) #> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.2) #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.1) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.1) #> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.2) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.2) #> Rcpp 1.0.8 2022-01-13 [1] CRAN (R 4.1.2) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.2) #> rlang 0.4.12 2021-10-18 [1] CRAN (R 4.1.2) #> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.2) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.2) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2) #> sf 1.0-5 2021-12-17 [1] CRAN (R 4.1.2) #> stars 0.5-5 2021-12-19 [1] CRAN (R 4.1.2) #> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.2) #> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.2) #> tibble 3.1.6 2021-11-07 [1] CRAN (R 4.1.2) #> tidyr 1.1.4 2021-09-27 [1] CRAN (R 4.1.2) #> tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.1.2) #> units 0.7-2 2021-06-08 [1] CRAN (R 4.1.2) #> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.2) #> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.2) #> withr 2.4.3 2021-11-30 [1] CRAN (R 4.1.2) #> xfun 0.29 2021-12-14 [1] CRAN (R 4.1.2) #> xml2 1.3.3 2021-11-30 [1] CRAN (R 4.1.2) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.1.1) #> #> [1] D:/Documents/R/win-library/4.1 #> [2] C:/Program Files/R/R-4.1.0/library #> #> ------------------------------------------------------------------------------ ```
paul-carteron commented 2 years ago

Solved by Always downloading rastzr on disk