3

I have some raster images, and I would like to determine the GSD using Python.

I know that I can use rasterio.transform() or gdal.GetGeoTransform() to extract the spatial resolution of the image.

How do I determine the units of the spatial resolution.

7
  • 1
    I don't think I've seen this called GSD before, and for anyone else it stands for "Ground Sampling Distance". (My default for GSD is German Shepherd Dog)
    – Spacedman
    Commented Nov 8, 2020 at 11:32
  • Sorry if it wasn't clear enough I updated the question. I was hoping there would be a way to use the spatial resolution to determine the GSD.
    – A Merii
    Commented Nov 8, 2020 at 14:15
  • Is the spatial resolution not equivalent to the GSD?
    – A Merii
    Commented Nov 8, 2020 at 14:16
  • Related: gis.stackexchange.com/a/115035/8104
    – Aaron
    Commented Nov 8, 2020 at 15:25
  • Thanks a lot, in this case I will rephrase the question so that others can benefit.
    – A Merii
    Commented Nov 8, 2020 at 15:45

1 Answer 1

4

You can use the linear_units property in the crs class. For example:

import rasterio

raster = rasterio.open('/path/to/your/raster.tif' )

print(raster.crs.linear_units)
4
  • 2
    What if this just sayis 'unknown' ? :( Showing this rater in QGis, for example, knows where to put each pixel, so surely it can calculate GSD, no? Commented Jul 30, 2021 at 14:16
  • Is there an equivalent for GDAL?
    – dazonic
    Commented Jan 25, 2023 at 11:56
  • @dazonic This may be helpful: gis.stackexchange.com/a/368008/8104
    – Aaron
    Commented Jan 25, 2023 at 15:55
  • @Aaron that only get the x and y res in numbers, I’m looking for a way to get units, ie degrees or metres
    – dazonic
    Commented Feb 7, 2023 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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