ropensci / geojsonio

Convert many data formats to & from GeoJSON & TopoJSON
https://docs.ropensci.org/geojsonio
Other
151 stars 59 forks source link

Install on Ubuntu 18.04 #140

Closed OmarGonD closed 6 years ago

OmarGonD commented 6 years ago

I'm trying to install and use geojsonio package to follow up this basic Leaflet tutorial: Leaflet choropleths

But having problems reading the example data in the tutorial, from URL or saving it as *.geojson locally.

However, after reading and trying differente things I'm still getting this error:

states <- geojsonio::geojson_read("http://leafletjs.com/examples/choropleth/us-states.js", what = "sp")
Error in rgdal::ogrListLayers(input) : Cannot open data source

It doesn't matter if I open the URL in a browser, copy the contents and save them as "json/us-states.geojson", or if I put the URL Directly, I get the same error.

When in terminal I do:

sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev

System tells me everything is installed and need no updates.

What else should I do?

sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev ogonzales@ogonzales:~$ sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev Leyendo lista de paquetes... Hecho Creando árbol de dependencias Leyendo la información de estado... Hecho libgdal-dev ya está en su versión más reciente (2.2.3+dfsg-2). libgeos-dev ya está en su versión más reciente (3.6.2-1build2). libproj-dev ya está en su versión más reciente (4.9.3-2). libudunits2-dev ya está en su versión más reciente (2.2.26-1). Los paquetes indicados a continuación se instalaron de forma automática y ya no son necesarios. linux-headers-4.15.0-23 linux-headers-4.15.0-23-generic linux-image-4.15.0-23-generic linux-modules-4.15.0-23-generic linux-modules-extra-4.15.0-23-generic Utilice «sudo apt autoremove» para eliminarlos. 0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 198 no actualizados.
Session Info Session info -------------------------------------------------------- setting value version R version 3.4.3 (2017-11-30) system x86_64, linux-gnu ui RStudio (1.1.383) language es_ES:en_US:en collate es_ES.UTF-8 tz America/Lima date 2018-08-11 Packages ------------------------------------------------------------ package * version date base * 3.4.3 2017-12-01 class 7.3-14 2015-08-30 classInt 0.2-3 2018-04-16 compiler 3.4.3 2017-12-01 crosstalk 1.0.0 2016-12-21 curl 3.2 2018-03-28 datasets * 3.4.3 2017-12-01 DBI 1.0.0 2018-05-02 devtools 1.13.6 2018-06-27 digest 0.6.15 2018-01-28 e1071 1.6-8 2017-02-02 foreign 0.8-69 2017-06-21 geojson 0.2.0 2017-11-08 geojsonio * 0.6.0.9100 2018-08-11 graphics * 3.4.3 2017-12-01 grDevices * 3.4.3 2017-12-01 grid 3.4.3 2017-12-01 htmltools 0.3.6 2017-04-28 htmlwidgets 1.2 2018-04-19 httpuv 1.4.3 2018-05-10 httr 1.3.1 2017-08-20 jqr 1.0.0 2017-09-28 jsonlite 1.5 2017-06-01 later 0.7.2 2018-05-01 lattice 0.20-35 2017-03-25 lazyeval 0.2.1 2017-10-29 leaflet * 2.0.0 2018-04-20 magrittr 1.5 2014-11-22 maptools 0.9-3 2018-07-31 memoise 1.1.0 2017-04-21 methods * 3.4.3 2017-12-01 mime 0.5 2016-07-07 promises 1.0.1 2018-04-13 R6 2.2.2 2017-06-17 Rcpp 0.12.18 2018-07-23 rgdal * 1.3-4 2018-08-03 rgeos 0.3-28 2018-06-08 sf 0.6-3 2018-05-17 shiny 1.1.0 2018-05-17 sp * 1.3-1 2018-06-05 spData 0.2.8.3 2018-03-25 stats * 3.4.3 2017-12-01 tools 3.4.3 2017-12-01 units 0.6-0 2018-06-09 utils * 3.4.3 2017-12-01 V8 1.5 2017-04-25 withr 2.1.2 2018-08-11 xtable 1.8-2 2016-02-05 yaml 2.2.0 2018-07-25 source local CRAN (R 3.4.0) CRAN (R 3.4.3) local CRAN (R 3.4.3) CRAN (R 3.4.3) local CRAN (R 3.4.3) CRAN (R 3.4.3) cran (@0.6.15) cran (@1.6-8) CRAN (R 3.4.0) CRAN (R 3.4.3) Github (ropensci/geojsonio@30b0969) local local local CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.0) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) local CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) cran (@0.12.18) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) CRAN (R 3.4.3) cran (@1.3-1) CRAN (R 3.4.3) local local CRAN (R 3.4.3) local CRAN (R 3.4.3) Github (jimhester/withr@fe56f20) CRAN (R 3.4.3) cran (@2.2.0) ```r ```
sckott commented 6 years ago

thanks for the issue @OmarGonD

Did you see that the file has var statesData = at the start of it and a semicolon at the end? So it seems that that URL is almost okay, it just needs to be edited a bit to remove that js var assignment, and to remove the trailing semicolon.

I guess in the leaflet tutorial where it says

From http://leafletjs.com/examples/choropleth/us-states.js

it shoould clarify that one needs to edit it a bit.

Let me know if that works.

OmarGonD commented 6 years ago

Thank you, that was it.

github-actions[bot] commented 1 year ago

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.