nansencenter / nansat

Scientist friendly Python toolbox for processing 2D satellite Earth observation data.
http://nansat.readthedocs.io
GNU General Public License v3.0
181 stars 66 forks source link

resize with eResampleAlg>0 gives ProjectionError #33

Closed mortenwh closed 10 years ago

mortenwh commented 11 years ago

n0: Some nansat object

In [37]: n0.resize(0.5,eResampleAlg=1) In [38]: n0

ProjectionError: Empty projection in input dataset!

Same happens for eResampleAlg=2,3,4

akorosov commented 11 years ago

Morten can you please provide more details in your issues? What was the input file at least? Did it have GCPs or geotransform?

mortenwh commented 11 years ago

It was a radarsat-2 file. I don't understand why it should be specific to rs2 though, so therefore this should be tested also on other data...

On 26 September 2013 08:45, akorosov notifications@github.com wrote:

Morten can you please provide more details in your issues? What was the input file at least? Did it have GCPs or geotransform?

— Reply to this email directly or view it on GitHubhttps://github.com/nansencenter/nansat/issues/33#issuecomment-25146771 .

akorosov commented 11 years ago

Nansat.resize() with eResampleAlg > 1 was supposed to be used for getting smoothly resized matrices only. It was not supposed for keeping the Nansat object with correct geolocation information. Although it is not in documentation. Solving this issue is possible but is rather complicated. And it is an improvement than a bug-fix. I would rather postpone it until 0.6.

mortenwh commented 11 years ago

Then this should at least be clearly written in the documentation.... But I definitely think we should solve this for nansat - for me this is quite urgent unless we come up with another temporary solution. The functionality like it is now is not good because it gives the impression that nansat behaves similarly regardless of which algorithm is used in resizing.

On 27 September 2013 09:56, akorosov notifications@github.com wrote:

Nansat.resize() with eResampleAlg > 1 was supposed to be used for getting smoothly resized matrices only. It was not supposed for keeping the Nansat object with correct geolocation information. Although it is not in documentation. Solving this issue is possible but is rather complicated. And it is an improvement than a bug-fix. I would rather postpone it until 0.6.

— Reply to this email directly or view it on GitHubhttps://github.com/nansencenter/nansat/issues/33#issuecomment-25228680 .

mortenwh commented 11 years ago

... - so for v0.6 we'll return two one function which consistently resizes the nansat object for all values of eResampleAlg

asumak commented 10 years ago

Is it ok to use reproject()? Then, the shapes of images are changed.

mortenwh commented 10 years ago

No - the resulting arrays should be like the originals

On 18 October 2013 11:40, Asuka Yamakawa notifications@github.com wrote:

Is it ok to use reproject()? Then, the shapes of images are changed.

— Reply to this email directly or view it on GitHubhttps://github.com/nansencenter/nansat/issues/33#issuecomment-26583267 .

asumak commented 10 years ago

How do you think about move line 570-670 in nansat.resize() to VRT?

My plan is:

  1. resize each band using PIL.Image.thumbnail()
  2. create new VRTs with resized arrays
  3. modify XML (replace source fileNames and size)

Problem: thumbnail() has 4 filters as NEAREST, BILINEAR, BICUBIC, or ANTIALIAS. CubicSpline and Lancoz are not included.

Any suggestions?

akorosov commented 10 years ago

We cannot keep resized images in memory. That's the whole point of Nansat - lazy operations.

akorosov commented 10 years ago

This ticket is closed, by the way.

mortenwh commented 10 years ago

What if (at least as a temporary workaround) we follow the method proposed by Asuka and write the resized data to temporary files like it is done in the VRT class with option 'nomem'=True? See lines 318-320 in vrt.py...

asumak commented 10 years ago

Can you please test fbb199b, Morten? I have solved #41 and committed together.

akorosov commented 10 years ago

Seems to be fixed buy implementing #38