Coder Social home page Coder Social logo

inlmisc's Introduction

inlmisc

Build status CRAN Version CRAN Downloads Dependencies Coverage Status USGS Category

Description

The R package inlmisc is a collection of functions for creating high-level graphics, performing raster-based analysis, processing MODFLOW-based models, selecting subsets using a genetic algorithm, creating interactive web maps, accessing color palettes, etc. Used to support packages and scripts written by researchers at the U.S. Geological Survey (USGS) Idaho National Laboratory (INL) Project Office.

Installation

The current release is available on CRAN, which you can install using the following command:

install.packages("inlmisc", dependencies = TRUE)

A recent version of Pandoc (>= 1.12.3) is also required to run particular examples in the help documentation—RStudio includes this so you do not need to download Pandoc if working in a RStudio IDE. The webshot package is imported from and has as a dependency the external program PhantomJS, which may be installed using the command:

webshot::install_phantomjs()

For creating word clouds, the OptiPNG program is recommended and needs to be accessible through the command window. Finally, to install the development version of inlmisc, you need to clone the repository and build from source, or run:

if (!requireNamespace("remotes")) install.packages("remotes")
remotes::install_github("USGS-R/inlmisc", dependencies = TRUE)

Usage

Examples are given in the package help pages. To access this documentation, run:

library("inlmisc")
help(package = "inlmisc")

Author

Jason C. Fisher (ORCID iD 0000-0001-9032-8912)

Point of Contact

Jason C. Fisher ([email protected])

Suggested Citation

To cite inlmisc in publications, please use:

Fisher, J.C., 2020, inlmisc—Miscellaneous functions for the U.S. Geological Survey Idaho National Laboratory Project Office: U.S. Geological Survey software release, R package, Reston, Va.

Contributing

We welcome your contributions and suggestions for how to make these materials more useful to the community. Please feel free to comment on the issue tracker or open a merge request to contribute.

Code of Conduct

All contributions to- and interactions surrounding- this project will abide by the USGS Code of Scientific Conduct.

Disclaimer

This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey (USGS). No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty. The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software.

Any use of trade, product, or firm names is for descriptive purposes only and does not imply endorsement by the U.S. Government.

License

Unless otherwise noted, this project is in the public domain in the United States because it contains materials that originally came from the United States Geological Survey, an agency of the United States Department of Interior. For more information, see the official USGS copyright policy at copyrights-and-credits.

Additionally, we waive copyright and related rights in the work worldwide through the CC0 1.0 Universal public domain dedication.

CC0 1.0 Universal Summary

This is a human-readable summary of the Legal Code (read the full text).

No Copyright

The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.

You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Other Information

In no way are the patent or trademark rights of any person affected by CC0, nor are the rights that other persons may have in the work or in how the work is used, such as publicity or privacy rights.

Unless expressly stated otherwise, the person who associated a work with this deed makes no warranties about the work, and disclaims liability for all uses of the work, to the fullest extent permitted by applicable law. When using or citing the work, you should not imply endorsement by the author or the affirmer.

Support

The Idaho National Laboratory Project Office of the USGS supports the development and maintenance of inlpubs. Resources are available primarily for maintenance and responding to user questions. Priorities on the development of new features are determined by the development team.

inlmisc's People

Contributors

jfisher-usgs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

inlmisc's Issues

`PlotMap()` relying on bugous `range(NA, finite=TRUE)`

As was noted a few days ago on the R-devel mailing list,
https://stat.ethz.ch/pipermail/r-devel/2017-October/075037.html
that R's behavior for range(c(TRUE,FALSE,NA), finite=TRUE) has been wrongly returning
two NA's, e.g. as opposed to range( as.numeric(c(TRUE,FALSE,NA)), finite=TRUE)

In the mean time I (as R Core member) have fixed this bug in the development version of R and yesterday have ported the patch to "R 3.4.2 patched" (planned to become R 3.4.3 soonish).

Unfortunately, your PlotMap() function has been relying on this buggy behavior in a way that it now (after the change) fails.

I now see you've fixed this yesterday, by removing finite=TRUE from
https://github.com/USGS-R/inlmisc/blob/master/R/PlotMap.R#L265
However I'd encourage a slightly different change (because you do want to get rid of +/- Inf I think:


  if (anyNA(r[])) {
    n <- 0
  } else {
    zran <- range(r[], finite=TRUE)

But of course it's your call and code.
In any case, it will be good to upload a new version of the package to CRAN.

Best regards,
Martin Maechler

The example of ReadCodeChunks

Do you mind using an Rmd file of your own?

#' path <- system.file("doc", "knitr-intro.Rmd", package = "knitr")

I'm asking because this will make it difficult for me to rename the file in the future, although it should be unlikely. Thanks!

NOTICE: upcoming default branch name change

The master branch of this repository will soon be renamed from master to main, as part of a coordinated change across the USGS-R and USGS-VIZLAB organizations. This is part of a broader effort across the git community to use more inclusive language. For instance, git, GitHub, and GitLab have all changed or are in the process of changing their default branch name.

We will make this change early in the week of February 6, 2022. The purpose of this issue is to give notification of the change and provide information on how to make it go smoothly.

When this change is made, forks and clones of the repository will need to be updated as well. Here are instructions for making the necessary changes.

  • On GitHub, change the default branch name from master to main (<your repository> -> Settings -> Branches).
  • Change the default branch on any forks you have, as well as local clones. (See details below)
  • If you have collaborators on this repository, let them know that they will need to change their forked/local repos. Point them to this issue to facilitate the process!
  • Search within your repository for "master" so that you can change references (e.g. URLs pointing to specific commit points of files) to point to "main" instead.
  • When you are done, feel free to close this issue!

Changing default branches on forks and local clones

First, update your local git configuration so that new repositories created locally will have the correct default branch: git config --global init.defaultBranch main.

Now, for any forks, do the following:

  1. Go to <your fork> -> Settings -> Branches and edit the default branch from master to main.
  2. Update the settings for your local clone of this fork to match this change.
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

Possible GEOS version vulnerability (3.7.2)

Running reverse dependency checks on rgdal, I've hit an error

Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false,  : 
  TopologyException: Input geom 0 is invalid: Ring Self-intersection at or near point 2 3 at 2 3

in the Grid2Polygons() example. It occurs in sp.polys.df <- raster::crop(sp.polys.df, ply) which uses rgeos. My GEOS is 3.7.2-CAPI-1.11.2.

Error in createPolygonsComment(p) when using PlotCrossSection

@jfisher-usgs I know some spatial libraries are(will) unavailable, which may cause issues with this package. However, I would like to know if the error I am getting has to do with it and if it is easy to fix:

Error in createPolygonsComment(p) : 
  rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 250

This was my function call:

    PlotCrossSection(transect1, raster::stack(DEM, KWHM_stack[[1]][[1:54]], KWHM_stack[[var]][[1:54]]),
                     ylim = ylim,
                     geo.lays = c("LE_m_lyr00", names(KWHM_stack[[1]][[1:54]])),
                     val.lays = names(KWHM_stack[[var]][[1:54]]),
                     breaks = breaks,
                     ylab = "Elevation, m", asp = asp,
                     id = c("A", "A'"),
                     explanation = paste0(KWHM_vars[var], ", ", KWHM_unit[var]),
                     bg.col = "#E1E1E1",
                     scale.loc = NULL,
                     draw.sep = F,
                     max.dev.dim = c(36, 33),
                     file = paste0(rd, "ParFlow_inputs/Parameters/", KWHM_vars[var], "_KWHM_AAtest'.png"))

Thanks!

How to use GetColors in ggplot ecosystem ?

Thank you for your great tools!

I am getting some trouble to use your color schemes on ggplot.
Obtained object format with inlmisc::GetColors() seems to be different depend on the presence/absence of "scheme =" option.

Here is an example

 cols <- inlmisc::GetColors(n=6)
 cols 

[1] "#E7EBFA" "#92559E" "#4F97BA" "#A1BE58" "#E5702F" "#521913"
attr(,"nan")
[1] "#666666"
attr(,"call")
GetColors(n = 6, scheme = "smooth rainbow", alpha = NULL, stops = c(0,
1), bias = 1, reverse = FALSE, blind = NULL, gray = FALSE)
attr(,"class")
[1] "inlpal" "character"

 cols_o <- inlmisc::GetColors(n=6,  scheme = "bright")
cols_o
 blue       red     green    yellow      cyan    purple 

"#4477AA" "#EE6677" "#228833" "#CCBB44" "#66CCEE" "#AA3377"
attr(,"nan")
[1] NA
attr(,"call")
GetColors(n = 6, scheme = "bright", alpha = NULL, stops = c(0,
1), bias = 1, reverse = FALSE, blind = NULL, gray = FALSE)
attr(,"class")
[1] "inlpal" "character"

I want to use obtained color objects like this...

g<-
  ggplot(iris,aes(x=Species, y =Sepal.Length, fill=Species))+
  geom_violin()

g+  scale_fill_manual(values=cols) # expected work
g+  scale_fill_manual(values=cols_o) # unexpected work

Do you have any plan to unify the output format or any idea around the situation?

PlotCrossSection issue with extents

I am trying to plot the geologic cross-section between two layers using a raster stack with three elements: (1) elevation of layer 1, (2) elevation of layer 2, and (3) horizontal hydraulic conductivity of layer 1. Here is part of my code:

explanation <- "Horizontal Hydraulic Conductivity"
PlotCrossSection(transect, GW_stack, geo.lays = LE_names[c(1,2)],
val.lays = HK_names[1],
ylab = "Elevation, m", asp = 5,
unit = "METERS", explanation = explanation,
bg.col = "#E1E1E1", bend.label = "BEND IN\nSECTION",
scale.loc = NULL)
AddScaleBar(unit = "HK, m/hr", vert.exag = 5, inset = 0.05)

PlotCrossSection is generating this error message: "Error in .local(x, y, ...) : extents do not overlap". I double-checked the extent of the three layers, and they are the same. How can I overcome this issue? Do the rasters need to have values all over the extent? or how the library handles rasters with certain areas with NA values?

Thanks!

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.