Hi All: I am extending a package I have to allow users to provide a crs string, which will eventually through some other packages be sent to sf. I like to try and make at least minimal tests that inputs are valid. Is there some existing code that will check if a string is a valid crs string? Thanks, -Roy ********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
testing a crs string
3 messages · Roy Mendelssohn - NOAA Federal, Edzer Pebesma
On 6/20/19 4:18 PM, Roy Mendelssohn - NOAA Federal via R-sig-Geo wrote:
Hi All: I am extending a package I have to allow users to provide a crs string, which will eventually through some other packages be sent to sf. I like to try and make at least minimal tests that inputs are valid. Is there some existing code that will check if a string is a valid crs string?
inherits(try(sf::st_crs("+proj=invalid"), silent = TRUE), "try-error")
[1] TRUE
inherits(try(sf::st_crs("+proj=longlat"), silent = TRUE), "try-error")
[1] FALSE
Thanks, -Roy ********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics Heisenbergstrasse 2, 48151 Muenster, Germany Phone: +49 251 8333081 -------------- next part -------------- A non-text attachment was scrubbed... Name: pEpkey.asc Type: application/pgp-keys Size: 2472 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190620/b37d7539/attachment.bin>
perfect. Thank you. I thought there must be a function in one of the packages to check. -Roy
On Jun 20, 2019, at 7:42 AM, Edzer Pebesma <edzer.pebesma at uni-muenster.de> wrote: On 6/20/19 4:18 PM, Roy Mendelssohn - NOAA Federal via R-sig-Geo wrote:
Hi All: I am extending a package I have to allow users to provide a crs string, which will eventually through some other packages be sent to sf. I like to try and make at least minimal tests that inputs are valid. Is there some existing code that will check if a string is a valid crs string?
inherits(try(sf::st_crs("+proj=invalid"), silent = TRUE), "try-error")
[1] TRUE
inherits(try(sf::st_crs("+proj=longlat"), silent = TRUE), "try-error")
[1] FALSE
Thanks, -Roy ********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- Edzer Pebesma Institute for Geoinformatics Heisenbergstrasse 2, 48151 Muenster, Germany Phone: +49 251 8333081 <pEpkey.asc>_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org
********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.