Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgWriteRast SnapToGrid causes Raster resizing and mismatch #14

Closed
isoneo opened this issue Nov 6, 2018 · 2 comments
Closed

pgWriteRast SnapToGrid causes Raster resizing and mismatch #14

isoneo opened this issue Nov 6, 2018 · 2 comments

Comments

@isoneo
Copy link

isoneo commented Nov 6, 2018

I have been trying to get pgWriteRast to work for some large raster files.
Example raster file I'm having issues with https://ufile.io/25trv

I am getting warnings / error "NOTICE: Cannot set value for pixel( x, y) outside raster bounds: X' x Y' ". I dug around a bit and it seems like Line 175 through 180 ST_SnapToGrid is changing the Raster width / height and causing mismatch once you get to Line 189 through 194 where you update pixel values. Could you fix this issue perhaps by adding band within b==1 loop but SnapToGrid after pixel value update?

@isoneo isoneo changed the title pgWriteRast S pgWriteRast SnapToGrid causes Raster resizing and mismatch Nov 6, 2018
@dnbucklin
Copy link
Contributor

Hi @isoneo ,

Thanks for trying out rpostgis. We hadn't tested this function on irregular grid resolutions (unequal x/y spacing), as is the case with your example raster. The function ST_SnapToGrid was assuming equal x/y, which was causing the issue. I've patched it in 5b3cec0 and it appears to be working with your test raster.

If you get a chance to test and run into any other issues, that would be great to know. You can install the latest version with:

devtools::install_github("mablab/rpostgis", "dev")

Also, since pgWriteRast is a pure-R solution, it's not very efficient for large rasters. If you have a lot of large raster to process you'll probably want to use command-line raster2pgsql.

@isoneo
Copy link
Author

isoneo commented Nov 7, 2018

I tried out the dev version and it is working. I will give raster2pgsql a try as well. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants