fude

農林水産省が公開する農地の区画情報(筆ポリゴン)を扱うRパッケージ

https://github.com/takeshinishimura/fude

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.8%) to scientific vocabulary
Last synced: 9 months ago · JSON representation

Repository

農林水産省が公開する農地の区画情報(筆ポリゴン)を扱うRパッケージ

Basic Info
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 7
Created about 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# fude


[![R-CMD-check](https://github.com/takeshinishimura/fude/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/takeshinishimura/fude/actions/workflows/check-standard.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/fude)](https://CRAN.R-project.org/package=fude)


The fude package provides utilities to facilitate the handling of the Fude Polygon data downloadable from the Ministry of Agriculture, Forestry and Fisheries (MAFF) website. The word "fude" is a Japanese counter suffix used to denote land parcels.


## Obtaining Data

Fude Polygon data can now be downloaded from two different MAFF websites (both available only in Japanese):

1. **GeoJSON format**:  
   

2. **FlatGeobuf format**:  
   

## Installation

You can install the released version of fude from CRAN with:
```r
install.packages("fude")
```

Or the development version from GitHub with:
```{r eval = FALSE}
# install.packages("devtools")
devtools::install_github("takeshinishimura/fude")
```

## Usage

### Reading Fude Polygon Data

There are two ways to load Fude Polygon data, depending on how the data was obtained:

1. **From a locally saved ZIP file**:  
This method works for both GeoJSON (from Obtaining Data #1) and FlatGeobuf (from Obtaining Data #2) formats. You can load a ZIP file saved on your computer without unzipping it.
```{r eval = FALSE}
library(fude)
d <- read_fude("~/2022_38.zip")
```
```{r echo = FALSE}
library(fude)
d <- read_fude("~/2022_38.zip", quiet = TRUE, supplementary = TRUE)
```

2. **By specifying a prefecture name or code**:  
This method is available only for FlatGeobuf data (from Obtaining Data #2). Provide the name of a prefecture (e.g., "愛媛") or its corresponding prefecture code (e.g., "38"), and the required FlatGeobuf format ZIP file will be automatically downloaded and loaded.
```{r eval = FALSE}
d2 <- read_fude(pref = "愛媛")
```
```{r echo = FALSE}
d2 <- read_fude("~/MB0001_2024_2020_38.zip", quiet = TRUE)
```

### Renaming the Local Government Code

**Note:** This feature is available only for data obtained from GeoJSON (Obtaining Data #1).

Convert local government codes into Japanese municipality names for easier management.
```{r}
dren <- rename_fude(d)
names(dren)
```

You can also rename the columns to Romaji instead of Japanese.
```{r}
dren <- d |> rename_fude(suffix = TRUE, romaji = "title")
names(dren)
```

### Getting Agricultural Community Boundary Data

Download the agricultural community boundary data, which corresponds to the Fude Polygon data, from the MAFF website:
 (available only in Japanese).
```{r eval = FALSE}
b <- get_boundary(d)
```
```{r echo = FALSE, warning = FALSE}
b <- get_boundary(d, path = "~", quiet = TRUE)
```

### Combining Fude Polygons with Agricultural Community Boundaries

You can easily combine Fude Polygons with agricultural community boundaries to create enriched spatial analyses or maps.

#### Characteristics of Data from GeoJSON (Obtaining Data #1)

```{r gogoshima, echo = TRUE, warning = FALSE, message = FALSE, dpi = 150}
db <- combine_fude(d, b, city = "松山市", community = "由良|北浦|鷲ケ巣|門田|馬磯|泊|御手洗|船越")

library(ggplot2)

ggplot() +
  geom_sf(data = db$fude, aes(fill = RCOM_NAME), alpha = .8) +
  guides(fill = guide_legend(reverse = TRUE, title = "興居島の集落別耕地")) +
  theme_void() +
  theme(legend.position = "bottom") +
  theme(text = element_text(family = "Hiragino Sans"))
```

**出典**:`r cite_fude(db)$ja`

##### Data Assignment

- `db$fude`: Automatically assigns polygons on the boundaries to a community.
- `db$fude_split`: Provides cleaner boundaries, but polygon data near community borders may be divided.
```{r nosplit_gogoshima, echo = TRUE, warning = FALSE, message = FALSE, dpi = 150, fig.width = 12, fig.height = 8}
library(patchwork)

fude <- ggplot() +
  geom_sf(data = db$fude, aes(fill = RCOM_NAME), alpha = .8) +
  theme_void() +
  theme(legend.position = "none") +
  coord_sf(xlim = c(132.658, 132.678), ylim = c(33.887, 33.902))

fude_split <- ggplot() +
  geom_sf(data = db$fude_split, aes(fill = RCOM_NAME), alpha = .8) +
  theme_void() +
  theme(legend.position = "none") +
  coord_sf(xlim = c(132.658, 132.678), ylim = c(33.887, 33.902))

fude + fude_split
```

If you need to adjust this automatic assignment, you will need to write custom code.
The rows that require attention can be identified with the following command.
```{r message = FALSE}
library(dplyr)
library(sf)

db$fude |>
  filter(polygon_uuid %in% (db$fude_split |> filter(duplicated(polygon_uuid)) |> pull(polygon_uuid))) |>
  st_drop_geometry() |>
  select(polygon_uuid, KCITY_NAME, RCOM_NAME, RCOM_ROMAJI) |>
  head()
```

#### Characteristics of Data from FlatGeobuf (Obtaining Data #2)

The FlatGeobuf format offers a more efficient alternative to GeoJSON.
A notable feature of this format is that each record already includes an **accurately assigned agricultural community code**.
```{r gogoshimafgb, echo = TRUE, warning = FALSE, message = FALSE, dpi = 150}
db2 <- combine_fude(d2, b, city = "松山市", community = "由良|北浦|鷲ケ巣|門田|馬磯|泊|御手洗|船越")

ggplot() +
  geom_sf(data = db2$fude, aes(fill = RCOM_NAME), alpha = .8) +
  guides(fill = guide_legend(reverse = TRUE, title = "興居島の集落別耕地")) +
  theme_void() +
  theme(legend.position = "bottom") +
  theme(text = element_text(family = "Hiragino Sans"))
```

**出典**:`r cite_fude(db2)$ja`

Data enables extraction based on city names, former village names, and agricultural community names.

**Note:** This feature is available only for data obtained from FlatGeobuf (Obtaining Data #2).

```{r message = FALSE}
d2 |> extract_fude(city = "松山市", kcity = "興居島")
```

### Review Fude Polygon Data

You can review Fude Polygon data in detail.
```{r shiny_fude, echo = TRUE, warning = FALSE, message = FALSE, dpi = 150}
library(shiny)

s <- shiny_fude(db, community = TRUE)
# shiny::shinyApp(ui = s$ui, server = s$server)
```

This feature was heavily inspired by the following website: .

### Using `mapview` package

If you want to use `mapview()`, do the following.
```{r eval = FALSE}
db1 <- combine_fude(d, b, city = "伊方町")
db2 <- combine_fude(d, b, city = "八幡浜市")
db3 <- combine_fude(d, b, city = "西予市", kcity = "三瓶|二木生|三島|双岩")

db <- bind_fude(db1, db2, db3)

library(mapview)

mapview::mapview(db$fude, zcol = "RCOM_NAME", layer.name = "農業集落名")
```

Owner

  • Login: takeshinishimura
  • Kind: user

GitHub Events

Total
  • Create event: 1
  • Release event: 1
  • Issues event: 2
  • Push event: 8
Last Year
  • Create event: 1
  • Release event: 1
  • Issues event: 2
  • Push event: 8

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 10
  • Total pull requests: 0
  • Average time to close issues: 3 days
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: about 1 hour
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • takeshinishimura (10)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 245 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 8
  • Total maintainers: 1
cran.r-project.org: fude

Utilities for Fude Polygon

  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 245 Last month
Rankings
Forks count: 28.3%
Dependent packages count: 28.3%
Average: 32.7%
Downloads: 34.8%
Stargazers count: 34.9%
Dependent repos count: 36.9%
Maintainers (1)
Last synced: 11 months ago