https://github.com/mdsumner/ozmaps
Australian maps
https://github.com/mdsumner/ozmaps
Last synced: about 1 year ago
JSON representation
Australian maps
- Host: GitHub
- URL: https://github.com/mdsumner/ozmaps
- Owner: mdsumner
- Created: 2019-11-05T11:36:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-25T11:43:13.000Z (almost 5 years ago)
- Last Synced: 2025-03-26T09:22:09.782Z (about 1 year ago)
- Language: R
- Homepage: https://mdsumner.github.io/ozmaps/
- Size: 47.6 MB
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
editor_options:
chunk_output_type: console
---
[](https://travis-ci.org/mdsumner/ozmaps)
[](https://travis-ci.org/mdsumner/ozmaps)
[](https://ci.appveyor.com/project/mdsumner/ozmaps)
[](https://cran.r-project.org/package=ozmaps)

[](https://codecov.io/github/mdsumner/ozmaps?branch=master)
```{r setup, include = FALSE}
library(dplyr)
library(sf)
library(rmapshaper)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
#knitr::read_chunk("data-raw/download_2016.R")
```
# Overview
The goal of ozmaps is to get maps of Australia to plot!
# Installation
Install from CRAN with
```{r install, eval=FALSE}
install.packages("ozmaps")
```
The development version of ozmaps may be installed directly from github.
```{r dev-install, eval = FALSE}
devtools::install_github("mdsumner/ozmaps")
```
The package includes some *simple features* data, which can be used
independently of ozmaps with the `sf` package. If required, install `sf` from CRAN.
**NOTE:** Since April 2020) we *must* have sf installed because of
requirements of the tibble package.
If sf causes you problems or you can't work with it [get in touch](https://github.com/mdsumner/ozmaps/issues/) and I will help you.
```{r sf-install,eval=FALSE}
install.packages("sf")
```
## Usage
Plot Australia with states.
```{r ozmap}
library(ozmaps)
ozmap()
```
Plot Australia without states.
```{r country}
ozmap(x = "country")
```
Add to an existing plot.
```{r add-plot}
plot(quakes[c("long", "lat")], xlim = c(120, 190))
ozmap(add = TRUE)
```
Obtain the data used in `sf` form.
```{r sf-format}
sf_oz <- ozmap_data("states")
tibble::as_tibble(sf_oz)
```
Plot with a custom palette.
```{r ochRe}
library(sf)
if (utils::packageVersion("paletteer") < '1.0.0') {
pal <- paletteer::paletteer_d(package = "ochRe", palette = "namatjira_qual")
} else {
pal <- paletteer::paletteer_d(palette = "ochRe::namatjira_qual")
}
opal <- colorRampPalette(pal)
nmjr <- opal(nrow(sf_oz))
plot(st_geometry(sf_oz), col = nmjr)
## plot directly with ggplot2
library(ggplot2)
ggplot(sf_oz, aes(fill = NAME)) + geom_sf() + coord_sf(crs = "+proj=lcc +lon_0=135 +lat_0=-30 +lat_1=-10 +lat_2=-45 +datum=WGS84") + scale_fill_manual(values = nmjr)
```
Plot the ABS layers (from 2016).
```{r abs}
ozmap("abs_ced", col = opal(nrow(abs_ced)))
ozmap("abs_ste", col = opal(nrow(abs_ste)))
```
## Resolution
These ABS layers `abs_ced`, `abs_lga`, and `abs_ste` are derived from the 2016 sources and simplified using `rmapshaper::ms_simplify(, keep = 0.05, keep_shapes = TRUE)` so all the original polygons are there. There is sufficient detail to map many (most?) of the regions on their own, which was a major goal for this package.
The cache of the source data at original resolution is available in [ozmaps.data](https://github.com/mdsumner/ozmaps.data/).
Compare the detail of Bruny Island here in this box, compared with the
very basic maps package layer.
```{r detail}
library(dplyr)
kbor <- abs_lga %>% dplyr::filter(grepl("Kingborough", NAME))
bb <- st_bbox(kbor)
layout(matrix(c(1, 1, 1, 2, 2, 2, 2, 2, 2), nrow = 3))
plot(kbor, reset = FALSE, main = "Kingborough (TAS)")
rect(bb["xmin"], bb["ymin"], bb["xmax"], bb["ymax"])
library(mapdata)
par(mar = rep(0, 4))
plot(c(145, 148.5), c(-43.6, -40.8), type = "n", asp = 1/cos(mean(bb[c(2, 4)]) * pi/180), axes = FALSE, xlab = "", ylab = "")
maps::map(database = "worldHires", regions = "australia", xlim = c(145, 148.5), ylim = c(-43.6, -40.8), add = TRUE)
rect(bb["xmin"], bb["ymin"], bb["xmax"], bb["ymax"])
```
---
Please note that the 'ozmaps' project is released with a [Contributor Code of Conduct](https://github.com/mdsumner/ozmaps/blob/master/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.