Git Product home page Git Product logo

lab3package's Introduction

Lab3package

The goal of Lab3package is to thin the large shape files and convert it into a data frame containing Longitude, Latitude, group, order and NAME_1 or HASC_1 so that you can make a polygon figure colored by region(NAME_1 or HASC_1) using this data frame.

Installation

You can install the development version of Lab3package from GitHub with:

# install.packages("devtools")
devtools::install_github("JinjiPang/Lab3package")

Example

This is a basic example to show how to use functions in this package to create geometric data frame and some implementations.

library(Lab3package)
#> Registered S3 method overwritten by 'geojsonlint':
#>   method         from 
#>   print.location dplyr
data("Yemen")

First, you can download a shape file of a country of your choice. Then, you can either read the file using sf::read_sf()first or just use the file path to try the following codes:

team_2

This function will return a data frame with four basic variables, which are long, lat, order, and group.

library(tidyverse)
#> -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
#> v ggplot2 3.3.5     v purrr   0.3.4
#> v tibble  3.1.6     v dplyr   1.0.7
#> v tidyr   1.1.4     v stringr 1.4.0
#> v readr   2.1.1     v forcats 0.5.1
#> -- Conflicts ------------------------------------------ tidyverse_conflicts() --
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag()    masks stats::lag()

df1 <- team_2(Yemen, 0.1)

df1 %>%
  ggplot(aes(x = long, y = lat, group = group)) + geom_polygon()

team_5

This function will return a data frame with five basic variables, which are long, lat, order, group, and HASC_1.

library(tidyverse)

df2 <- team_5(Yemen, 0.1)

df2 %>%
  ggplot(aes(x = long, y = lat, group = group)) + geom_polygon(aes(fill = HASC_1))

team_6

This function will return a data frame with 15 variables, basically it keeps all the original variables and add three more variables long, lat, group, order and NAME_1.

library(tidyverse)

df3 <- team_6(Yemen, 0.1)

df3 %>%
  ggplot(aes(x = long, y = lat, group = group)) + geom_polygon(aes(fill = NAME_1))

lab3package's People

Contributors

jinjipang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.