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

gips_project returns nan when feature contains no raster pixel centers #47

Open
bhbraswell opened this issue Aug 31, 2015 · 7 comments
Open

Comments

@bhbraswell
Copy link
Member

Example: Merra is 0.5 x 0.67 degree raster images. I want to extract data for each county in NH, even if it is only one pixel by one pixel. In this unusual case, I get a nan result for some counties, I believe because they are on the order of the size of the merra pixels, and do not contain a pixel center. Is this a gdal_rasterize issue that is outside the current scope of GIPS?

gips_project merra -p tave -d 2015-201 -s gadm2_vtnh_3410.shp -v4 --fetch --overwrite --outdir test102 -w "HASC_1='US.NH'" --res 1000 1000 -k HASC_2 --notld --interpolation 1

@matthewhanson
Copy link
Member

gdal_rasterize isn't used directly, it uses the GDAL warp api. I don't think the fix lies there, or with GIPS though. There are some counties that are smaller than a Merra pixel? It should still return something.

Without knowing the details, you might consider just buffering out the counties though, to ensure that working with data immediately outside the boundary. You can always clip the final result to the actual county boundary.

@bhbraswell
Copy link
Member Author

Yeah, as an example, Merra grid cells are just big enough so that 3 out of 10 NH counties do not contain a grid cell center and also return an image containing nan from gips_project. I assume that's what is going on but can't think of another reason for the error. I could change the Merra products so that they have a finer resolution, but that seems like the worst way to go. Maybe the buffering fix could be implemented within GIPS?

@ircwaves
Copy link
Member

ircwaves commented Sep 8, 2015

seems like the analog of gdal_rasterize's "ALL_TOUCHED" option is what is
needed here. Not sure how to implement it in the warp-api pipeline that
CookieCutter is using, but that seems like the option that would most
reliably solve this problem.

++ Ian

@matthewhanson
Copy link
Member

There is an option to set in the Warp API called CUTLINE_ALL_TOUCHED, it would be straigtforward to implement in order to test out if that's the issue.

@ircwaves
Copy link
Member

ircwaves commented Sep 8, 2015

I didn't see that one. Thanks, Matt.

@bhbraswell -- It does look straight forward to add to the mix. I could put a version that uses this option onto one of our servers for you to test -- unless you wanted to roll a little test script for me to check it with?

@ircwaves
Copy link
Member

ircwaves commented Sep 9, 2015

I did the quick hard-coded test and it does work. I will sew this into gips/gippy so that gips_project has an --all-touched option (although I'm open to other suggested option strings.

@ircwaves
Copy link
Member

ircwaves commented Nov 9, 2015

Fixed in AGS fork via adding alltouch to gips and gippy.

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

3 participants