Hello!
I am trying to display SAR satellite imagery in .NET MAUI (such as ICEYE).
Is this supported in any way? I already tried loading the .tif files as a RasterLayer, but the map remains empty.
Thank you!
Solved! Go to Solution.
The project where I needed this is finished. I ended up using a workaround. This post is for documenting additional findings and to offer help to people in the future who might stumble across the same problem.
First of all, what might be the cause? Unfortunately, there is no way to be 100% certain (for me) but I think the problem is caused by the GeoTransform tag in the geoTIFF. The SAR images from ICEYE are not north facing (a.k.a: the top of the image is not north). Instead if you call gdalinfo on it you will notice that it has a GeoTransfrom tag describing how to rotate the image in order to make it north facing.
What I ended up doing is pulling gdal into my MAUI app via a nuget package (I personally used the MaxRev.Gdal since it doesn't require gdal to be installed on the target machines) and I rotate the images manually before displaying it in my application.
Specifically I used to following functions:
(Make sure that you call: GdalBase.ConfigureAll(); when you app starts before using these)
originalDataSet = Gdal.Open("OriginalTiff.tif", Access.GA_ReadOnly);
// warp will make the map north facing, and get rid of the geoTransform tag
using var warpedFile = Gdal.Warp("TempFile.tif", [originalDataSet], new(["-of", "COG", "-t_srs", "EPSG:4326", "-r", "bilinear", "-multi", "-wo", "ALL_CPUS"]), null, null);
//translate will mark the empty pixels as empty, thus making it invisible in the application
using var transformedFile = Gdal.wrapper_GDALTranslate(destinationFile, warpedFile, new([ "-of", "COG", "-co", "ADD_ALPHA=YES", "-a_nodata", "0", "-co", $"NUM_THREADS={Environment.ProcessorCount}"]), null, null);
In case it is confusing why the translate is necessary. After the warp the original image (which is a rectangle) will be roatated. The new image will have to be a rectangle too, but due to the rotation it won't overlap perfectly with the old image. So the new image will have some "padding" where no data is present. I needed to make those parts invisible.
After running the above code the newly created geoTiffs appear as expected.
Hi there,
Samples demonstrating RasterLayer workflows for .NET MAUI can be found here:
If you are trying to load a bundled file on .NET MAUI there are a couple of additional steps, this is covered for an .mmpk file in this tutorial: Display a map from a mobile map package (.NET MAUI).
Essentially, you need to first make sure the bundled file has build action "MauiAsset". This file needs to be written to the the "AppDataDirectory" from where it can then be loaded to initialize the RasterLayer.
I may not have a full understanding of your problem so please let me know if this doesn't resolve your issue.
Sorry, I wasn't clear enough.
I want to display a SAR geotiff in a Map.
e.g.: https://www.iceye.com/resources/datasets <- the Houston, USA sample reproduces the problem, I haven't tried the other ones(You need to download the dataset that says geotiff)
However, when I load it the way it is done in the examples, the map remains empty.
var rasterFile = new Raster(file.FullPath);
var baseLayer = new RasterLayer(rasterFile);
var baseMap = new Basemap(baseLayer);
Map = new Map(baseMap);
Here I am loading it as a basemap but loading it as an operational layer does the same.
Here is a link to a screenshot, about what I see: https://imgur.com/hGTrsnp
Try adding "await baseLayer.LoadAsync()" and see if the layer loads fine. Also check the debug output for any hints around load or render issues
Thank you for your answer but unfortunately neither of them did anything.
Here is the debug output, with the
await baseLayer.LoadAsync();
already added.
Here is the debug output of my Demo app, I don't see any issues.
I've managed to reproduce your issue with your code and the data you are using.
We'll investigate this further and let you know.
The project where I needed this is finished. I ended up using a workaround. This post is for documenting additional findings and to offer help to people in the future who might stumble across the same problem.
First of all, what might be the cause? Unfortunately, there is no way to be 100% certain (for me) but I think the problem is caused by the GeoTransform tag in the geoTIFF. The SAR images from ICEYE are not north facing (a.k.a: the top of the image is not north). Instead if you call gdalinfo on it you will notice that it has a GeoTransfrom tag describing how to rotate the image in order to make it north facing.
What I ended up doing is pulling gdal into my MAUI app via a nuget package (I personally used the MaxRev.Gdal since it doesn't require gdal to be installed on the target machines) and I rotate the images manually before displaying it in my application.
Specifically I used to following functions:
(Make sure that you call: GdalBase.ConfigureAll(); when you app starts before using these)
originalDataSet = Gdal.Open("OriginalTiff.tif", Access.GA_ReadOnly);
// warp will make the map north facing, and get rid of the geoTransform tag
using var warpedFile = Gdal.Warp("TempFile.tif", [originalDataSet], new(["-of", "COG", "-t_srs", "EPSG:4326", "-r", "bilinear", "-multi", "-wo", "ALL_CPUS"]), null, null);
//translate will mark the empty pixels as empty, thus making it invisible in the application
using var transformedFile = Gdal.wrapper_GDALTranslate(destinationFile, warpedFile, new([ "-of", "COG", "-co", "ADD_ALPHA=YES", "-a_nodata", "0", "-co", $"NUM_THREADS={Environment.ProcessorCount}"]), null, null);
In case it is confusing why the translate is necessary. After the warp the original image (which is a rectangle) will be roatated. The new image will have to be a rectangle too, but due to the rotation it won't overlap perfectly with the old image. So the new image will have some "padding" where no data is present. I needed to make those parts invisible.
After running the above code the newly created geoTiffs appear as expected.