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

Output Viewport Does Not Match out_bbox #4

Closed
jbeuckm opened this issue Mar 24, 2022 · 3 comments
Closed

Output Viewport Does Not Match out_bbox #4

jbeuckm opened this issue Mar 24, 2022 · 3 comments

Comments

@jbeuckm
Copy link

jbeuckm commented Mar 24, 2022

I am trying to warp this GeoTiff into EPSG:4326 to generate a tile for Mapbox.

input

Parsing with georaster seems to give the expected result:

  height: 570,
  width: 501,
  pixelHeight: 56,
  pixelWidth: 56,
  xmin: 450278,
  xmax: 478334,
  ymax: 1891090,
  ymin: 1859170,

When I geowarp() with these params, I get a correctly sized result that looks like the projection of a small piece of the top left corner of the source raster:

  const georaster = await parseGeoraster('https://nassgeodata.gmu.edu/webservice/nass_data_cache/CDL_2008_clip_20220323194315_1211782049.tif')

  const options = {
    left: 0,
    top: 0,
    right: georaster.width,
    bottom: georaster.height,
    width: georaster.width,
    height: georaster.height,
  }

  const values = await georaster.getValues(options)

  const result = geowarp({
    debug_level: 2,
    forward: albersConicalEqualArea.inverse,
    inverse: albersConicalEqualArea.forward,
    in_data: values[0],
    in_bbox: [xmin, ymin, xmax, ymax],
    in_layout: '[row][column,band]',
    in_pixel_depth: 1,
    in_srs: ALBERS_CONICAL_EQUAL_AREA,
    in_width: georaster.pixelWidth,
    in_height: georaster.pixelHeight,
    out_bbox: [west, south, east, north],
    out_layout: '[row][column,band]',
    out_srs: 4326,
    out_height: 256,
    out_width: 256,
    method: 'near',
    round: false,
    theoretical_min: 0,
    theoretical_max: 255,
  })

The requested output bbox is a direct projection of the bbox in the source tiff:

[geowarp] out_xmin: -90.703125
[geowarp] out_ymin: 39.6395375643667
[geowarp] out_xmax: -90.3515625
[geowarp] out_ymax: 39.909736234537185

The result is the correct size, but does not appear to match the requested output bbox:
temp

The result looks to be a projected version of a small, top left piece of the input tiff:
Screen Shot 2022-03-23 at 7 04 12 PM

@DanielJDufour
Copy link
Owner

Hi. Thanks for submitting this issue and a great write-up! I'll look into this as soon as I can (but that might not be till the weekend).

Did you happen to see if you ran into this problem with older versions of geowarp?

Thank you again for reporting this issue! :-)

@jbeuckm
Copy link
Author

jbeuckm commented Mar 24, 2022

I think i found the issue. I'm not sure what georaster.pixelWidth/georaster.pixelHeight are, but they are too small to use for the input dimensions. This works as expected if I use georaster.width/georaster.height.

Note: I added the dependencies to my project and copied in geowarp.js because my project did not accept the Nullish coalescing operator when imported from this module.

@DanielJDufour
Copy link
Owner

@jbeuckm , good catch! You have it correct.

@jbeuckm jbeuckm closed this as completed Mar 24, 2022
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