Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am running running Mac OS X (10.7.5), PostgreSQL (9.2) and PostGIS (2.0.2) (installed via Postgres.app).

The PostGIS extension seems to work perfectly with vector and raster layers. Once I enable PostGIS for the specific database I am able to create vector and rasters from the SQL Editor of phpAdmin3 (like with ST_MakeEmptyRaster).

The problems begin when I try to load a raster with raster2pgsql. I have no great experience with Postgres (or DBMS in general) so what I did might appear stupid...

I tried to launch it via psql following this steps:

1) Open psql terminal;

2) typed \c mydatabase;

3) Got as prompt mydatabase=# (that I guess means I am logged with owner rights...;

4) Now I tried raster2pgsql -Gbut of course is no SQL so I got ERROR: syntax error at or near "raster2pgsql" LINE 1: raster2pgsql -G;

Then I went back to my Mac OS X terminal shell and into the the folder where my raster2pgsql file is located (/usr/local/pgsql/bin) and typed raster2pgsql -s 4236 -I -C -M *.tif -F -t 100x100 /my/path/to/the/file/myfile.tif myrastertable | psql -U myuser -d mydb -h localhost -p 5432 but I got -bash: raster2pgsql: command not found.

What I am doing wrong?

share|improve this question
    
I actually solved the problem by reinstalling Postgres & PostGIS with the homebrew installation (here [link] (lukeberndt.com/2011/postgres-postgis-on-osx-lion)). No idea why Postegres.app didn't work for the raster... –  Francesco Feb 13 '13 at 8:41

3 Answers 3

In Windows, the raster2pgsql file is in

C:\Program Files (x86)\PostgreSQL\9.1\bin>raster2pgsql 

In Linux, it's in

/usr/bin (ubuntu)  

In OSX, I have no idea, but have you tried to search it? And yes, that fifth way was the right way.

share|improve this answer

Postgresapp's tools are in a different location - /Applications/Postgres.app/Contents/Versions/9.3/. To use a given tool, prepend the full path:

/Applications/Postgres.app/Contents/Versions/9.3/raster2pgsql -s 4236 -I -C -M *.tif -F -t 100x100 /my/path/to/the/file/myfile.tif myrastertable | psql -U myuser -d mydb -h localhost -p 5432

Alternatively, add the directory to your PATH or use alias:

alias raster2pgsql="/Applications/Postgres.app/Contents/Versions/9.3/bin/raster2pgsql"

For permanency, add that line to your .bashrc file.

share|improve this answer

Since Mac OS X is a UNIX based system you should check the file permissions first.

> ls -l raster2pgsql 

-rwxr-xr-x 1 root root 200096 May 23 15:03 raster2pgsql

If it looks like this than you could try to write it like

> ./raster2pgsql

If this works, than your installation directory

/usr/local/pgsql/bin

is not in the PATH check your PATH variable

> $PATH

If it is not there check out how to put it in your PATH.
The syntax depend very much on the shell you use.
It looks like 'bash' in your case, so use

> export PATH=$PATH:/usr/local/pgsql/bin

That should solve the problem about not finding the executable.
This would be the exact description of your problem.

To make the export permanent, add that to your ~/.bashrc file. Takes effect after re-logging in, or after sourcing the file with something like source ~/.bashrc.
Or, to make the export permanent after reboot, for the entire system, add that to the /etc/profile.d/pgsql.sh file (this may verify by system). The file name itself if arbitrary for a setup like that, and does not need to be executable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.