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

Spatially consistency between 2 Raster layers #80

Merged
merged 2 commits into from
Mar 11, 2023

Conversation

ma15569
Copy link
Contributor

@ma15569 ma15569 commented Dec 11, 2022

Check if the RasteImageLayer is spatially consistent with another: a) both have the same cell size
b) both have the same dimension (same width and height) c) both overlap to each other into the geographic space Usefull for ovelapping processes between two raster iamge layers

Check if the RasteImageLayer is spatially consistent with another:
a) both have the same cell size
b) both have the same dimension (same width and height)
c) both overlap to each other into the geographic space
Usefull for ovelapping processes between two raster iamge layers
@jratike80
Copy link
Contributor

Does it also check that the pixels are aligned? I mean that if the pixels have also a common origin in addition to same pixel size so that they overlap exactly? Compare the -tap option in gdalwarp https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-tap.

@ma15569
Copy link
Contributor Author

ma15569 commented Dec 11, 2022 via email

@jratike80
Copy link
Contributor

I do not need that kind of check myself. I was just remembering some troubles/worries that GDAL users have had when they have warped an image by using a clipping polygon. In that case GDAL by default is placing the origo to the (minx miny) of the envelope of the clipping geometry and that leads often to unaligned pixels. The -tap option is placing the pixels to match with a grid that begins from (0 0) in the CRS of the output.

If you think that that raster calculator works right if two images both have for example 100x100 pixels, with the same pixel size of 1x1 metre, but when one image has the origin at (0 0) and the other one at (0.3 0.2) then I think there is no need for this check.

* @return true if they are spatially consistent, false if they are not
*/
public boolean isSpatiallyConsistentWith(RasterImageLayer rasteimageLayer) {
if (this.getMetadata().getOriginalCellSize() != rasteimageLayer.getMetadata().getOriginalCellSize()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the 3 first tests (xmin, ymin, cellsize) can be replaced by :
if (! this.getWholeImageEnvelope().equals(rasterImageLayer.getWholeImageEnvelope()) {
return false;
}

* @param RasterImageLayer
* @return true if they are spatially consistent, false if they are not
*/
public boolean isSpatiallyConsistentWith(RasterImageLayer rasteimageLayer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rasterImageLayer to follow more standard naming convention

@ma15569
Copy link
Contributor Author

ma15569 commented Dec 12, 2022 via email

@ma15569
Copy link
Contributor Author

ma15569 commented Dec 12, 2022 via email

Upgraded according to Michaël  sugestion
Copy link
Contributor

@mukoki mukoki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Sorry for the delay.

@mukoki mukoki merged commit 6801846 into openjump-gis:main Mar 11, 2023
@ma15569
Copy link
Contributor Author

ma15569 commented Mar 11, 2023 via email

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

Successfully merging this pull request may close these issues.

None yet

3 participants