[GRASS-user] nn library

jon jeir at hi.is
Thu Jul 20 01:58:38 PDT 2017


OK, with a little courage and reading the manual pages properly, I 
managed to install nn library on my Mac. In case anyone is interested, I 
copy the commands below. Apologies to anyone who might have spent time 
on this.

Jón

//
Last login: Thu Jul 20 08:20:30 on console
  ________________________________________________________________________________
| ~ @ jons-iMac (jon)
| => git clone https://github.com/sakov/nn-c
Cloning into 'nn-c'...
remote: Counting objects: 208, done.
remote: Total 208 (delta 0), reused 0 (delta 0), pack-reused 208
Receiving objects: 100% (208/208), 792.10 KiB | 475.00 KiB/s, done.
Resolving deltas: 100% (93/93), done.
Checking connectivity... done.
  ________________________________________________________________________________
| ~ @ jons-iMac (jon)
| => cd nn-c
  ________________________________________________________________________________
| nn-c @ jons-iMac (jon)
| => cd nn
  ________________________________________________________________________________
| nn @ jons-iMac (jon)
| => ls
CHANGELOG		install-sh		nnai.c
CUSTOMISE		istack.c		nnbathy.c
LICENSE			istack.h		nncommon-vulnerable.c
README			lpi.c			nncommon.c
config.h.in		makefile.example	nnconfig.h.in
configure		makefile.in		nnpi.c
configure.in		minell.c		preader.c
delaunay.c		minell.h		preader.h
delaunay.h		mkinstalldirs		triangle.c
examples		nan.h			triangle.h
hash.c			nn.h			version.h
hash.h			nn_internal.h
  ________________________________________________________________________________
| nn @ jons-iMac (jon)
| => ./configure
Using prefix /usr/local
Using libdir /usr/local/lib
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking for ar... ar
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking for main in -lm... yes
checking for realloc... yes
checking for strtod... yes
checking for strtok... yes
checking for hypot... yes
checking for -fno-force-mem option... no
configure: creating ./config.status
config.status: creating makefile
config.status: creating config.h
  ________________________________________________________________________________
| nn @ jons-iMac (jon)
| => make
gcc -c -DTRILIBRARY -g -O2 -Wall -pedantic -w -ffloat-store -I. 
triangle.c
gcc -g -O2 -Wall -pedantic -c delaunay.c -o delaunay.o
gcc -g -O2 -Wall -pedantic -c hash.c -o hash.o
gcc -g -O2 -Wall -pedantic -c istack.c -o istack.o
gcc -g -O2 -Wall -pedantic -c lpi.c -o lpi.o
gcc -g -O2 -Wall -pedantic -c minell.c -o minell.o
gcc -g -O2 -Wall -pedantic -c nnai.c -o nnai.o
gcc -g -O2 -Wall -pedantic -c nnpi.c -o nnpi.o
gcc -g -O2 -Wall -pedantic -c nncommon.c -o nncommon.o
gcc -g -O2 -Wall -pedantic -ffloat-store -c nncommon-vulnerable.c -o 
nncommon-vulnerable.o
gcc -g -O2 -Wall -pedantic -c preader.c -o preader.o
ar cru libnn.a delaunay.o hash.o istack.o lpi.o minell.o nnai.o nnpi.o 
nncommon.o nncommon-vulnerable.o preader.o triangle.o
chmod go+r libnn.a
gcc -o minell minell.c -DME_STANDALONE -g -O2 -Wall -pedantic -I.  -lm
gcc -o nnbathy nnbathy.c -g -O2 -Wall -pedantic -DNN_SERIAL -I.  libnn.a 
-lm
  ________________________________________________________________________________
| nn @ jons-iMac (jon)
| => sudo make install
Password:
/bin/sh mkinstalldirs /usr/local/bin /usr/local/lib /usr/local/include
for i in libnn.a; do \
	   /usr/bin/install -c -m 644 $i /usr/local/lib/$i; \
	done
for i in nn.h; do \
	   /usr/bin/install -c -m 644 $i /usr/local/include; \
	done
for i in minell nnbathy; do \
	   fname=`basename $i`; \
	   /usr/bin/install -c $i /usr/local/bin; \
	done
  ________________________________________________________________________________
