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

Allow additional kwargs to pass from reproject_match() -> reproject() #436

Merged

Conversation

four43
Copy link
Contributor

@four43 four43 commented Nov 22, 2021

I wanted to set a specific nodata value when running a reproject_match and I figured this was the most flexible. What do you all think?

  • Tests added
  • Fully documented, including docs/history.rst for all changes and docs/rioxarray.rst for new API

@four43 four43 force-pushed the feature-reproject_match-kwargs branch from bb7b381 to cf61e44 Compare November 22, 2021 22:15
@codecov
Copy link

codecov bot commented Nov 22, 2021

Codecov Report

Merging #436 (2cd14e8) into master (1755f90) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #436   +/-   ##
=======================================
  Coverage   96.07%   96.07%           
=======================================
  Files          13       13           
  Lines        1530     1530           
=======================================
  Hits         1470     1470           
  Misses         60       60           
Impacted Files Coverage Δ
rioxarray/raster_array.py 98.32% <100.00%> (ø)
rioxarray/raster_dataset.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1755f90...2cd14e8. Read the comment docs.

rioxarray/raster_array.py Outdated Show resolved Hide resolved
@snowman2
Copy link
Member

This makes sense to me, thanks 👍 . Mind adding a simple test to ensure that the nodata passed into reproject_match works properly?

@four43
Copy link
Contributor Author

four43 commented Nov 23, 2021

@snowman2 how do you create these fixture files? When trying to re-use the same parameterized fixtures I keep getting this while trying to open mine:

ValueError: Given file dataset contains more than one data variable. Please read with xarray.open_dataset and then select the variable you want.

After verifying in my debugger the file looked correct I just dumped it out to the fixture location with a mds_repr.to_netcdf([fixture_path]) but that doesn't seem to work...

It has the single data variable!

<xarray.Dataset>
Dimensions:                        (x: 150, y: 100)
Coordinates:
  * x                              (x) float64 4.853e+05 4.857e+05 ... 5.429e+05
  * y                              (y) float64 5.029e+06 5.029e+06 ... 4.991e+06
    spatial_ref                    int64 0
Data variables:
    __xarray_dataarray_variable__  (y, x) int16 -9999 -9999 581 ... 867 804 706

@four43 four43 force-pushed the feature-reproject_match-kwargs branch from cf61e44 to cf370e7 Compare November 23, 2021 02:17
@four43
Copy link
Contributor Author

four43 commented Nov 23, 2021

I squashed and committed what I have but will need help with that fixture. Thanks!

@snowman2
Copy link
Member

I am thinking you need to create the netCDF file starting from a DataArray instead of from a Dataset. Are you able to do that?

@four43
Copy link
Contributor Author

four43 commented Nov 23, 2021

I tried that as well, I gave it the ol:

mds_repr['__xarray_dataarray_variable__'].to_netcdf(modis_reproject_match__passed_nodata["compare"])

And open_dataarray() is still mad! It's pulling in another 'spatial_ref' data_var when opening with that. Did I configure my fixture wrong?

@snowman2
Copy link
Member

What happens if you add decode_coords="all" when opening?

@four43 four43 force-pushed the feature-reproject_match-kwargs branch from cf370e7 to bf8818f Compare November 23, 2021 19:49
@four43
Copy link
Contributor Author

four43 commented Nov 23, 2021

That did it! It's odd that it was required there for some reason...

@four43 four43 force-pushed the feature-reproject_match-kwargs branch from bf8818f to 2cd14e8 Compare November 23, 2021 20:23
@snowman2
Copy link
Member

It's odd that it was required there for some reason...

Related to #287

@snowman2
Copy link
Member

Thanks @four43 👍

@four43
Copy link
Contributor Author

four43 commented Nov 23, 2021

Thanks for the review and help @snowman2. We appreciate the project :D

@snowman2 snowman2 merged commit 34800bb into corteva:master Nov 23, 2021
@four43 four43 deleted the feature-reproject_match-kwargs branch November 23, 2021 21:21
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.

3 participants