[postgis-users] Voronoi in PostGIS

11 views
Skip to first unread message

Dheeraj Chand

unread,
Mar 9, 2012, 4:12:48 PM3/9/12
to PostGIS Users Discussion
Hi,

I've been looking online to find some documentation on how to undertake this in PostGIS. Has anyone done it successfully, and if so, further willing to share code?

Best,

-dx
_______________________________________________
postgis-users mailing list
postgi...@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Puneet Kishor

unread,
Mar 9, 2012, 4:19:19 PM3/9/12
to PostGIS Users Discussion

On Mar 9, 2012, at 3:12 PM, Dheeraj Chand wrote:

> Hi,
>
> I've been looking online to find some documentation on how to undertake this in PostGIS. Has anyone done it successfully, and if so, further willing to share code?
>


did you see http://punkish.org/Voronoi-Diagrams-In-PostGIS


--
Puneet Kishor

Jan Hartmann

unread,
Mar 9, 2012, 4:21:35 PM3/9/12
to PostGIS Users Discussion
It's possible when you use the statistical package R, and its PostgreSQL implementation PL/R (http://www.joeconway.com/plr/). It's not simple, but I did it a few years ago.

Jan

Dheeraj Chand

unread,
Mar 9, 2012, 4:22:23 PM3/9/12
to PostGIS Users Discussion
That was one that I'd bookmarked, but I don't have PL/R installed. I'm on a Mac. I have Python and PHP handy, though! I also don't know PL/R, but I could try to learn it!

Puneet Kishor

unread,
Mar 9, 2012, 4:27:19 PM3/9/12
to PostGIS Users Discussion

On Mar 9, 2012, at 3:22 PM, Dheeraj Chand wrote:

> That was one that I'd bookmarked, but I don't have PL/R installed. I'm on a Mac. I have Python and PHP handy, though! I also don't know PL/R, but I could try to learn it!
>


All my work is on a Mac. You don't have to "learn" PL/R, but you do have to install it. Installing it via Macports is the easiest, but you can also easily compile it yourself.


Once you get PL/R installed, it is just a matter of copying the code I have provided. Then, over time you can learn R. PL/R simply lets you right Postgres functions in R.

Dheeraj Chand

unread,
Mar 9, 2012, 7:22:17 PM3/9/12
to PostGIS Users Discussion
Oh, gotcha. I'm actually very good with R, so that's a relief. Umm, I used the installers from Kyng Chaos for PostGIS and all the libraries, and I'm not exactly the best at command line interactions, sorry.

Can someone give me completely idiot-proof directions to installing PL/R on OS X Lion, assuming the Kyng Chaos versions of GDAL, etc. ?

-dx

pcr...@pcreso.com

unread,
Mar 9, 2012, 7:57:19 PM3/9/12
to PostGIS Users Discussion, b.w...@niwa.co.nz

Dheeraj Chand

unread,
Mar 13, 2012, 4:23:36 PM3/13/12
to pcr...@pcreso.com, b.w...@niwa.co.nz, PostGIS Users Discussion
Hi,

I'm trying to install on Mac Lion, and getting an error with pkg-config (appended).

I'm following the instructions for pkg-config from here: http://cairographics.org/end_to_end_build_for_mac_os_x/

Anyone able to help me figure out what's going on?

-dx



