Code Monkey home page Code Monkey logo

neon-r-make-pretty-maps-plots's People

Contributors

bbest avatar dependabot[bot] avatar fmichonneau avatar kwiter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

neon-r-make-pretty-maps-plots's Issues

Create a map with a legend (categorical legend) in R

Hey @bbest @megwilliams @kwiter -- did any of you work on creating a map (or have you done this) where you have a shapefile (eg the roads_streams lines shapefile in our data ), and you create a map with the lines colored by category. IN essence "TYPE" or an attribute becomes a factor. We have the following below which seems a bit cumbersome but works. We are using the roads_streams shapefile.

I am not sure how to add a legend or to make a nice categorical plot. Is there a simple way to do and teach this?

Thanks for any ideas!

#color lines by TYPE attribute
type <- slot(object = lines, name = "data")$TYPE
#you can also write
type <- lines@data$TYPE

col <- rep(x= "black", length = length(type))
col[type == "footpath"] <- "red"

plot(x=lines, col=col,add=T)

Here is the latest version of the lesson that i'm working on

https://github.com/data-lessons/NEON-R-Spatial-Vector/blob/gh-pages/00-open-a-shapefile.Rmd

Make / Brew / Build options for all lessons

This issue is related to #4
where some interactive components don't render properly via jekyll. we might need to consider a local build option.

"You might consider opening a separate issue that tries to reconcile bringing these lessons together into a single site, factoring in this closed issue as a factor for consideration (if you want to include htmlwidgets) and one possibility to generate output (ie by skipping use of Jekyll and opting for simpler rendering methods like brew and Makefile)."

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.