---
title: "Okinawa and Ogasawara Insets"
description: "Include, exclude, or show Okinawa and Ogasawara as transported insets."
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Okinawa and Ogasawara Insets}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  fig.width = 7,
  fig.height = 5,
  dpi = 120,
  fig.bg = "white",
  dev.args = list(bg = "white")
)
jpmap_build_full_vignettes <- identical(tolower(Sys.getenv("JPMAP_FULL_VIGNETTES")), "true") ||
  identical(tolower(Sys.getenv("IN_PKGDOWN")), "true")
jpmap_has_boundary_data <- jpmap_build_full_vignettes &&
  nrow(jpmap::available_jpmap_data()) > 0
```

By default, `jpmap` transports Okinawa and Ogasawara into visible inset
locations.

```{r}
library(tidyverse)
library(jpmap)
```

```{r default-insets, eval = jpmap_has_boundary_data}
plot_jpmap("prefecture") +
  labs(title = "Default map with Okinawa and Ogasawara insets") +
  theme(
    plot.title = element_text(face = "bold", color = "#001040")
  )
```

## Remove One Inset

Use `ogasawara = FALSE` when you only want Okinawa moved.

```{r okinawa-only, eval = jpmap_has_boundary_data}
plot_jpmap(
  "prefecture",
  ogasawara = FALSE
) +
  labs(title = "Okinawa inset only") +
  theme(
    plot.title = element_text(face = "bold", color = "#001040")
  )
```

Use `okinawa = FALSE` when you only want Ogasawara moved.

```{r ogasawara-only, eval = jpmap_has_boundary_data}
plot_jpmap(
  "prefecture",
  okinawa = FALSE
) +
  labs(title = "Ogasawara inset only") +
  theme(
    plot.title = element_text(face = "bold", color = "#001040")
  )
```

## Adjust The Map Frame

Use `xlim` and `ylim` to set longitude/latitude limits. You can also set axis
breaks and labels. This example keeps the main islands and Okinawa while
dropping the Ogasawara inset.

```{r axis-controls, eval = jpmap_has_boundary_data}
plot_jpmap(
  "prefecture",
  ogasawara = FALSE,
  xlim = c(122, 149),
  ylim = c(28.5, 47),
  x_breaks = seq(125, 145, 5),
  y_breaks = seq(30, 45, 5),
  x_labels = function(x) paste0(x, "\u00b0E"),
  y_labels = function(y) paste0(y, "\u00b0N")
) +
  labs(title = "Main islands with Okinawa inset") +
  theme(
    plot.title = element_text(face = "bold", color = "#001040")
  )
```

## Remove The Boxes

Set `inset_boxes = FALSE` to keep the transported islands but remove the
visual frames. When boxes are shown, `jpmap` masks the ordinary main-panel
graticules inside each box and draws local longitude/latitude lines for the
transported island group. Those labels are the islands' original coordinates,
not the destination coordinates of the inset box.

```{r no-boxes, eval = jpmap_has_boundary_data}
plot_jpmap(
  "prefecture",
  inset_boxes = FALSE
) +
  labs(title = "Insets without boxes") +
  theme(
    plot.title = element_text(face = "bold", color = "#001040")
  )
```

## Use Literal Geography

Set `inset = FALSE` to keep every geometry in its projected geographic
location.

```{r literal-map, eval = jpmap_has_boundary_data}
plot_jpmap(
  "prefecture",
  inset = FALSE
) +
  labs(title = "Projected map without transported insets") +
  theme(
    plot.title = element_text(face = "bold", color = "#001040")
  )
```

## Control Disputed-Territory Shapes

Set `territorial_disputes = FALSE` to exclude areas discussed in Japan
territorial-dispute references. You can also pass a character vector to include
only selected regions, such as `territorial_disputes = "senkaku"` or
`territorial_disputes = c("senkaku", "takeshima")`.

Use `disputed_fill`, `disputed_color`, and `disputed_dots = TRUE` when you want
to emphasize these small islands and reefs.

```{r disputed-territories-highlight, eval = jpmap_has_boundary_data}
plot_jpmap(
  "prefecture",
  disputed_fill = "#005BAC",
  disputed_color = "#001040",
  disputed_dots = TRUE
) +
  labs(title = "Map with highlighted disputed-territory shapes") +
  theme(
    plot.title = element_text(face = "bold", color = "#001040")
  )
```

## What The Boxes Mean

The inset boxes are visual guide frames for the transported island groups. They
are sized to cover the Okinawa and Ogasawara source extents that `jpmap`
transports into the default map frame. The longitude/latitude labels drawn
inside a box describe the island group's true coordinates before transport.
The boxes themselves are still display frames, not legal boundary extents.

For Okinawa municipal maps, an available 2024 MLIT N03 Okinawa layer is
transported as Okinawa. For Ogasawara, the default box also covers the remote
Ogasawara pieces present in the available prefecture layer, such as
Minamitorishima. Use `inset = FALSE` when literal geographic placement matters
more than a compact display.

When `territorial_disputes = TRUE` includes Okinotorishima, the Ogasawara box is
expanded so the Okinotorishima reef shape remains visible. These
disputed-territory shapes are not official boundary polygons.
