Skip to content

Commit 4ec8f19

Browse files
committed
spatial_point_pattern: expand on CRS/proj4string/WKT2
1 parent 934c973 commit 4ec8f19

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • content/tutorials/spatial_point_pattern

content/tutorials/spatial_point_pattern/index.Rmd

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,27 @@ ggmap(map) +
3030
geom_point(data = points, alpha = 0.1, colour = "blue", shape = 4)
3131
```
3232

33-
The next step is to convert the dataset in to a `SpatialPoints` object with WGS84 project and re-project it into Lambert72. `sp::CRS()` defines the coordinate systems. `sp::coordinates()<-` is an easy way to convert a `data.frame` into a `SpatialPointsDataFrame`, but without specifying a coordinate system. Therefore we need to override the `proj4string` slot with the correct coordinate system. `sp::spTransform()` converts the spatial object from the current coordinate system to another coordinate system.
33+
The next step is to convert the dataset to a `SpatialPoints` object with WGS84 projection and re-project it to Belgian Lambert72.
34+
`sp::CRS()` defines the coordinate reference systems (CRS).
35+
`sp::coordinates()<-` is an easy way to convert a `data.frame` into a `SpatialPointsDataFrame`, but without specifying a CRS.
36+
Therefore we need to override the CRS with the correct one.
3437

35-
```{r reproject}
38+
`sp` will derive a 'WKT2 string' representation from an EPSG-code [^epsg] that we provide, in order to represent the CRS.
39+
The WKT2 string (well known text) is a recent open standard by the Open Geospatial Consortium to represent a CRS, and it replaces the older (deprecated) 'PROJ.4 string'.
40+
Currently, the function to set the CRS is still called `proj4string()`.
41+
`sp::spTransform()` converts the spatial object from the current CRS to another CRS.
42+
43+
[^epsg]: Most coordinate reference systems have an [EPSG](https://en.wikipedia.org/wiki/International_Association_of_Oil_%26_Gas_Producers#European_Petroleum_Survey_Group) code which you can find at http://epsg.io/.
44+
45+
```{r crs-objects}
3646
library(sp)
3747
crs_wgs84 <- CRS(SRS_string = "EPSG:4326")
3848
crs_lambert <- CRS(SRS_string = "EPSG:31370")
49+
```
50+
51+
The warning above once again demonstrates that some PROJ.4 information is not supported anymore.
52+
53+
```{r reproject}
3954
coordinates(points) <- ~lon + lat
4055
# proj4string() - still the only available function to set the CRS - may in the
4156
# future get a more general name:

0 commit comments

Comments
 (0)