Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 16 15:36

    github-actions[bot] on gh-pages

    Built site for eurostat: 3.7.10… (compare)

  • Mar 16 15:21

    github-actions[bot] on gh-pages

    Built site for eurostat: 3.7.10… (compare)

  • Mar 16 15:13

    pitkant on master

    Add Cairo to extra-packages (compare)

  • Mar 16 15:04

    pitkant on master

    Add tmap to extra-packages (compare)

  • Mar 16 14:07

    pitkant on master

    Update readme and pkgdown workf… (compare)

  • Feb 09 11:00

    pitkant on pitkant_cranfix

    (compare)

  • Feb 09 10:28

    github-actions[bot] on gh-pages

    Built site for eurostat: 3.7.10… (compare)

  • Feb 09 10:22

    antagomir on master

    sync sync submitted to CRAN (compare)

  • Feb 09 09:44

    github-actions[bot] on gh-pages

    Built site for eurostat: 3.7.10… (compare)

  • Feb 09 09:38

    github-actions[bot] on gh-pages

    Built site for eurostat: 3.7.10… (compare)

  • Feb 09 09:32

    antagomir on master

    Minor fixes to articles, depend… Re-build README.Rmd Remove package version from art… and 3 more (compare)

  • Feb 09 09:32
    antagomir closed #234
  • Feb 09 09:30
    pitkant commented #234
  • Feb 09 09:17
    codecov[bot] commented #234
  • Feb 09 09:08
    pitkant synchronize #234
  • Feb 09 09:08

    pitkant on pitkant_cranfix

    Explicitly state person field p… (compare)

  • Feb 09 08:50
    antagomir commented #234
  • Feb 09 08:36
    pitkant opened #234
  • Feb 09 08:36
    pitkant review_requested #234
  • Feb 08 15:53

    pitkant on pitkant_cranfix

    Remove package version from art… Remove comma (compare)

Joona Lehtomäki
@jlehtoma
@muuankarski could be an issue with GDAL reading TopoJSON or then something funky has been going down in producing the TopoJSON files
No personal experience on the CRSs / TopoJSON tho
But: everything seems to be in order, so carry on :)
Leo Lahti
@antagomir
il
Markus Kainu
@muuankarski

One issue still prevails, as in current implementation of get_eurostat_geospatial user can opt for SpatialPolygonDataFrame , fortified data.frame or sf output. We could provide those conversions "on-the-fly" if we will rely on the json-files from eurostat (now they come preprocessed using download.file()). If we would provide all three it would require following steps on-the-fly.

# =======================================================
# If user passes output_class = "sf" OR does not spesify it (default behaviour)
## Download and return a sf-object
# =======================================================
library(sf)
library(dplyr)
jsontemp <- tempfile()
download.file("http://ec.europa.eu/eurostat/cache/GISCO/distribution/v1/geojson/nuts-2013/NUTS_RG_60M_2013_4258_LEVL_0.geojson",
              jsontemp)
shape <- sf::st_read(jsontemp, stringsAsFactors = FALSE)
return(shape)

# =======================================================
# If user passes output_class = "sp" this is done in addition to default behaviour
## Convert sf-object into sp-object SpatialPolygonDataFrame
# =======================================================
shape_sp <- as(shape, "Spatial")
return(shape_sp)

# =======================================================
# If user passes output_class = "data.frame" this is done in addition to steps above
## Convert SpatialPolygonDataFrame into "fortified" regular data.frame to be plotted with ggplot2::geom_polygon
# =======================================================
shape_sp$id <- row.names(shape_sp)
fortified <- broom::tidy(shape_sp)
fortified <- left_join(fortified,shape_sp@data)
return(fortified)

@jlehtoma what do you think, is that feasible to do on-the-fly OR should we provide just a sf-output and nothing else..?

Leo Lahti
@antagomir
sf could be default and others optional ?
Markus Kainu
@muuankarski

Yep, that is the current behavior (in sf-branch), but providing the other options would require adding broom-dependency at least.

I could try with preserving the exact same behavior as currently, but change the source and processing. A new attribute would be nuts_level where user could pass either 0,1,2,3 or all. all would be default allowing the current behavior of subsetting with inner_join only.

Leo Lahti
@antagomir
Sound very good to me. I think we can import one more package but it is true that we are starting to have quite many imported packages. Could investigate at some point if these can be reduced.. or splitting data retrieval and geovisualization components in separate packages is also an option (though perhaps a bit complicated one)
Markus Kainu
@muuankarski
rOpenGov/eurostat@57d1686
now the basic idea is implemented. At least, cache needs to be revised. Can test with:
library(eurostat)
library(dplyr)
library(sf)
# sf
shape_sf <- get_eurostat_geospatial(nuts_level = "0", output_class = "sf")
shape_sf %>% select(NUTS_ID) %>% plot()
# data.frame
shape_df <- get_eurostat_geospatial(nuts_level = "0", output_class = "df")
shape_df %>% ggplot2::ggplot(.) + ggplot2::geom_polygon(aes(x=long,y=lat,group=group,fill=NUTS_ID))
# spdf
shape_spdf <- get_eurostat_geospatial(nuts_level = "0", output_class = "spdf")
sp::spplot(obj = shape_spdf, "NUTS_ID")
Leo Lahti
@antagomir
is this in master now ?
Markus Kainu
@muuankarski
no no, in simplefeatures branch
Leo Lahti
@antagomir
yees
i saw wrong
Markus Kainu
@muuankarski
i double checked..
Leo Lahti
@antagomir
yes it works ! (after adding library(ggplot2) in the beginning)
Markus Kainu
@muuankarski
\o/
Perhaps there is a better method for fetching this json data http://ec.europa.eu/eurostat/cache/GISCO/distribution/v1/geojson/nuts-2013/NUTS_RG_60M_2013_4258_LEVL_3.geojson than download.file()...
Leo Lahti
@antagomir
might be
Markus Kainu
@muuankarski
instead of download.file() I implemented it using httr::GETnow, the two options are listed below:
resolution <- "60"
# option 1
resp <- httr::GET(paste0("http://ec.europa.eu/eurostat/cache/GISCO/distribution/v1/geojson/nuts-2013/NUTS_RG_",resolution,"M_2013_4258_LEVL_1.geojson"))
nuts1 <- sf::st_read(httr::content(resp, as="text"), stringsAsFactors = FALSE)
# option 2
jsontemp <- tempfile()
download.file(paste0("http://ec.europa.eu/eurostat/cache/GISCO/distribution/v1/geojson/nuts-2013/NUTS_RG_",resolution,"M_2013_4258_LEVL_1.geojson"), jsontemp)
nuts1 <- sf::st_read(jsontemp, stringsAsFactors = FALSE)
Leo Lahti
@antagomir
you are a piece of gold
Markus Kainu
@muuankarski
I had a similar feeling for a second! Now have to hurry back to normal life and being a piece of shit!
Leo Lahti
@antagomir
!
Markus Kainu
@muuankarski
rOpenGov/eurostat@ff6defa here is the fix. Commits do show up nicely in the right side listing ->
Leo Lahti
@antagomir
nicee
Joona Lehtomäki
@jlehtoma
Very nice!
Leo Lahti
@antagomir
FedData package has functionality to download GIS data in US: https://ropensci.org/blog/technotes/2017/08/24/FedData-release
Joona Lehtomäki
@jlehtoma
Was just linking the same here, seems worth exploring
Leo Lahti
@antagomir
!