I found this guide to get pixel value of raster under point: Getting pixel value of GDAL raster under OGR point without NumPy?
I've a problem here:
for feat in lyr:
geom = feat.GetGeometryRef()
mx,my=geom.GetX(), geom.GetY() #coord in map units
If I print geom
, I can see all the point's coordinates but if I print mx
or my
the result is 0
for every feat.
if I print geom:
MULTIPOINT (9.48556682927651 39.1368546561669)
MULTIPOINT (9.46173837787432 39.1298387934389)
MULTIPOINT (9.54058251881085 39.441437960101)
MULTIPOINT (9.08688113454087 39.5390542536278)
MULTIPOINT (9.00215692841357 39.0072908447031)
MULTIPOINT (9.17741005408364 39.2751570664614)
if i print mx
or my
:
0.0
0.0
0.0
0.0
0.0
0.0
I'm using Python 3 maybe this could be a problem