Skip to content

Commit 0a0f6e3

Browse files
committed
spatial_point_pattern: improve markdown & language
1 parent 4ec8f19 commit 0a0f6e3

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

  • content/tutorials/spatial_point_pattern

content/tutorials/spatial_point_pattern/index.Rmd

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ params:
1111
cellsize: 20
1212
---
1313

14-
In this example we focus on a set of 10450 coordinates in a small area. The goal is to estimate the local density of points, expressed as the number of point per unit area. The raw coordinates are given in [WGS84 (EPSG:4326)](https://epsg.io/4326), which is a geodetic coordinate system. That is not suited for calculating distances, so we need to re-project the points into a local projected coordinate system. In this case we use [Lambert72 (EPSG:3170)](https://epsg.io/31370). Next we calculate the density. To visualise the density, we have to transform the results back in to WGS84.
14+
In this example we focus on a set of 10450 coordinates in a small area.
15+
The goal is to estimate the local density of points, expressed as the number of points per unit area.
16+
The raw coordinates are given in [WGS84 (EPSG:4326)](https://epsg.io/4326), which is a geodetic coordinate reference system.
17+
That is not suited for calculating distances, so we need to re-project the points into a local projected coordinate reference system.
18+
In this case we use [Belgian Lambert72 (EPSG:3170)](https://epsg.io/31370).
19+
Next we calculate the density.
20+
To visualise the density, we have to transform the results back to WGS84.
1521

16-
The data used in this example is real data by centred to a different location for privacy reasons. The dataset is available on [GitHub](https://github.com/ThierryO/my_blog/tree/master/data/20170628).
22+
The data used in this example is real data but centred to a different location for privacy reasons. The dataset is available on [GitHub](https://github.com/ThierryO/my_blog/tree/master/data/20170628).
1723

1824
First we must read the data into R. Plotting the raw data helps to check errors in the data.
1925

@@ -116,7 +122,12 @@ ggmap(map) +
116122
)
117123
```
118124

119-
Using `leaflet` to generate a map was a bit more laborious. Using the `data.frame dens_wgs`directly failed. So we converted the `data.frame` in a `SpatialPolygonsDataframe`, which is a combination of a `SpatialPolygons` and a `data.frame`. The `SpatialPolygons` consists of a list of `Polygons`, one for each row of the `data.frame`. A `Polygons` object consist of a list of one or more `Polygon` object. In this example a single polygon which represents the grid cell.
125+
Using `leaflet` to generate a map was a bit more laborious.
126+
Using the `data.frame dens_wgs`directly failed.
127+
So we converted the `data.frame` to a `SpatialPolygonsDataframe`, which is a combination of a `SpatialPolygons` and a `data.frame`.
128+
The `SpatialPolygons` consists of a list of `Polygons`, one for each row of the `data.frame`.
129+
A `Polygons` object consists of a list of one or more `Polygon` objects.
130+
In this example it is a single polygon which represents the grid cell.
120131

121132
```{r convert-to-Spatial-Polygons}
122133
dens_sp <- lapply(
@@ -137,7 +148,10 @@ dens_sp <- lapply(
137148
)
138149
```
139150

140-
`leaflet` requires a predefined function with a colour pallet. We use `leaflet::colorNumeric()` to get a continuous pallet. Setting `stroke = FALSE` removes the borders of the polygon. `fillOpacity` sets the transparency of the polygons.
151+
`leaflet` requires a predefined function with a colour palette.
152+
We use `leaflet::colorNumeric()` to get a continuous palette.
153+
Setting `stroke = FALSE` removes the borders of the polygon.
154+
`fillOpacity` sets the transparency of the polygons.
141155

142156
```{r leaflet, fig.cap = "Dynamic map of density"}
143157
library(leaflet)

0 commit comments

Comments
 (0)