Ali (2) [Avatar] Offline
#1
Hi,
I'm currently working through Chapter 7 Raster Functions but I'm having some trouble in section 7.2.5. I'm getting an error when using ST_Clip() to clip the Reo raster that was loaded as an out-db raster in section 7.2.2.

Specifically, I'm seeing the following on running the code in listing 7.6:
ERROR: rt_band_load_offline_data: Cannot open offline raster: C:\Users\Ali\Desktop\adbadge_tall.png

This surprised me as I'd previously checked that out-db rasters and gdal drivers were enabled using my system environment variables. I also verfied this in PostgreSQL:
show postgis.enable_outdb_rasters -- returns on
show postgis.gdal_enabled_drivers -- returns GTiff PNG JPEG GIF XYZ DTED USGSDEM AAIGrid


The following is the command I used to load the Reo raster into the table:
raster2pgsql -e -R -a "C:\Users\Ali\Desktop\adbadge_tall.png" ch07.bag_o_rasters | psql -U postgres -d postgis_in_action


The record appeared in the bag_o_rasters table and calls to ST_Width() and ST_Height() produced the expected results.

I would be very grateful if you are able to offer any insight on what the issue may be and how I could go about solving it. For reference the result of SELECT postgis_full_version() is included below:
"POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4090" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.0.1, released 2015/09/15" LIBXML="2.7.8" LIBJSON="0.12" RASTER"


Kind regards,

Ali
regina.leo (260) [Avatar] Offline
#2
This issue often happens if the account postgres runs under does not have rights to read the folder you place the file.
Given you put it in your desktop, that is highly likely the issue.

You could do one of the following:

1) put your files elsewhere that has read-all or at very least read rights for the account your postgres service is running under
2) Chagne the permissions on your desktop.

I know it loads into the database which is misleading. That's because raster2pgsql is a client tool so runs under the context of account you launched it with (which is most likely the account your logged into your computer with).
Ali (2) [Avatar] Offline
#3
Thank you for your quick response.

Following your advice I changed the permissions on the image, granting the NETWORK SERVICE account read access; I was then able to clip successfully. smilie

Thanks for helping to clear that up - it certainly highlights the difference between the user account and postgres service account.