0

I have the following geotif file. I wrote simple script to transform its coordinates into google maps coordinate system

import rasterio
import rasterio.features
import rasterio.warp


DATA = "/Users/Desktop/TextureUSDA_23/"


def main():
    with rasterio.open(DATA + 'textureUSDA_eu23.tif') as dataset:
        mask = dataset.dataset_mask()
        print(dataset.crs)
        for geom, val in rasterio.features.shapes(mask, transform=dataset.transform):
            geom = rasterio.warp.transform_geom(dataset.crs, 'EPSG:4326', geom, precision=6)
            print(geom)


if __name__ == "__main__":
    main()

The output of this script is the list of the transformed coordinates i.e. [-4.414515, 57.507086]. However, if I enter this coordinates then they will point to the indian ocean, but they should be placed in Europe.

Could you explain what am I missing?

Additional information about geotiff

PROJCS["GRS_1980_IUGG_1980_Lambert_Azimuthal_Equal_Area",GEOGCS["GCS_GRS_1980_IUGG_1980",DATUM["unknown",SPHEROID["GRS80",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",52],PARAMETER["longitude_of_center",10],PARAMETER["false_easting",4321000],PARAMETER["false_northing",3210000],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]

mr.M
  • 851
  • 6
  • 23
  • 41

1 Answers1

0

The coordinates are returned in x,y order, i.e., longitude and then latitude. Google maps (and other similar services I've seen) expect coordinates in order latitude then longitude. If you swap the order of the coordinates, you'll get a spot near Inverness, which is I'm guessing what you're looking for. There's a nice summary of lon/lat ordering by different techs here.

jdmcbr
  • 5,964
  • 6
  • 28
  • 38
  • Wow. I will try to test swapping coordinates. Btw, it is rather too much asking from my side, but could verify if I am on the right path? Ie is my code correct to extract coordinates from the geo tiff? – mr.M Sep 25 '19 at 16:06
  • Without understanding exactly what you're trying to do, it looked like a reasonable set of steps for getting to locations from features in the image. – jdmcbr Sep 25 '19 at 16:29
  • I want to extract the coordinates from the geo tiff and draw them in google maps. Seems like I am on the right path. Thank you for your response. – mr.M Sep 25 '19 at 16:31