You can either reproject your polygon shapefile OR your dataset. EPSG is a short code for spatial projections. EPSG:4326 is the code for non-projected data in degrees using wgs84: http://spatialreference.org/ref/epsg/4326/
Reproject your polygon into 4326
france_wgs84 <- spTransform(france_L93, CRS("+init=epsg:4326"))
Reproject your dataset into Lambert93
data <- structure(list(centerid = c("0121H1", "0121H2", "0218H3", "0303H1",
"0303H2"), latitude = c(46.2236804, 46.2236804, 49.3700842, 46.3429172,
46.3429172), longitude = c(5.2108193, 5.2108193, 3.335127, 2.6089958,
2.6089958), adresse_complete = c("900 Route de Paris, 01440 Viriat, France",
"900 Route de Paris, 01440 Viriat, France", "46 Avenue du Général de Gaulle, 02200 Soissons, France",
"18 Avenue du 8 Mai 1945, 03100 Montluçon, France", "18 Avenue du 8 Mai 1945, 03100 Montluçon, France"
)), .Names = c("centerid", "latitude", "longitude", "adresse_complete"
), row.names = c(NA, 5L), class = "data.frame")
coordinates(data) <- ~longitude+latitude
proj4string(data) <- "+init=epsg:4326"
data_L93 <- spTransform(data, CRS("+proj=lcc +lat_1=44 +lat_2=49 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m
+no_defs"))
Here's a way, first I'll create a fake data set.
library(raster)
r <- raster(matrix(1:30, 5, 6))
## this is the full data set in data frame form
dfull <- as.data.frame(r, xy = TRUE)
## this is the partial data set, only the points with a valid value
## row-order doesn't matter, but we keep it for illustration
set.seed(10)
dpart <- dfull[sort(sample(seq_len(nrow(dfull)), 22)), ]
Now we need raster's cell-abstraction tools. Here we can treat r
like an raw specification of the original raster, and in fact create it from scratch if needed. But, we have it so we use it.
rspec <- raster(r) ## this drops the data, keeps the structure
This fills the data with missing values , because raster doesn't truly have "sparse forms", they are either empty or full and we cannot put values piece-wise into an empty raster, it's either all or nothing until it's not empty.
(Note that sparse forms are supported completely by this approach, but via a level of abstraction that is the responsibility of the user)
rspec[] <- NA_real_
Now we need an index into the "structure of the raster" for our points.
## these names were nominated above, and might be different for a different
## input
cells <- cellFromXY(rspec, as.matrix(dpart[, c("x", "y")])
Now, put the values in the data frame into the otherwise "filled with missing" raster.
rspec[cells] <- dpart$layer
All this is illustrated in full here: http://rpubs.com/cyclemumner/294656
It's a very powerful approach, but it's not widely understood and it's easy to get it wrong, so do use with caution and take time to practice and understand it.
Happy to help if it doesn't make sense.
Best Answer
From your question I get that you want to create a raster that has the extent of the entire world. Here is a way that you can use in order to create the raster and find the centroids of each grid cell.