Cidree / rpostgis

rpostgis: R Interface to a 'PostGIS' Database
http://cidree.github.io/rpostgis/
77 stars 14 forks source link

pgGetRast() error #22

Closed lucas-johnson closed 4 years ago

lucas-johnson commented 4 years ago

Context

SELECT AddRasterConstraints('my_rasters'::name, 'rast'::name);

Error

Error in pgSRID(conn, rout@crs) : 
  No SRID matches found. Re-run with 'create.srid = TRUE' to create new SRID entry in spatial_ref_sys.

Question

lucas-johnson commented 4 years ago

UPDATE:

This error message is printed, but the raster is returned correctly. Should the message be a warning instead?

dnbucklin commented 4 years ago

Hi @lucas-johnson . To answer your questions directly:

Since you used pgWriteRast to write to PostGIS, and it looks like SRID was correctly(?) applied as 5070, it's not obvious to me why that error is showing. Could you check the SRID(s) returned from both the original raster, and the pgGetRast-loaded raster?

r1 <- raster("original_raster_file")
pgSRID(conn, r1@crs) # Does this return `5070` ?
rgdal::showEPSG(as.character(r1@crs)) # what does this return?

r2 <- pgGetRast(conn, 'my_rasters')
pgSRID(conn, r2@crs)  # This should produce the error you were seeing...
dnbucklin commented 4 years ago

Error printing fix applied in 74a6ac7 , closing...