appelmar / gdalcubes_cpp

Earth observation data cubes from GDAL image collections
MIT License
74 stars 7 forks source link

Problem with axis order #40

Closed DavidHernandezLopez closed 2 years ago

DavidHernandezLopez commented 2 years ago

Dear author Your project is just greath Using new versions of proj, from GDAL, the first axis in geographic CRSs is latitude and the second axis es longitude. I think the solution is compile including an easy change: srs.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER) in every OGRSpatialReference object after before Best David

appelmar commented 2 years ago

Thanks, David and sorry for the late reply. What exactly is going wrong? OAMS_TRADITIONAL_GIS_ORDER ahould already be used by default (see https://github.com/appelmar/gdalcubes/blob/e89d9a2838c648a0d56ec8ff89a733732e7cfbc0/src/config.cpp#L110).

appelmar commented 2 years ago

Ah OK this is interesting. Maybe a better approach would be to store WKT strings in image collections.

DavidHernandezLopez commented 2 years ago

Sorry, but the option CPLSetConfigOption("OGR_CT_FORCE_TRADITIONAL_GIS_ORDER", "YES"); does not work. In images table, latitudes are stored in fields left and right and longitudes are stored in fields up and down. Best David

appelmar commented 2 years ago

Can you share an example image or the output of gdalinfo of an image? I get the following with default settings (using different data, of course):

Screenshot from 2022-03-16 16-35-56

DavidHernandezLopez commented 2 years ago

dear Marius I am making a shared unit in google drive with images and database Can you send me your email to share with you the folder? Best david

appelmar commented 2 years ago

Great, thanks! Please share with marius.appel@uni-muenster.de

DavidHernandezLopez commented 2 years ago

You should have received an email with the link.

appelmar commented 2 years ago

Many thanks, could you also share the code / command you used to generate the image collection?

Using R, I get:

library(gdalcubes)
f = list.files("201909", pattern = ".tif", full.names = TRUE)
dt = as.POSIXct(substr(basename(f), 1, 15),format = "%Y%m%dT%H%M%S", tz = "GMT")
create_image_collection(f, date_time = dt, band_names = "ndvi",out_file = "test.db")

Screenshot from 2022-03-16 20-25-14

This seems correct, so my guess is that simply the config options are not set properly from C++ (I need to check).

DavidHernandezLopez commented 2 years ago

First of all, thank you very much for your help and my apologies for my bad English. I am developing a plugin in QGIS integrating gdalcubes with the definition of a local nested grid to apply classification algorithms to large areas with time series of remote sensing scenes from different space missions, as I explain at the end of the article https://www.mdpi.com/2072-4292/13/8/1546 This plugin run in windows but i could not compile gdalcubes in windows enviroment using qtcreator (with microsoft visual studio 2015) and libraries version from osgeo4w (gdal, proj, ...). In a first version i use gdalcubes from R in windows, but i get some errors and decided to use gdalcubes from docker, developing programs that use the gdalcubes library, read files generated from the qgis plugin where i write the images to use, the processes to perform, and the paths for the results. As a previous version I am developing the programs in a virtual machine ubuntu 20.04. I am going to upload to the shared folder the folder structure from the root path of ubuntu, the user name is ubuntu too. The program for make the images database is: /home/ubuntu/dev/gdalcubes/projects/pafyc_gdalcubes_create_images_collections using as argument the file: /home/ubuntu/Desktop/GDALCubesProjects/AmalTunez/gdalcubes/s2/temp_docker/gdalCubes_createImageCollections_linux.txt I can share with you everything you tell me. I could even give you access to the virtual machine with andydesk. In case you think it's better to continue this topic by email, my email is david.hernandez@uclm.es. My researchs groups: https://pafyc.uclm.es/ https://tidop.usal.es/ My orcid: https://orcid.org/my-orcid?orcid=0000-0001-9874-5243 I would really like that we could collaborate in this work Best David

appelmar commented 2 years ago

Thanks for sharing, this sounds really interesting and I have to a admit that the documentation of the C++ part is really still missing important parts (e.g. compilation on Windows). That being said, I had a look at the pafyc_gdalcubes_create_images_collections/main.cpp file, maybe simply adding the following line before you use any gdalcubes functions can solve the axis order issue?

gdalcubes::config::instance()->gdalcubes_init();
DavidHernandezLopez commented 2 years ago

You're right. This solves my problem. My apologies. I will continue with the development and if I have any problems I will ask for your help. Many many thanks

2022-03-17 11_08_35-DB gdalcubes_issueSolvedImagesDatabase

appelmar commented 2 years ago

Great to hear, let me know if anything does not work!