forked from OpenDroneMap/FIELDimageR
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed NAMESPACE Bug on fieldRotate() and documentation improvements.
- Loading branch information
1 parent
e09b18b
commit 8bf4564
Showing
46 changed files
with
1,593 additions
and
1,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^Dockerfile$ | ||
^\.dockerignore$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.RData | ||
.Rhistory | ||
.git | ||
.gitignore | ||
manifest.json | ||
rsconnect/ | ||
Rproj.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,45 @@ | ||
Package: FIELDimageR | ||
Type: Package | ||
Title: FIELDimageR: A R Package to Analyze Orthomosaic Images from Agricultural Field Trials | ||
Version: 0.2.9 | ||
Author: Filipe Inacio Matias | ||
Maintainer: Filipe Inacio Matias <fmatias@wisc.edu> | ||
Description: This package is a compilation of function to analyze pos-mosaicking images from research experimental fields, and allows to: reduce the mosaic dimension by cropping it in small sections; remove the soil effect; build vegetation indices; rotate the field and build the plot shape file; extract information for each plot; and evaluate stand count, plant height and canopy (greenness). | ||
License: GPL-2 | ||
Imports: sp, raster, plyr, EBImage, doParallel, foreach, parallel, maptools | ||
Sugested:rgdal, rgeos, igraph | ||
Title: A Tool to Analyze Orthomosaic Images From Agricultural Field Trials | ||
Version: 0.1.0 | ||
Authors@R: | ||
c(person(given = "Filipe", | ||
family = "Matias", | ||
role = c("cre", "aut"), | ||
email = "filipematias23@gmail.com")) | ||
Description: A compilation of functions to analyze orthomosaic images | ||
from research fields. To prepare the image it first allows to crop the image, remove soil | ||
and weeds and rotate the image. The package also builds a plot shapefile in order to extract | ||
information for each plot to evaluate different wavelengths, vegetation indices, stand count, | ||
canopy percentage, and plant height. | ||
License: GPL-3 + file LICENSE | ||
biocViews: | ||
Imports: | ||
EBImage, | ||
attempt, | ||
config (>= 0.3.1), | ||
DT, | ||
fftwtools, | ||
git2r, | ||
glue, | ||
maptools, | ||
methods, | ||
raster, | ||
rgdal, | ||
scales, | ||
sp, | ||
xml2, | ||
foreach, | ||
doParallel, | ||
plyr, | ||
processx, | ||
grDevices | ||
Encoding: UTF-8 | ||
LazyData: true | ||
URL: https://github.com/OpenDroneMap/FIELDimageR | ||
RoxygenNote: 6.1.1 | ||
biocViews: EBImage | ||
RoxygenNote: 7.1.1 | ||
Author: Filipe Matias [cre, aut] | ||
Maintainer: Filipe Matias <filipematias23@gmail.com> | ||
Suggests: | ||
spelling, | ||
testthat (>= 3.0.0) | ||
Config/testthat/edition: 3 | ||
Language: en-US |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,68 @@ | ||
export(fieldRotate,fieldCrop,fieldShape,fieldPolygon,fieldObject,fieldIndex,fieldMask,fieldMap,fieldInfo,fieldPlot,fieldCount,fieldArea,fieldDraw) | ||
importFrom("sp", "Polygons","Polygon","SpatialPolygonsDataFrame","SpatialPolygons","spsample","SpatialPointsDataFrame","over", "proj4string") | ||
importFrom("raster", "stack", "projection","plotRGB","res","projectRaster","crs","extent","atan2","crop","rasterToPolygons","mask","extract","clump","drawLine","drawPoly","xyFromCell") | ||
importFrom("maptools", "elide") | ||
importFrom("parallel", "makeCluster", "detectCores") | ||
importFrom("foreach", "foreach", "%dopar%") | ||
importFrom("doParallel", "registerDoParallel") | ||
importFrom("graphics", "abline", "axis", "lines", "par", "plot","points","locator","legend") | ||
importFrom("utils", "read.csv") | ||
importFrom("grDevices", "rgb", "col2rgb") | ||
importFrom("plyr", "join") | ||
importFrom("EBImage","watershed","distmap") | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(fieldArea) | ||
export(fieldCount) | ||
export(fieldCrop) | ||
export(fieldDraw) | ||
export(fieldIndex) | ||
export(fieldInfo) | ||
export(fieldMap) | ||
export(fieldMask) | ||
export(fieldObject) | ||
export(fieldPlot) | ||
export(fieldPolygon) | ||
export(fieldRotate) | ||
export(fieldShape) | ||
importFrom(EBImage,distmap) | ||
importFrom(EBImage,watershed) | ||
importFrom(doParallel,registerDoParallel) | ||
importFrom(foreach,"%dopar%") | ||
importFrom(foreach,foreach) | ||
importFrom(grDevices,col2rgb) | ||
importFrom(grDevices,colorRamp) | ||
importFrom(grDevices,grey) | ||
importFrom(grDevices,rgb) | ||
importFrom(graphics,abline) | ||
importFrom(graphics,axis) | ||
importFrom(graphics,legend) | ||
importFrom(graphics,lines) | ||
importFrom(graphics,locator) | ||
importFrom(graphics,par) | ||
importFrom(graphics,plot) | ||
importFrom(graphics,points) | ||
importFrom(maptools,elide) | ||
importFrom(methods,as) | ||
importFrom(methods,slot) | ||
importFrom(parallel,detectCores) | ||
importFrom(raster,as.data.frame) | ||
importFrom(raster,as.list) | ||
importFrom(raster,as.matrix) | ||
importFrom(raster,atan2) | ||
importFrom(raster,clump) | ||
importFrom(raster,crop) | ||
importFrom(raster,crs) | ||
importFrom(raster,drawLine) | ||
importFrom(raster,drawPoly) | ||
importFrom(raster,extent) | ||
importFrom(raster,extract) | ||
importFrom(raster,mask) | ||
importFrom(raster,plotRGB) | ||
importFrom(raster,projectRaster) | ||
importFrom(raster,projection) | ||
importFrom(raster,raster) | ||
importFrom(raster,rasterToPolygons) | ||
importFrom(raster,res) | ||
importFrom(raster,stack) | ||
importFrom(raster,values) | ||
importFrom(raster,xyFromCell) | ||
importFrom(sp,Polygon) | ||
importFrom(sp,Polygons) | ||
importFrom(sp,SpatialPointsDataFrame) | ||
importFrom(sp,SpatialPolygons) | ||
importFrom(sp,SpatialPolygonsDataFrame) | ||
importFrom(sp,bbox) | ||
importFrom(sp,over) | ||
importFrom(sp,proj4string) | ||
importFrom(sp,spsample) | ||
importFrom(stats,dist) | ||
importFrom(utils,read.csv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#' fieldCrop | ||
#' | ||
#' @title Selecting experimental field from original image | ||
#' | ||
#' @description It calculates the percentage of object area in the entire mosaic or per plot using the fieldShape file. | ||
#' | ||
#' @param mosaic object mask of class stack from the function \code{\link{fieldMask}}. | ||
#' @param fieldShape crop the image using the fieldShape as reference. If fieldShape=NULL, four points should be selected | ||
#' directly on the original image to determine the experimental field. | ||
#' @param nPoint number of points necessary to select field boundaries or area to remove (4 >= nPoint <= 50). | ||
#' @param remove if TRUE the selected area will be removed from the image. | ||
#' @param plot if \code{TRUE} (by default) plots the original and cropped image. | ||
#' @param type character indicating the type of plotting, please check help("lines"). | ||
#' @param lty line types, please check help("lines"). | ||
#' @param lwd line width, please check help("lines"). | ||
#' @param fast.plot if TRUE only the grey scale image will be plotted as reference (faster approach). | ||
#' if TRUE only the grey scale image will be plotted as reference (faster approach). | ||
#' | ||
#' @importFrom raster plotRGB mask | ||
#' @importFrom graphics locator lines | ||
#' @importFrom sp Polygons Polygon SpatialPolygonsDataFrame SpatialPolygons | ||
#' | ||
#' | ||
#' @return A image format stack. | ||
#' | ||
#' @export | ||
fieldCrop <- function(mosaic, fieldShape = NULL, nPoint = 4, plot = TRUE, remove = FALSE, type = "l", | ||
lty = 2, lwd = 3, fast.plot = FALSE) { | ||
mosaic <- stack(mosaic) | ||
num.band <- length(mosaic@layers) | ||
print(paste(num.band," layers available", sep = "")) | ||
if(nPoint<4|nPoint>50){stop("nPoint must be >= 4 and <= 50")} | ||
par(mfrow=c(1,2)) | ||
if(is.null(fieldShape)|plot){ | ||
if(fast.plot){ | ||
raster::plot(mosaic[[1]], col=grey(1:100/100), axes=FALSE, box=FALSE, legend=FALSE)} | ||
if(!fast.plot){ | ||
if(num.band>2){plotRGB(RGB.rescale(mosaic,num.band=3), r = 1, g = 2, b = 3)} | ||
if(num.band<3){raster::plot(mosaic, axes=FALSE, box=FALSE)}} | ||
} | ||
if(!is.null(fieldShape)){ | ||
if(raster::projection(fieldShape) != raster::projection(mosaic)){ | ||
stop("fieldShape and mosaic must have the same raster::projection CRS. Use fieldRotate() for both files.") | ||
} | ||
r <- crop(x = mosaic, y = fieldShape) | ||
} | ||
c1 <- NULL | ||
if(is.null(fieldShape)) { | ||
print(paste("Select ",nPoint," points at the corners of field of interest in the plots space.",sep = "")) | ||
for(i in 1:nPoint){ | ||
c1.1<-locator(type="p",n = 1, col="red",pch=19) | ||
c1<-rbind(c1,c(c1.1$x,c1.1$y)) | ||
} | ||
c1<-rbind(c1,c1[1,]) | ||
colnames(c1)<-c("x","y") | ||
lines(c1, col= "red", type=type, lty=lty, lwd=lwd) | ||
} | ||
if(!is.null(c1)) { | ||
p1 <- Polygons(list(Polygon(c1)), "x") | ||
f1 <- SpatialPolygonsDataFrame( SpatialPolygons(list(p1)), data.frame( z=1, row.names=c("x") ) ) | ||
raster::projection(f1) <- raster::projection(mosaic) | ||
if(!remove){r <- crop(x = mosaic, y = f1)} | ||
if(remove){r <- mask(x = mosaic, mask = f1, inverse = remove)} | ||
} | ||
r <- stack(r) | ||
if(plot){ | ||
if(fast.plot) { | ||
raster::plot(r[[1]], col=grey(1:100/100), axes=FALSE, box=FALSE, legend=FALSE)} | ||
if(!fast.plot){ | ||
if(num.band>2){plotRGB(RGB.rescale(r,num.band=3), r = 1, g = 2, b = 3)} | ||
if(num.band<3){raster::plot(r, axes=FALSE, box=FALSE)}}} | ||
par(mfrow=c(1,1)) | ||
return(r) | ||
} |
Oops, something went wrong.