Closed Nowosad closed 2 years ago
I just tested it on Windows (R 4.0.5) and it worked. To debug you can use debug()
.
These lines are crucial: https://github.com/kadyb/rgugik/blob/e276ac0b20c026543674cf15be3b0c532611957b/R/ortho_request.R#L72-L75
You can check URL from prepared_URL
variable in web browser to exclude a local problem.
Thanks @kadyb.
The prepared url is "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/0/query?geometry={'xmin':360207.759479622, 'ymin':512866.601609941, 'xmax':360298.871256537, 'ymax':512957.713386855, 'spatialReference':{'wkid':2180}}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&outFields=godlo,akt_rok,piksel,kolor,zrDanych,ukladXY,czy_ark_wypelniony,url_do_pobrania,idSerie,sha1,akt_data,nazwa_pliku&returnGeometry=false&f=json"
and it works in the browser.
However, when I try to run the next line of code, I got:
> jsonlite::fromJSON(prepared_URL)
Error in open.connection(con, "rb") :
URL using bad/illegal format or missing URL
I tested on Ubuntu (R 4.1.2) and it works too. Does the code below work for you?
URL = "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/0/query?geometry={'xmin':360207.759479622, 'ymin':512866.601609941, 'xmax':360298.871256537, 'ymax':512957.713386855, 'spatialReference':{'wkid':2180}}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&outFields=godlo,akt_rok,piksel,kolor,zrDanych,ukladXY,czy_ark_wypelniony,url_do_pobrania,idSerie,sha1,akt_data,nazwa_pliku&returnGeometry=false&f=json"
output = jsonlite::fromJSON(URL)
URL = "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/0/query?geometry={'xmin':360207.759479622, 'ymin':512866.601609941, 'xmax':360298.871256537, 'ymax':512957.713386855, 'spatialReference':{'wkid':2180}}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&outFields=godlo,akt_rok,piksel,kolor,zrDanych,ukladXY,czy_ark_wypelniony,url_do_pobrania,idSerie,sha1,akt_data,nazwa_pliku&returnGeometry=false&f=json"
output = jsonlite::fromJSON(URL)
#> Error in open.connection(con, "rb"): URL using bad/illegal format or missing URL
Created on 2021-12-09 by the reprex package (v2.0.1)
Interestingly, the URL works when spaces were removed:
URL = "https://mapy.geoportal.gov.pl/gprest/services/SkorowidzeFOTOMF/MapServer/0/query?geometry={'xmin':360207.759479622,'ymin':512866.601609941,'xmax':360298.871256537,'ymax':512957.713386855,'spatialReference':{'wkid':2180}}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&outFields=godlo,akt_rok,piksel,kolor,zrDanych,ukladXY,czy_ark_wypelniony,url_do_pobrania,idSerie,sha1,akt_data,nazwa_pliku&returnGeometry=false&f=json"
output = jsonlite::fromJSON(URL)
Created on 2021-12-09 by the reprex package (v2.0.1)
This error is from curl and is unhappy about the link. Maybe try adding "/" at the end? Or maybe space encoding will help: URL = gsub(" ", "%20", URL)
? Or remove these spaces at all?
We have nice post timing :smile:
So the question now is -- can we remove these (and similar) spaces from the package's code without making issues for other platforms?
This issue is very similar to this one #10. I see Geoportal is using +
to encode spaces. I will try to remove these spaces at all and test next. If it doesn't work, I encode this as %20
or +
.
Great. Let me know when it is ready and I will test it on my machine.
The patch (#84) for this issue can be installed in this way:
remotes::install_github("kadyb/rgugik")
Hi @kadyb -- now I have a different problem. The new code (tested on the reprex in the first post) does not return any result -- it just keeps the process working... I also tried the url that had previously worked (https://github.com/kadyb/rgugik/issues/83#issuecomment-990048092) -- it does not work now. My browser keeps trying to access the website for several minutes, and at the end returns {"error":{"code":500,"message":"Error performing query operation","details":[]}}
Is this an issue with the gugik servers or could it be my local issue?
Update: R code gave the proper result after maaaany minutes...
Error 500 means there are some problems with the server. Maybe the server is overloaded. It is certain that searching for orthophotomaps takes longer than for DEMs (this is independent of R, just the server).
library(rgugik)
library(sf)
polygon_path = system.file("datasets/search_area.gpkg", package = "rgugik")
polygon = read_sf(polygon_path)
system.time({req_df = ortho_request(polygon)})
#> user system elapsed
#> 0.06 0.00 105.44
system.time({req_df = DEM_request(polygon)})
#> user system elapsed
#> 0.01 0.00 0.47
Thanks for the explanation, Krzysztof.
Hi @kadyb -- I tried to use
ortho_request()
today, but without any success. Now, the question is -- is it my local problem, rgugik issue, or GUGiK's servers problem?This issues is partially related to https://github.com/kadyb/rgugik/issues/81.
CC: @krystiano200