Geographic projection missing in output

@Jan @Olivier @marpet @Fabrizio_Ramoino

Can any of your please chime in on this issue!?
Having TOC Data with no projection makes the whole tool pretty much useless and workarounds like they are posted here can’t really be a long term solution.
I’m at a loss why solving this wasn’t high on the priority list for the recent update, the update even deteriorated the bug since the gdalcopyproj.py workaround won’t work anymore.

@ChristianSeverin

4 Likes

I have managed to use gdalcopyproj.py in another computer but I agree with Christian in the sense of this issue must be resolve quickly in order to make this tool feasible, at least not losing the DEM information from L1C to L2A. I have been in the ESA Living Planet Symposium last May and we were looking forward for a solution on this issue without any response.
Hope the summer Sen2Cor update will fix all these stucking problems!

or you can use this little python script.
gdal python module is required (use easy_install if needed).

get it there https://bitbucket.org/nmatton/public-scripts/src/3a3f132314b04440b9e753dfe000d42e31d34d32/python/S2_tests/georefL1cToL2A.py?at=master&fileviewer=file-view-default

1 Like

does it work with sen2cor 2.2.1 ?

Yep !
It simply transpose georef and projection from L1C to L2A

Dear all,
I’m a complete newbie in the matter. I’ve been following all instructions and gathering all technical data (not easy) to understand Sentinel-2 products and to correct the images to get BOA reflectances. I was happy when I got everything working until I realized L2A jp2 bands were not georeferenced. I found this thread in the forum but now I need help from you on how to apply the nmatton script. I’m sorry but I have no idea on how or where to start… I guess I need to install Python and GDAL for Python in my W8.1 machine but after reading the thread with problems in Sen2cor installations I’m affraid that I could damage mine which is currently working.

Could any of you please help me with some directions on what are the steps to run the nmatton script from zero. I would really appreciate that.

And just for some additional discussion. Is that a bug in Sen2cor or is there anything to be done to georeference the L2A output bands within SNAP 3.0?

Gratefully

If you can run sen2cor python ist already installed on your machine.
I have not run @nmatton script but from looking at the code your should be able to run in in a CMD window with python path/to/georefL1cToL2A.py -i folder
where folder = the folder containing S2 SAFE folders (OPER and USER)

I still run sen2cor 2.0.6 because I have a working setup and 2.2.1 didn’t improve on this critical issue. Here gdalcopyproj.py works. Usage is: python gdalcopyproj.py projFile.jp2 unprojFile.jp2
You have to loop through the images, so if you have no coding experience your best choice is to use nmattons script which takes the whole folder as input.

Is that a bug in Sen2cor or is there anything to be done to georeference the L2A output bands within SNAP 3.0?

I doubt SNAP is capable of handling this issue. Unfortunately we don’t have any information about solutions or progress because the involved personel @Jan @Olivier @marpet @Fabrizio_Ramoino remain silent about this.

Hi,

I’m really an L1C kind of guy, so I’ll flag it to my colleagues who have expertise in L2A.

Cheers

Jan

1 Like

@nmatton

I tried your script (thanks for making it available!) and i run into the same issue I get stuck with using gdal.
Both (python) scripts can’t open the .jp2 files produced by sen2cor 2.2.1. Did you have this problem as well, if yes how did you solve it?

Sorry to hear about that. But it seems to be a gdal issue.
Be sure to have the JP2000 driver installed (look for JP2OpenJPEG (most common) in output of gdalinfo --formats )

1 Like

thanks for the hint. Indeed the JP2000 driver was missing on the machine where sen2cor 2.2.1 was installed.
I removed sen2cor and installed GDAL individually. JPEG2000 driver is there and .jp2 can be read (gdalinfo). Unfortunately installing sen2cor 2.2.1 overwrites the former gdal installation thus removing the driver. I tried to remove the gdal installation from the setup.py file but wasn’t successfull.

Any hints are welcome

Dear unnic,
I really appreciate your reply and the time invested in making it work. However, if you don’t mine I’ll wait for you and the rest of pros to solve it before trying…
Thank you!

@unnic

Hi,

I’ve raised it with my colleagues, and it appears that it is a known issue. As to when it is sorted; that I cannot say with any certainty. Sorry.

I’ve asked my colleagues to look at this thread.

Cheers

Jan

Hello @nmatton,

I tried to georefrence L2A images using your script on windows x64 system but script proccesing isn’t getting any progress at all. All i see is 0.0% at any product i tried to process.

Any help?

Hello,

i am trying to use nmatton’s script @nmatton but the progress always remains at 0.0%, no error appears and nothing happens. I had exactly the same result using the script on windows and linux system. @unnic the script worked in your case? What could be the cause? Maybe i should use a specific version of python and gdal ? Well, i was thinking about doing the projection using ground control points in ArcGis but i think nmatton’s code could help me a lot.

@ Rea

I suppose it’s the same problem as described here: Geographic projection missing in output . You can try by checking if the jp2 driver (JP2OpenJPEG) is missing in the output of gdalinfo --formats

@nmatton s approach isn’t much different from gdalcopyproj.py (using gdal.Open() ) so it’s also not working in this case because the driver is missing.

I suggest uninstalling everything (Python, Anaconda …) and reinstalling sen2cor 2.0.6 which does not remove the needed driver.

@unnic
Thanks for your answer.

I installed Anaconda on Ubuntu 16.04 and then manually i installed osgeo gdal package 1.11.2. I checked the installations and all packages respond correctly. Also jp2 driver is supported by GDAL as you can see in the image bellow. But still script is not running it stucks on progress 0.0%…

I don’t know what else to do :tired_face:

sry, I can’t speak for nmattons script, it did not work for me but gdalcopyproj.py does.

1 Like

@nmatton
So I managed to reinstall GDAL with a driver for jp2 files.
running gdalinfo filename.jp2 from the command line returns the expected output but in python

import gdal
data=gdal.Open(filename)

does not return anything.

I assume python is not directing to the right GDAL installation Is there a way to set the installation path of gdal within python?

1 Like

Hi,

I was in the belief that the most recent version of sen2cor (2.3.0) fixed the problem with missing geo reference in the L2A output. Anyhow, for me the problem still occurs … the only thing new is the output of *geo.jp2 files, which I can’t seem to open or use.

Am I missing something obvious or can someone shed some light on this for me?

Much appreciated,

Val