| nn @ jons-iMac (jon)
| =>


--

and the run session in GRASS:

GRASS 7.3.svn (nc_spm_08_grass7):~ > g.region raster=elevation at PERMANENT 
-p
projection: 99 (Lambert Conformal Conic)
zone:       0
datum:      nad83
ellipsoid:  a=6378137 es=0.006694380022900787
north:      228500
south:      215000
west:       630000
east:       645000
nsres:      10
ewres:      10
rows:       1350
cols:       1500
cells:      2025000
GRASS 7.3.svn (nc_spm_08_grass7):~ > r.random input=elevation at PERMANENT 
n=100000 raster_output=random_points
WARNING: Please update the usage of <r.random>: option <raster_output> 
has
          been renamed to <raster>
Collecting Stats...
  100%
Writing raster map <random_points> ...
  100%
GRASS 7.3.svn (nc_spm_08_grass7):~ > r.surf.nnbathy input=random_points 
output=raster_map
"nnbathy" is performing the interpolation now. This may take some 
time...
Converting nnbathy output to GRASS raster ...
All done. Raster map <raster_map> created.
GRASS 7.3.svn (nc_spm_08_grass7):~ >
//

On 19 Jul 2017, at 10:13, jon wrote:

> Hi,
>
> I am running  GRASS GIS 7.3.svn (r68671M) on MacOSX 10.10.5
>
> I have used g.extension to install r.surf.nnbathy and v.surf.nnbathy, 
> and the following command indicates that it is in the right place 
> (accessible from GRASS command line):
>
> r.surf.nnbathy --help
>
> Description:
>  Interpolates a raster map using the nnbathy natural neighbor 
> interpolation program.
>
> Keywords:
>  vector, surface, interpolation, natural, neighbor
>
> Usage:
>  r.surf.nnbathy input=name output=name [algorithm=string] 
> [--overwrite]
>    [--help] [--verbose] [--quiet] [--ui]
>
> Flags:
>  --o   Allow output files to overwrite existing files
>  --h   Print usage summary
>  --v   Verbose module output
>  --q   Quiet module output
>  --qq  Super quiet module output
>  --ui  Force launching GUI dialog
>
> Parameters:
>       input   Name of input raster map
>      output   Name of output raster map
>   algorithm   Settings
>               options: l,nn,ns
>               default: nn
>                l: Linear
>                nn: Sibson natural neighbor
>                ns: Non-Sibsonian natural neighbor
>
>
> However, issuing e.g.  [r.surf.nnbathy input=dem_ct output=dem_nn]
>
> GRASS 7.3.svn (skeifa_river_02):~ > r.surf.nnbathy input=dem 
> output=dem_nn
> "nnbathy" is performing the interpolation now. This may take some 
> time...
> Traceback (most recent call last):
>   File "/Users/jon/Library/GRASS/7.3/Modules/scripts/r.surf.nnbathy", 
> line 80, in <module>
>     main()
>   File "/Users/jon/Library/GRASS/7.3/Modules/scripts/r.surf.nnbathy", 
> line 75, in main
>     obj.compute()
>   File 
> "/Users/jon/Library/GRASS/7.3/Modules/etc/v.surf.nnbathy/nnbathy.py", 
> line 57, in compute
>     stdout=fsock)
>   File 
> "/Applications/GRASS-7.3.app/Contents/MacOS/etc/python/grass/script/core.py", 
> line 84, in call
>     return Popen(*args, **kwargs).wait()
>   File 
> "/Applications/GRASS-7.3.app/Contents/MacOS/etc/python/grass/script/core.py", 
> line 74, in __init__
>     subprocess.Popen.__init__(self, args, **kwargs)
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", 
> line 710, in __init__
>     errread, errwrite)
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", 
> line 1335, in _execute_child
>     raise child_exception
> OSError: [Errno 2] No such file or directory
>
> I suspect I need to install the nn-c library.
>
> Does anyone have step-by-step cookbook type instructions or any 
> guidelines on how to do this on MacOSX?
>
> Cheers,
>
> Jon Eiriksson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20170720/e681092c/attachment-0001.html>


More information about the grass-user mailing list