Geographic Information Systems Asked on December 8, 2021
I tried to retrieve the resolution of a raster image with Gdal in a python notebook to convert surfaces from pixels to hectares.
import gdal
from osgeo import osr
src = gdal.Open(map_raster)
proj = osr.SpatialReference(wkt=src.GetProjection())
_, resx, _, _, _, resy = src.GetGeoTransform()
src = None
I expected resx
to be in meter but a print(resx)
gave me 0.00025000000000000017
which would be very small if expressed in meters.
So my question is how can I know the unit system used by the GetGeoTransform
function ?
EDIT
the proj
value is :
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AXIS["Latitude",NORTH],
AXIS["Longitude",EAST],
AUTHORITY["EPSG","4326"]]
"So my question is how can I know the unit system used by the GetGeoTransform function ?"
The units used in GetGeoTransform
are 100% related to your coordinate system. Perhaps you can read-up about coordinate systems (there are various coordinate systems for various applications).
The two main types of coordinate systems is either a "Geographic" or a "Projected" coordinate system. Your current file is in WGS 84 (epsg 4326) and is a geographic coordinate system and uses degrees as a unit. This coordinate system is widely used for display purposes (and navigation perhaps), but it is not accurate for area measurements (e.g. your true pixel size).
What you want to do is re-project your raster image to a projected coordinate system (one that is specific to the area of you image, most commonly used is the universal transverse mercator (utm), you just need to know your zone). Once the image is re-projected into a projected coordinate system your pixel size from GetGeoTransform
will be in meters.
I hope that helps.
Answered by Jascha Muller on December 8, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP