Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal of some updates to read_habitatmap_xxx() #140

Merged
merged 13 commits into from
May 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions R/read_habitatdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@
#' each of them. The variable \code{certain} will be \code{FALSE} if
#' the original code consists of 2 or 3 possible vegetation types, and \code{TRUE}
#' if only one vegetation type is provided.
#' \itemize{
#' \item Note that this does not hold for the following codes:
#' \code{3130,rbbmr},
#' \code{3140,rbbmr},
#' \code{3150,rbbmr} and
#' \code{3160,rbbmr}.
#' These are standing water bodies that contain both \code{rbbmr} and the
#' habitat type.
#' Since \code{habitatmap_stdized_2020_v1} this has been taken into
#' account (setting \code{certain} as \code{TRUE} for both types).
#' }
#' \item Some polygons contain both a standing water habitat type
#' and \code{rbbmr}, e.g.:
#' \code{3130_rbbmr},
#' \code{3140_rbbmr},
#' \code{3150_rbbmr} and
#' \code{3160_rbbmr}.
#' Since \code{habitatmap_stdized_2020_v1}, the two vegetation
#' types \code{31xx} and \code{rbbmr} are split up and one row is
#' created for each of them.
#' The variable \code{certain} in this case will be \code{TRUE} for both types.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About issue #117:

you may want to add a note on the interpretation of phab for code combinations from one column of the original habitatmap

Should also be mentioned in the geospatial hab vignette, but I think this can be useful here too, so:

Suggested change
#' created for each of them.
#' The variable \code{certain} in this case will be \code{TRUE} for both types.
#' created for each of them, with \code{phab} for each new row simply
#' set to the original value of \code{phab}.
#' The variable \code{certain} in this case will be \code{TRUE} for both types.
#' \itemize{
#' \item Note that this implies that the a given polygon could contain the same
#' type with variable \code{certain} as \code{TRUE} several times, e.g. when:
#' \code{31xx_rbbmr} is present with \code{phab} = yy% and
#' \code{31xx} is present with \code{phab} = zz%.
#' In that case the rows with the same \code{polygon_id}, \code{type}
#' and \code{certain} were gathered into one row and the respective
#' \code{phab} were summed up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks! I'll re-add your suggestion as a new commit, as the lines it depends on are flagged as outdated (so cannot apply suggestion).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm supposing this bullet is at a lower level. The {} of \itemize needed to be closed 😉

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cecileherr Are you sure this is restricted to 31xx_rbbmr and it does not occur in general?

Anyway, the code executes this as a general rule. So I think it will be better to state it in general and add this bullet as a subnote under the first bullet (where you added 'with phab for each new row simply set to the original value of phab').

I leave consideration to you; I'll postpone the initial plan of adding the above suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sidenote: it appears that '%' needs to be escaped as \%

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cecileherr Are you sure this is restricted to 31xx_rbbmr and it does not occur in general?

Anyway, the code executes this as a general rule. So I think it will be better to state it in general and add this bullet as a subnote under the first bullet (where you added 'with phab for each new row simply set to the original value of phab').

I thought it was a general rule in the code, but that it only happened for the 31xx_rbbmr case, but I was wrong (e.g. 605723_v2014 is an example for the uncertain case). I would be tempted to add this is as 3rd item (after the uncertain case and the 31xx_rbbmr case), instead of making a subitem out of it.

Something like (other items abbreviated):

#'     \itemize{

#'     \item For some polygons the vegetation type is uncertain (...)
#'     if only one vegetation type is provided.

#'     \item Some polygons contain both a standing water habitat type (...)
#'     created for each of them, with \code{phab} for each new row simply 
#'     set to the original value of \code{phab}. 
#'     The variable \code{certain} in this case will be \code{TRUE} for both types.

#'     \item After those first two steps, a given polygon could contain the same 
#'     type with the same value for \code{certain} several times, e.g. when:
#'     \code{31xx_rbbmr} is present with \code{phab} = yy\% and
#'     \code{31xx} is present with \code{phab} = zz\%.
#'     In that case the rows with the same \code{polygon_id}, \code{type} 
#'     and \code{certain} were gathered into one row and the respective 
#'     \code{phab} were summed up.

#'     \item For some polygons the original vegetation code in the (...)
#'     code was adjusted.
#'   }

@florisvdh : your thought on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea @cecileherr. It better fits the idea of 'steps'.

Minor comments:

  • when: drop colon
  • summed up: means 'enumerated'; should become something like 'added up'.
  • with the same value for \code{certain} several times: I think '[...] repeated several times' is better

I suggest you add another suggestion in this PR, or else do it as commit in your branch update_habitat2020_ch (including the Rd file update) after merging this PR. Merging this branch is up to you anyway, since its target branch is yours.

#' \item For some polygons the original vegetation code in the
#' \code{habitatmap} was not consistent with general coding syntax or
#' with the type codes from the \code{\link{types}}. In that case the
Expand Down Expand Up @@ -1647,4 +1646,3 @@ if (references) {
return(habitatquarries)

}