GENESISARK:plr dheerajchand$ USE_PGXS=1 make clean
rm -f plr.so   libplr.a 
rm -f plr.sql
rm -f plr.o pg_conversion.o pg_backend_support.o pg_userfuncs.o pg_rsupport.o
rm -f doc/html/* doc/plr-US.aux doc/plr-*.log doc/plr-*.out doc/plr-*.pdf doc/plr-*.tex-pdf
rm -rf results/ regression.diffs regression.out tmp_check/ log/
GENESISARK:plr dheerajchand$ USE_PGXS=1 make
sed 's,MODULE_PATHNAME,$libdir/plr,g' plr.sql.in >plr.sql
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv  -I"." -I"/Library/Frameworks/R.framework/Resources//include" -I/Library/Frameworks/R.framework/Resources//include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources/\"  -c -o plr.o plr.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv  -I"." -I"/Library/Frameworks/R.framework/Resources//include" -I/Library/Frameworks/R.framework/Resources//include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources/\"  -c -o pg_conversion.o pg_conversion.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv  -I"." -I"/Library/Frameworks/R.framework/Resources//include" -I/Library/Frameworks/R.framework/Resources//include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources/\"  -c -o pg_backend_support.o pg_backend_support.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv  -I"." -I"/Library/Frameworks/R.framework/Resources//include" -I/Library/Frameworks/R.framework/Resources//include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources/\"  -c -o pg_userfuncs.o pg_userfuncs.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv  -I"." -I"/Library/Frameworks/R.framework/Resources//include" -I/Library/Frameworks/R.framework/Resources//include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources/\"  -c -o pg_rsupport.o pg_rsupport.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv  -bundle -multiply_defined suppress -o plr.so plr.o pg_conversion.o pg_backend_support.o pg_userfuncs.o pg_rsupport.o -L/usr/local/pgsql-9.1/lib -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -Wl,-dead_strip_dylibs   -L/Library/Frameworks/R.framework/Resources//bin -L/Library/Frameworks/R.framework/Resources//lib -lR -bundle_loader /usr/local/pgsql-9.1/bin/postgres
GENESISARK:plr dheerajchand$ USE_PGXS=1 make install
/bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/lib'
/bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/share/extension'
/bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/share/doc/extension'
mkdir: /usr/local/pgsql-9.1/share/doc/extension: Permission denied
make: *** [installdirs] Error 1
GENESISARK:plr dheerajchand$ sudo USE_PGXS=1 make install
Password:
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: *** No rule to make target `install'.  Stop.
GENESISARK:plr dheerajchand$ echo $PATH
/Users/dheerajchand/pear/bin/:/Applications/ImageMagick-6.7.2/bin:/Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config:/usr/local/pgsql-9.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin:/usr/local/mysql/bin

Puneet Kishor

unread,
Mar 13, 2012, 4:41:26 PM3/13/12
to PostGIS Users Discussion
Dheeraj,

I did get your message re. problems with installing PL/R. I might be able to help you, but I am tied up in knots with another problem I am trying to solve right now, which I have to attend to right away.

Also, note that I didn't use pkg-config (I have no idea what that is). I simply downloaded the PL/R code from Joe Conway's web site and compiled it. There were a few errors mainly to do with wrong paths, and I went about fixing those as those were encountered (only 3 or 4, if I recall correctly). After that it compiled easily. Also, I use macports for my R, Postgres and PostGIS needs, so everything was in /opt/local/.

Soon as I get a moment free, I will try to dig up where all I made edits in the PL/R source, and put it up on my web site.

Dheeraj Chand

unread,
Mar 13, 2012, 7:05:43 PM3/13/12
to PostGIS Users Discussion
Thanks!

I don't use MacPorts or Homebrew for a long series of reasons that I'd rather not get into at the moment...So I had to use the Kyng Chaos installers and periodically compile from source when there's something that I need that doesn't have a binary installer.

When I downloaded Jon Conway's source, this was the error that I got, which was that it needed pkg-config. I suspect that Ports gave it to you already. So I tried installing pkg-config, and this is what I got...

I'm absolutely stymied!

-dx

Puneet Kishor

unread,
Mar 13, 2012, 7:36:10 PM3/13/12
to PostGIS Users Discussion
Dheeraj,

Since you don't use Macports, I will be completely guessing as to the source of the problem. I have not used the Kyngchaos installers at all. My problem is the other way around -- I need way too much stuff, and I'd rather have a single overarching mechanism for installing software. So, I either hand roll everything or let someone else do it... Macports comes the closest to filling my need. Also, if I occasionally do have to install something by hand (case in point being PL/R), it seems to work ok with Macports.

Anyway -- I am assuming you have R installed correctly, although I do see a mysterious double slash in the path to R components, for example, /Library/Frameworks/R.framework/Resources//include and /Library/Frameworks/R.framework/Resources//lib

Second issue, `make install` won't work without `sudo` because you are trying to install in /usr/local/ which requires correct permissions. That is why you get "mkdir: /usr/local/pgsql-9.1/share/doc/extension: Permission denied"

Third, do you have `pkg-config` installed or not? Here is what I have

$which pkg-config
/opt/local/bin/pkg-config
$pkg-config --version
0.26


The pkg-config web site is http://www.freedesktop.org/wiki/Software/pkg-config

Hope the above gives you a few ideas.

>>> ..

Dheeraj Chand

unread,
Mar 13, 2012, 7:53:16 PM3/13/12
to PostGIS Users Discussion
Hi, hi!

Thanks so much for responding while I know that you're busy. 

Yeah, if I could use Ports or Homebrew with some of the other things that I need to do, I totally would, believe me. On my Ubuntu machine, I'm all apt, all the time.

Thanks for correcting the error on my R listing. That was a typo in my ~/.bash_profile that's now been fixed.

What I was saying about pgk-config was that I am unsure of what went wrong.  I compiled according to the instructions I linked to here (http://cairographics.org/end_to_end_build_for_mac_os_x/) and added PKG_CONFIG to my $PATH, but I still get this confusing output:

GENESISARK:~ dheerajchand$ which pgk-config
GENESISARK:~ dheerajchand$ echo $PATH
/Users/dheerajchand/pear/bin/:/Applications/ImageMagick-6.7.2/bin:/Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config:/usr/local/pgsql-9.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin:/usr/local/mysql/bin
GENESISARK:~ dheerajchand$ echo $PKG_CONFIG
/Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config
GENESISARK:~ dheerajchand$ ls $PKG_CONFIG
328 -rwxr-xr-x  1 staff  164356 Mar 13 13:33 /Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config
GENESISARK:~ dheerajchand$ 

Also, if you scroll down further in the original append, you'll see that I did run it as sudo, so I am very confused. My thought is that I must have done something wrong with pkg-config.

-dx

Puneet Kishor

unread,
Mar 13, 2012, 8:00:11 PM3/13/12
to PostGIS Users Discussion

On Mar 13, 2012, at 6:53 PM, Dheeraj Chand wrote:

> GENESISARK:~ dheerajchand$ echo $PATH
> /Users/dheerajchand/pear/bin/:/Applications/ImageMagick-6.7.2/bin:/Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config:/usr/local/pgsql-9.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin:/usr/local/mysql/bin


Try removing 'pkg-config' from /Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config and make it /Users/dheerajchand/Projects/src/pkgthings/bin


Then do a `source ~/.bash_profile` to reload the path (or quit Terminal and launch it again), then do a `which pkg-config`


--
Puneet Kishor

Dheeraj Chand

unread,
Mar 13, 2012, 9:22:40 PM3/13/12
to PostGIS Users Discussion
Thanks!

1. Altering $PKG_CONFIG to just ../bin worked!
2. Fixed the issue with the R path.

That allowed the make to work, but the make install is still giving me errors. (Appended)

-dx

GENESISARK:plr dheerajchand$ pwd
/Users/dheerajchand/Projects/src/plr
GENESISARK:plr dheerajchand$ which pkg-config
/Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config
GENESISARK:plr dheerajchand$ echo $PATH
/Users/dheerajchand/pear/bin/:/Applications/ImageMagick-6.7.2/bin:/Users/dheerajchand/Projects/src/pkgthings/bin:/usr/local/pgsql-9.1/bin:/Users/dheerajchand/pear/bin/:/Applications/ImageMagick-6.7.2/bin:/Users/dheerajchand/Projects/src/pkgthings/bin/pkg-config:/usr/local/pgsql-9.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin:/usr/local/mysql/bin:/usr/local/mysql/bin


GENESISARK:plr dheerajchand$ USE_PGXS=1 make
sed 's,MODULE_PATHNAME,$libdir/plr,g' plr.sql.in >plr.sql

gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I"." -I"/Library/Frameworks/R.framework/Resources/include" -I/Library/Frameworks/R.framework/Resources/include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources\" -c -o plr.o plr.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I"." -I"/Library/Frameworks/R.framework/Resources/include" -I/Library/Frameworks/R.framework/Resources/include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources\" -c -o pg_conversion.o pg_conversion.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I"." -I"/Library/Frameworks/R.framework/Resources/include" -I/Library/Frameworks/R.framework/Resources/include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources\" -c -o pg_backend_support.o pg_backend_support.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I"." -I"/Library/Frameworks/R.framework/Resources/include" -I/Library/Frameworks/R.framework/Resources/include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources\" -c -o pg_userfuncs.o pg_userfuncs.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I"." -I"/Library/Frameworks/R.framework/Resources/include" -I/Library/Frameworks/R.framework/Resources/include -I. -I. -I/usr/local/pgsql-9.1/include/server -I/usr/local/pgsql-9.1/include/internal -I/usr/include/libxml2 -DPKGLIBDIR=\"/usr/local/pgsql-9.1/lib\" -DDLSUFFIX=\".so\" -DR_HOME_DEFAULT=\"/Library/Frameworks/R.framework/Resources\" -c -o pg_rsupport.o pg_rsupport.c
gcc -Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -bundle -multiply_defined suppress -o plr.so plr.o pg_conversion.o pg_backend_support.o pg_userfuncs.o pg_rsupport.o -L/usr/local/pgsql-9.1/lib -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -Wl,-dead_strip_dylibs -L/Library/Frameworks/R.framework/Resources/bin -L/Library/Frameworks/R.framework/Resources/lib -lR -bundle_loader /usr/local/pgsql-9.1/bin/postgres


GENESISARK:plr dheerajchand$ USE_PGXS=1 make install
/bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/lib'
/bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/share/extension'
/bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/share/doc/extension'
mkdir: /usr/local/pgsql-9.1/share/doc/extension: Permission denied
make: *** [installdirs] Error 1
GENESISARK:plr dheerajchand$ sudo USE_PGXS=1 make install
Password:

make: *** No rule to make target `install'. Stop.
GENESISARK:plr dheerajchand$

Puneet Kishor

unread,
Mar 13, 2012, 9:38:55 PM3/13/12
to PostGIS Users Discussion

On Mar 13, 2012, at 8:22 PM, Dheeraj Chand wrote:

> Thanks!
>
> 1. Altering $PKG_CONFIG to just ../bin worked!
> 2. Fixed the issue with the R path.
>
>

I am out of my depth here, and besides, I am only guessing what is going on with your computer. Nevertheless, it seems you once again tried to `make install` without sudo, and that failed.

> ..


> GENESISARK:plr dheerajchand$ USE_PGXS=1 make install
> /bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/lib'
> /bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/share/extension'
> /bin/sh /usr/local/pgsql-9.1/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/pgsql-9.1/share/doc/extension'
> mkdir: /usr/local/pgsql-9.1/share/doc/extension: Permission denied
> make: *** [installdirs] Error 1


After that you tried it again with `sudo`


> GENESISARK:plr dheerajchand$ sudo USE_PGXS=1 make install
> Password:
> make: *** No rule to make target `install'. Stop.

Dunno what to suggest. Perhaps do a complete `make clean` and do everything again making sure, but I am just guessing. Hopefully, someone else knows what is going on.

Reply all
Reply to author
Forward
0 new messages