GDAL: unit of measure not found

Dear @cudroiu, @lnicola

I have run into an issue when executing the L4B processor (sen4cap version is 2.0 on a completely fresh machine) and was wondering whether you could give me a hand in this. We have run this processor successfully on v1.2 before.

The L4B processor successfully finishes MowingInputShpGenerator and S2MowingDetection steps, but errors out on the S1MowingDetection step with an error message:

/home/sen2agri-service/miniconda3/envs/sen4cap/lib/python3.6/site-packages/scipy/ndimage/measurements.py:668: RuntimeWarning: invalid value encountered in true_divide
return sum / numpy.asanyarray(count).astype(numpy.float64)

Traceback (most recent call last):
File “/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_main.py”, line 854, in
main()
File “/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_main.py”, line 848, in main
do_cmpl=s4cConfig.do_cmpl, test=s4cConfig.test)
File “/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_main.py”, line 584, in main_run
compliancy_conf_file=configFile)
File “/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_main.py”, line 151, in run_proc
srcNodata=invalid_data, resampling=resampling, error_threshold=error_threshold)
File “/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_gmd.py”, line 246, in make_vrt
data_proj = gdal_data.GetProjection()
File “/home/sen2agri-service/miniconda3/envs/sen4cap/lib/python3.6/site-packages/osgeo/gdal.py”, line 2272, in GetProjection
return _gdal.Dataset_GetProjection(self, *args)
RuntimeError: PROJ: proj_uom_get_info_from_database: unit of measure not found

From what I gather, this issue is due to GDAL working with a dataset that has a user-defined CRS.
This topic on GIS Stack Exchange mentions a very similar situation:

The proposed solution seems to be to update the GDAL library.
So my question is - have you run into this problem? If GDAL being out of date is at fault, would it be possible to update GDAL within the system and not cause conflict with other dependencies? If so, could you provide the appropriate instructions?

Thanks for the help in advance!

Best,
Harijs

Hi Harijs,

I have run into the same problem myself. I tried updating libgeotiff (the underlying source of the error according to the referenced github issue) but it didn’t help and I managed to break even stuff that was working before :smiley:

However, when I tried running L4B processor with only a subset of S1 products I found out that the problem is not necessarily caused by faulty lib, because it is working fine for most of the S1 products. Turns out that in my case out of almost 100 input products only 2 were causing the error, so I decided to ignore the faulty ones.

It can be done by editing the file /usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_gmd.py

Originally, line 246 looked like this

data_proj = gdal_data.GetProjection()

I have wrapped it in try-except so that the execution could continue:

try:
    data_proj = gdal_data.GetProjection()
except RuntimeError:
    print("geoprojection RuntimeError in file", file, ", skipping")
    data_proj = ''

System will consider the file as not having a geoprojection and discard it, but continue without crash.
The products themselves are still probably faulty which may cause issues to other processors as well. I will write an update if that happens.

Best,
Adam

2 Likes

Hi Adam,

Such a simple yet effective solution. I wonder how I didn’t think of this. I did the changes you proposed and now the processor works as it should. Thanks a lot! :slight_smile:

Harijs

Hi,
I have the same problem but unfortunately there are so many products with the error that i do not get any mowing detections based on only S1. I followed the link you have posted and it seems that the newest gdal update corrected the error but have you tried to update GDAL and checked if it is not causing any other problems?

Best
Bastian

Hi Bastian,

Have you found an input product where GDAL reports that error? Can you upload it somewhere?

Hi,
yes no problem. I am running the L4B with only S1 from the terminal. I have attached a folder with one of the coherence tif files which is flagged with an error. image1 in the folder shows the terminal output without any changes in the S1_gmd.py script. image2 shows the main error which shows upp very often when I add the changes adam.knaze suggested for the S1_gmd.py script. With the changes, the whole L4B finishes and does not terminate before. terminaloutout.txt is everything the terminal shows when i run L4B so you will find the error in that text file plenty of times. But i am getting no mowing events in the output shapefile so i am guessing it is because so many products are skipped.
Ny mapp.zip (1.9 MB)

Have you found a solution?

I’m not sure what’s wrong. I can reproduce that error (well, it’s a warning for me) on my computer (outside of Sen4CAP), but it works in an OSGeo Docker container. I think the processor is already running in a container, so we could upgrade. On the other hand, the code that’s crashing is not used.

But the strange part is that the whole raster is black. Are the others like that, too? You can check by running gdalinfo -stats on them.

I checked another product and its the same problem. So a coherence tif is created but it has only 0 as a value. There is also no amplitude product created and the log shows that it got skipped. I have attached another tif and the log to it. There is a lot of these no data tifs in our archive so that S1 would not really contribute much to an analysis i fear. But I think its odd that these products are not flagged as faulty since they do not contain real data. Hopefully you can find a fix for it.
output_20210817.zip (658.7 KB)

I’m not sure what’s up, but can you confirm the location of your site (Sweden)?

Yes thats correct. If it helps, we can add your ssh key and you can have a look yourself.

Thanks. Here are the SSH keys of Cosmin and myself:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK225/L73iOfC3BiEoc1wqdgDYOQFn3WByjUpyupges0 grayshade@heidr
sh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAlDohzAX8Yi5YvPnrS0SzCZotTxphLeWXmwkN0rzmy1iT2HFNLsbj7QaHqqIWY6Qy8XOEX1RqjeaNcmTSw9uzEI/mUra/LgXnk7KzS4UAOl9r8tlni00htx7VSL9iIo5b5yybjXLPlTGAkCAH8BGiZLL1vX6dQjfsJF4fniwMymHj8Smtu3An13DJicUQq01CM9QjwmSG+4O+WqEf44XvBdd3YUJy40sEW3GJnWMvcTFSZiGNfOXwgvqYyD4743oNhYZyxyCmxQ9rf89rlwVb8CdZ9nPJ99K2f4MTr5XeHlum2rvYoY5XUIjxsyLKkw02vi/tZ2ZiAPmAQ3FPPr1ocQ== CIU

Ok,
we have now added your key to the machine. I hope you can find the problem :slight_smile:

Hi @BBerlin and @lnicola,

this is an old thread now, but I’ve recently been having a lot of the same issues as described here - S1 processing resulting in coherence products with just 0s and amplitude product skipped. Did you manage to resolve the issue back then? Thanks for any tips.

Adam

Hi Adam,
I checked my old mails that I had with @cudroiu about this issue. He first ran a script to find all of the products and then deleted them so that they can get reprocessed. After that, the productas were fine but I could not find the reason for the faulty products in the mail conversation.
/ Bastian