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

'file_to_geojson' - error when reading from 'special' url #83

Closed
patperu opened this issue Apr 14, 2016 · 15 comments
Closed

'file_to_geojson' - error when reading from 'special' url #83

patperu opened this issue Apr 14, 2016 · 15 comments
Assignees
Milestone

Comments

@patperu
Copy link
Contributor

patperu commented Apr 14, 2016

Hello @sckott,

I want to convert a shpfile (as zip) to geojson, the input comes from an url.

library('geojsonio')
url <- 'http://odn.comune.prato.it/geonetwork/srv/en/resources.get?uuid=f7077224-bf61-4b1e-904b-f3668ef80859&fname=WIFI_COPERTURA.zip&access=private'
out <- file_to_geojson(input=url, method='web', output='wifi-free-web')
## Success! File is at wifi-free-web.geojson

But the generated geojson is not valid, it contains this:

readLines("wifi-free-web.geojson", n = -1)
## [1] "{\"errors\":[\"invalid distance too far back\"]}"

If I use the same file from a different location, everything looks good (well, not really.. but this will be another issue 😉 )

url <- 'http://www.covimo.de/wifi/WIFI_COPERTURA.zip'
out <- file_to_geojson(input=url, method='web', output='wifi-free-web-covimo')
substring(readLines("wifi-free-web-covimo.geojson", n = -1), 1, 150)
#[1] "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"ID\":7},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[1668528.9793110648,48612"

Ciao
Patrick

@sckott
Copy link
Collaborator

sckott commented Apr 14, 2016

thanks for the issue @patperu - will have a look

@sckott
Copy link
Collaborator

sckott commented Apr 14, 2016

what version of geojsonio do you have - works for me - with current version

library('geojsonio')
url <- 'http://odn.comune.prato.it/geonetwork/srv/en/resources.get?uuid=f7077224-bf61-4b1e-904b-f3668ef80859&fname=WIFI_COPERTURA.zip&access=private'
out <- file_to_geojson(input=url, method='web', output='wifi-free-web')
substring(readLines("wifi-free-web.geojson"), 1, 75)
#> [1] "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"ID"

@patperu
Copy link
Contributor Author

patperu commented Apr 14, 2016

Hello @sckott ,
upps, sorry for missing this info..
I'm using geojsonio 0.1.8 (708f11e)

BTW, I'm going to open another issue (not connected) in a few minutes, so maybe you want to wait.

@sckott
Copy link
Collaborator

sckott commented Apr 14, 2016

I've not seen the error invalid distance too far back - it doesn't look like an error that happens in geojsonio

@patperu
Copy link
Contributor Author

patperu commented Apr 14, 2016

Hmm, ok.
I found this

Ciao
Patrick

@sckott
Copy link
Collaborator

sckott commented Apr 14, 2016

yeah, that makes sense that it's a problem with reading from the url

Have you tried using method="local" ?

@patperu
Copy link
Contributor Author

patperu commented Apr 17, 2016

Hello @sckott ,
couldn't try it on another windows machine, hopefully tomorrow. With Ubuntu it works without a problem for both methods local and web.
Ciao
Patrick

@sckott
Copy link
Collaborator

sckott commented Apr 17, 2016

thanks for update

@sckott
Copy link
Collaborator

sckott commented Jun 4, 2016

@patperu did you get this sorted out?

@patperu
Copy link
Contributor Author

patperu commented Jun 5, 2016

Hello @sckott
the reason is download.file in handle_remote (in file_to_geojson.r).
On windows (two different machines) this

url <- 'http://odn.comune.prato.it/geonetwork/srv/en/resources.get?uuid=f7077224-bf61-4b1e-904b-f3668ef80859&fname=WIFI_COPERTURA.zip&access=private'
download.file(url, destfile = "WIFI_COPERTURA.zip")

doesn't create a valid zip-file.

But this works:

library('httr')
library('geojsonio')
t_ok   <- content(GET('http://www.covimo.de/wifi/WIFI_COPERTURA.zip'))
t_fail <- content(GET('http://odn.comune.prato.it/geonetwork/srv/en/resources.get?uuid=f7077224-bf61-4b1e-904b-f3668ef80859&fname=WIFI_COPERTURA.zip&access=private'))
identical(t_ok, t_fail)
#[1] TRUE

outfile <- file("WIFI_COPERTURA.zip", "wb")
     writeBin(t_fail, outfile, raw())
close(outfile)

file_to_geojson("WIFI_COPERTURA.zip", method='web', output='WIFI_COPERTURA')
substring(readLines("WIFI_COPERTURA.geojson"), 1, 75)
# [1] "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"ID"

@sckott sckott self-assigned this Jun 5, 2016
@sckott
Copy link
Collaborator

sckott commented Jun 6, 2016

thanks @patperu I'll have a look

@sckott
Copy link
Collaborator

sckott commented Jun 6, 2016

@patperu try reinstalling devtools::install_github("ropensci/geojsonio")

i tested on my windows VM, try it on your windows machine. I think it should work now. let me know

@patperu
Copy link
Contributor Author

patperu commented Jun 8, 2016

Hi @sckott, looks good! I'm using the latest version (4d0f8cc) and it works now.
Thank you!
Patrick 👋

@sckott
Copy link
Collaborator

sckott commented Jun 8, 2016

great, glad it works

@sckott sckott added this to the v0.3 milestone Jun 8, 2016
@sckott sckott closed this as completed Jun 8, 2016
@sckott sckott modified the milestones: v0.3, v0.2 Jun 17, 2016
@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants