I am having some trouble with the raster2pgsql function (on a Windows 7 in the OSGeo4W shell). I am receiving the error "Unable to read raster file"
. I can import shapefiles, ok using org2org so I know that the connection works, it just does not work for the raster2pgsql function.
To retrace my steps, I first changed the directory from m:/>
to the folder containing my raster:
cd M:\Users\userID\Documents\R\Koala_Proj\koala_data\koala_information_base\habitat_suitability
I then check the files within the directory using >dir to see what the raster is called. From this, I receive a list of the one raster in this folder and the affiliated files, such as:
koala_raster.tif
I then try to use the raster2pgsql to import this raster to the above directory in postgresql:
raster2pgsql -s 4283 -I -C -t 100x100 koala_raster.tif public.khsm │
psql -h localhost -p 1234 -d koala -U postgres
I have also tried:
raster2pgsql -s 4283 -I -C -t 100x100 *.tif public.khsm │
psql -h localhost -p 1234 -d koala -U postgres
From these queries, I receive the error "Unable to read raster file"
.
However, rather than the file that this error refers bring named "koala_raster.tif"
it prints "._koala_raster.tif"
. I am not sure what the "._"
at the beginning of my raster refers to, or how to fix this problem I am having.
I have looked for fixes in
- Uploading raster format(*.tif) to postgis through raster2pgsql
- Cannot upload an IMG file into PostGIS using raster2pgsql
- and the help files
However, I still have not found a solution that fixes my problem.
Best Answer
UPDATE: I found a solution. I set the directory to my raster location:
What I ended up doing wrong was I set the -p as the password, not the port. Once I changed this, the import worked successfully: