Cidree / rpostgis

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

Using "out db" cloud rasters for Cloud Optimize GeoTiff #26

Closed Tartomas closed 2 years ago

Tartomas commented 2 years ago

Hello team if rpostgis I was wandering if its possible to connect a bucket and trigger the query through rpostgis for single zone how is explain in the documentation of postgis.
If it so, please could guide me in how would be the step to do it? Thanks you

basille commented 2 years ago

Hi @Tartomas. I'm not sure I follow entirely. rpostgis will not help you to load such a cloud raster into your DB (these are not R objects); for this, you need to use raster2pgsql as explained in the docs you referred to. And if you want to read it into R, it might just work as with any raster — the doc explains:

Once you have the data loaded and permissions set you can interact with the raster table like any other raster table, using the same functions. The database will handle all the mechanics of connecting to the cloud data when it needs to read pixel data.

Did you try to read a cloud raster already loaded in your DB? I cannot test such thing, but I'm curious to see your feedback.

Tartomas commented 2 years ago

Hi @basille Thanks for your answer. What I understand with this features of postgis is that you can "refers" a COG image without loading into postgis DB, avoiding an overhead as well as increasing storage costs through data duplication. The rasr2pgsql create a connector to the COG file in a cloud HTTPS space that simulate a "normal raster table".

Once you have the data loaded and permissions set you can interact with the raster table like any other raster table, using the same functions. The database will handle all the mechanics of connecting to the cloud data when it needs to read pixel data.  

Here are two well documented examples

  1. https://medium.com/@c.r.williams0109/integrating-satellite-image-analysis-into-urban-planning-gis-5f0cc885429c
  2. https://www.crunchydata.com/blog/postgis-raster-and-crunchy-bridge

At the end, I understand that the features add some metadata of the COG image from where postgis could use to redirect the URL info for your front end.

Let me know what you think. Best!

basille commented 2 years ago

That is my understanding too. Honestly, you'd have to try it out, and see how it works with R/rpostgis as the front end. It might be transparent for you — what is sure is that the raster (or subset of it) will be loaded in memory in R. Let us know what you're able to do!

Tartomas commented 2 years ago

@basille I will give it a try and I'm back to you in the following months. For know we manage to resolve directly with bucket just using COG https url. I will close this issue