joelgombin / spReapportion

Reapportion Data From one Geography to Another in R
7 stars 0 forks source link

Matching problem with 2017 bureaux #6

Closed svhooren closed 5 years ago

svhooren commented 5 years ago

I used the package with the same data (my IRIS data, your shape bureaux 2012 and your data IRIS 2011) to understand and it was ok.

Then I wanted to use the same Data except for the shape bureaux 2017. ( )

I had an issue with my excell to make it into a shape to use in the script, but @pokyah found me a solution :

# read excel
dataExcel = readxl::read_excel("~/Downloads/bureaux-de-votes.xls", sheet = "Sheet")

# splitting the geo_point_2d in to columns lon and lat
dataExcel = dataExcel %>%
  tidyr::separate(geo_point_2d, c("lat", "lon"), ",") %>%
  dplyr::mutate_at(vars(c("lon","lat")), funs(as.numeric)) %>%
  dplyr::select(-one_of("geo_shape"))

# making it a sf 
dataExcelsf = sf::st_as_sf(dataExcel, coords = c("lon", "lat"))

# setting the CRS
dataExcelsf = sf::st_set_crs(dataExcelsf, 4326)

# view it on a map
mapview::mapview(dataExcelsf)

# making it a sp
dataExcelsf = as(dataExcelsf, "Spatial")

But even with this help, I'm stuck with an error message and i can't find the error in the R script of spReaportion.

capture d ecran 2019-03-07 a 17 44 24

Maybe my data are not usable in this script ?

Thanks