1

I am completely new to GeoData so this might be somewhat of a silly problem, but I am having a problem with the angle GeoTIFF images tend to come with. I am collecting satellite images for a deep learning segmentation project. For that purpose I need square or rectangular images. But when I import an image with GDAL (via Python) it is an angled image, since these GeoTIFF images contain a projection (in my case an unnamed projection, more info below). When I plot these images I get a rotated images, with the sides filled with black to form a square.

These rotated images are useful in many geo-related cases, but not for deep learning. Every image needs to be a square/rectangle. Every pixel needs to come from the image itself (not a black fill). I want to remove the angle in the image: in essence remove the projection. I have been searching and trying for days to simple remove the projection, but I keep failing. Does anyone here know how I can "unangle" these images, either by removing the projection (if that is even possible) or rotating the image? Or is there an even easier method?

Some information of images I'd like to process (un-angle) is:

Coordinate System is:
PROJCRS["unnamed",
    BASEGEOGCRS["Amersfoort",
        DATUM["Amersfoort",
            ELLIPSOID["Bessel 1841",6377397.155,299.152812800003,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4289]],

Corner Coordinates:
Upper Left  (  185042.500,  364840.000) (  5d49' 5.55"E, 51d16'22.64"N)
Lower Left  (  185042.500,  348993.000) (  5d49' 0.74"E, 51d 7'49.79"N)
Upper Right (  200000.000,  364840.000) (  6d 1'57.25"E, 51d16'19.08"N)
Lower Right (  200000.000,  348993.000) (  6d 1'50.05"E, 51d 7'46.24"N)
Center      (  192521.250,  356916.500) (  5d55'28.40"E, 51d12' 4.62"N)

This problem does not occur when I import raw satellite imagery, and therefore I am looking in that direction for potential answers. These raw images have a SpatialReference of None, a GeoTransform of (0.0, 1.0, 0.0, 0.0, 0.0, 1.0), and the Corner Coordinates are specified by simple pixel locations (6395 is the size of Y whereas 5720 is the size of X):

Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 6395.0)
Upper Right ( 5720.0,    0.0)
Lower Right ( 5720.0, 6395.0)
Center      ( 2860.0, 3197.5)
  • You probably need to unproject the data from 28992 (Amersfoort RD New) to Amersfoort (lat-lon 4289) or WGS84 (lat-lon 4326) or (shudder) Web Mercator (projected 3857). It may not take care of all nodata. – mkennedy Sep 30 at 17:13
  • Thanks for the suggestion. I also tried these projections (using gdal.Warp) and though the image did change, it did not become rectangle (and not reduce the nodata by much). If you have any other suggestions (EPSG's or how I could look for the correct EPSG), i'd be glad to hear them :). – TheBackwardsman Oct 3 at 20:52
0

I suspect you are encountering NoData values around the satellite image as shown in the below image. Your imagery is likely not "Analysis Ready Data (ARD)", but rather uses something like the WRS-2 path data. For more on how USGS tiles Landsat scenes, see the following information (note that all satellite providers will have a description on how they tile data at the various processing levels):

U.S. Landsat Analysis Ready Data

There is also a similar question that has pertinent information, though will not likely answer your question:

How do I eliminate the black border on a georeferenced map layer?

In sum, you cannot remove the projection to remove the NoData border. Instead, you will have to choose how you will handle the NoData border around the satellite path data. Here are your options:

  1. Handle the NoData values in your deep learning model
  2. Combine all of your satellite imagery into a mosaic and then generate your own tiling scheme
  3. Look for a different source that provides ARD tiles

enter image description here

  • Yes, I've found that what you said is true. I've made something along the second option (though without the need for a mosaic at the moment since I'm using them for training. When I finish all my code I'll post it somewhere here since satellite images need to become available more easily so people can make models with them. Thanks for your input! – TheBackwardsman Oct 31 at 20:42
0

Two simple solutions with GDAL command line utilities

  1. Use the Python script gdal_edit.py https://gdal.org/programs/gdal_edit.html#gdal-edit with option -unsetgt

-unsetgt Remove the georeference information.

  1. Use gdal_translate utility (also available directly from Python as gdal.Translate, see https://erouault.blogspot.com/2015/10/gdal-and-ogr-utilities-as-library.html) and GTiff driver https://gdal.org/drivers/raster/gtiff.html to create a baseline TIFF file

Usage:

gdal_translate -of GTiff -co PROFILE=BASELINE input.tif output.tif

  • ty for the help! I've tried gdal.translate() but it does not remove the angle. Maybe there is sth wrong with the way I coded: do you see sth that is off? I tried the following three translateoptions before putting it in gdal.Translate(): 1) to = gdal.TranslateOptions(gdal.ParseCommandLine("-of Gtiff -co PROFILE=BASELINE")) #2)to = gdal.TranslateOptions(gdal.creationOptions=['PROFILE = BASELINE'], format='GTiff') #3)to = gdal.TranslateOptions(creationOptions=['PROFILE = BASELINE'], format='GTiff') outFile = gdal.Translate(outdir, tif_images[0], options=to) – TheBackwardsman Sep 29 at 21:31
  • Perhaps this example helps github.com/OSGeo/gdal/blob/master/autotest/utilities/… – user30184 Sep 30 at 8:21
  • Ty again! (and sorry for more questions, really struggling). Sadly, these functions create a new image but with the same angle. For example, i used gdal.Translate(out_path.tif, input, creationOptions=['PROFILE=BASELINE']). It creates a tif file + a tif.aux.xml, and the tif.aux.xml has the same SRS dataAxisToSRSAxisMapping as the angled image (simply deleting the xml doesnt work). For some reason the profile = baseline doesn't seem to work: might it be named differently in gdal in python? Or do I have to use any other things beforehand before it can work? Perhaps any other ideas? Ty again! – TheBackwardsman Sep 30 at 20:26
  • Deleting the aux.xml file should definitely work and it is also possible to prevent the creation of the aux.xml file with a configuration option. However, because you want to update the existing image then use the gdal_edit.py script. – user30184 Oct 1 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.