Geographic projection missing in output

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

Hey Val,

i just processed a recent acquisition with sen2cor 2.3.0. The resulting .jp2 files are projected correctly.
Check if L2A_process -h indicates that the correct version is used; e.g.: Sentinel-2 Level 2A Prototype Processor (Sen2Cor). Version: 2.3.0,

Hi unnic,

thanks for the answer.

I just checked again, and I’m running definitely version 2.3.0.

Sentinel-2 Level 2A Prototype Processor (Sen2Cor). Version: 2.3.0, created:
2016.11.18, supporting Level-1C product version: 14.

That’s what’s confusing me … also the *geo.jp2 files. Are these supposed to be there or maybe a sign of an unfinished process?

So your sen2cor output .jp2 files do open but are simply unprojected (like it was with sen2cor <2.3) ? Any error messages?

Precisely … with the only difference of having additionally files like

S2A_USER_MSI_L2A_TL_MTI__20160709T114209_A005466_T36PWT_B02_10m_geo.jp2

as well.

No error messages during the processing, the only thing I’ve noticed is that sen2cor ocassionally “pauses” until I hit the return button … which I tried to sort out here: