Skip to content

Commit

Permalink
Rename lat/lon and easting/northing
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Mar 28, 2017
1 parent 57d81c3 commit 32ce780
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions intro-spatial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,12 @@ The code below should help understand the way spatial data work in R.

```{r}
# Find the centre of the london area
lng <- coordinates(gCentroid(lnd))[[1]]
lat <- coordinates(gCentroid(lnd))[[2]]
easting_lnd <- coordinates(gCentroid(lnd))[[1]]
northing_lnd <- coordinates(gCentroid(lnd))[[2]]
# arguments to test whether or not a coordinate is east or north of the centre
east <- sapply(coordinates(lnd)[,1], function(x) x > lng)
north <- sapply(coordinates(lnd)[,2], function(x) x > lat)
east <- sapply(coordinates(lnd)[,1], function(x) x > easting_lnd)
north <- sapply(coordinates(lnd)[,2], function(x) x > northing_lnd)
# test if the coordinate is east and north of the centre
lnd@data$quadrant[east & north] <- "northeast"
Expand Down

0 comments on commit 32ce780

Please sign in to comment.