# Mindat Data

#### Xiang Que

#### 2025-06-04

## Load libraries

    #library(httr)
    #library(jsonlite)
    #library(OpenMindat)
    #library(tidyverse)
    #library(sf)
    #library(mapview)

## Connect to the Mindat API

    #mindat_connection("3214e7170011236535c9a6e17d4ebd69", page_size = 1500)

## Demo 1- Map the retieved Localities that contains As

    #mapview(localities_list_elems_inc(c("As")), xcol = "longitude", ycol = "latitude", crs = 4269, grid = FALSE)#"Dy","Li"

## Demo 2- Map the retieved Localities within an given country

    #mapview(localities_list_country(c("Sweden")), xcol = "longitude", ycol = "latitude", crs = 4269, grid = FALSE)

## Demo 3- Map the retieved Localities that contains the input description.

    #mapview(localities_list_description("volcano"), xcol = "longitude", ycol = "latitude", crs = 4269, grid = FALSE)

## Demo 4- Map the retieved Localities that contains the input description.

    #df_elements<-minerals_ima_list_ima(1)$type_localities
    #df_out <- data.frame()
    #for (elements in df_elements) {
    #  elm_id_list <- as.list(elements)
    #  for (elm in elm_id_list){
    #    df_cur_locality <- localities_retrieve_id(elm)
    #    df_out <- rbind(df_out,df_cur_locality)
    #  }
    #}
    #df_out$longitude <- as.numeric(df_out$longitude)
    #df_out$latitude <- as.numeric(df_out$latitude)
    #mapview(df_out2, xcol = "longitude", ycol = "latitude", crs = 4269, grid = FALSE)

## More Examples

Please refer to: https://github.com/quexiang/OpenMindat