Assistance with running R code 'AHNextract'

Hi, my name is Hans i am totally new to R.
I have been pointed out to a code which can retrieve GIS information into e.g. csv files from GIS servers.

I am struggling to get R studio and this script working.
I think i managed to install devtools. But i get a lot of errors like "could not find function "ahn_point"

I would be very happy if someone can help me to get this working.
In the ideal situation i would like to make some standalone executable file and a YouTube demo to have other people like myself help to work with this.

Thanks upfront

Help doc as readable pdf:
https://drive.google.com/open?id=1kyeANmu8WI1ONumdkRi6fWpX_xIjoRqg

Code can be found here:
https://github.com/Jellest/rAHNextract

The guidance been given to install and make it work was this code

devtools::install_github(“Jellest/rAHNextract”)

But the error that follows is this
Error: unexpected input in "devtools:install_github(“"

R studio recognizes devools at the prompt so i assume that part of the code is functioning.

What to do. Anybody?

OMG! .. You can't use copy paste.. (?!)
I worked typing

You were pasting an invalid quoting character, that is why it worked when you typed the command with the normal one.

Can you help me with this next error?

Error: Failed to install 'rAHNextract' from GitHub:
(converted from warning) cannot remove prior installation of package ‘glue’

Run RStudio as administrator or manually remove the glue package from your package library by deleting the folder.

Running as adminstrator did not help. Where can i find the folder? Glue does not show up.

Remove .. install worked for glue at last

But not RHNextract. Does it work at your end?

package ‘glue’ successfully unpacked and MD5 sums checked
Error: Failed to install 'rAHNextract' from GitHub:
(converted from warning) cannot remove prior installation of package ‘glue’

I have tested it on RStudio Cloud and it works seamlessly so I think this is a permissions issue specific to your system.

You can try running this command before installing the package to avoid this problem.

Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS="true")

What worked for me is installing the glue package by itself before installing 'rAHNextract' by using install.package("glue"). Make sure to remove the 'glue' package first.

Also, do you have Rtools installed? This is a seperate program that is recommended if you download packages through 'github_install()'.

What a frustration installing these functions :(.
The call you mention "github_install()" is not recognized.
Only

devtools::install_github("Rtools")
WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools custom from RTools: Toolchains for building R and R packages from source on Windows.
Error in parse_repo_spec(repo) : Invalid git repo specification: 'Rtools'

So downloading now..
I will come back some day i got this programm running.

..
..

  • installing source package 'rAHNextract' ...
    ** using staged installation
    ** R
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'rAHNextract'
    finding HTML links ... done
    ahn_area html
    ahn_letters html
    ahn_pc html
    ahn_point html
    create_area html
    create_bbox_polygon html
    create_spatialpoint html
    create_wcs_url html
    download_bladnrs html
    download_dsm html
    download_dtm html
    download_pointCloud html
    download_wcs_raster html
    extract_elevation html
    generate_ahn_point html
    generate_lowres_ahn_points html
    get_ahn_letter html
    get_ahn_sheets html
    get_dem html
    get_resolution html
    get_surrounding_ahn html
    read_pc html
    trim_name html
    write_pc html
    *** copying figures
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    *** arch - i386
    *** arch - x64
    ** testing if installed package can be loaded from final location
    *** arch - i386
    *** arch - x64
    ** testing if installed package keeps a record of temporary installation path
  • DONE (rAHNextract)

That looks like it is here!

ahn_point(name = "Utrecht point", X = 136550, Y = 456060)
Error in ahn_point(name = "Utrecht point", X = 136550, Y = 456060) :
could not find function "ahn_point"
ahn_point(X = 136550, Y = 456060)
Error in ahn_point(X = 136550, Y = 456060) :
could not find function "ahn_point"
ahn_point

What now?

library(rAHNextract)
ahn_point(name = "Utrecht point", X = 136550, Y = 456060)
AHN3 0.5 resolution DSM (ruw) selected.
trying URL 'https://geodata.nationaalgeoregister.nl/ahn3/wcs?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&COVERAGE=ahn3_05m_DSM&BBOX=136549.5,456059.5,136551,456061&CRS=EPSG:28992&RESPONSE_CRS=EPSG:28992&FORMAT=GEOTIFF_FLOAT32&WIDTH=3&HEIGHT=3'
Content type 'image/tiff' length 562 bytes
downloaded 562 bytes

[1] "Download raster image succeeded."
[1] "Intersecting raster. Getting elevation..."
[1] "Elevation of Utrecht point: 7.38 m."
[1] 7.38
Warning messages:
1: In CPL_crs_from_input(x) :
GDAL Message 1: +init=epsg:XXXX syntax is deprecated. It might return a CRS with a non-EPSG compliant axis order.
2: In .local(x, y, ...) :
Transforming SpatialPoints to the CRS of the Raster

(howly! it works !)

1 Like

Sorry, I always mix up the two. It’s ‘install_github()’ indeed.

Glad you got it to work! You can ignore the warning messages. I will fix those in a future update.

Love this AHN function code!
What a beauty!
I would like to take it a step futher for use in CAD environment.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.