[gdal-dev] problem with wrong corner coordinates in a projected raster

Rahkonen Jukka jukka.rahkonen at maanmittauslaitos.fi
Thu Dec 22 14:09:29 PST 2022


Hi,

The coordinate system and coordinate values must match. Now they don't.
gdal_translate -of GTiff -outsize 1400 0 -a_srs EPSG:3857 -a_ullr 172.5 -35.0 175.0 -36.0

If the source image is in EPSG:4326 this should work:
gdal_translate -of GTiff -outsize 1400 0 -a_srs EPSG:4326 -a_ullr 172.5 -35.0 175.0 -36.0 in.tif out_temp.tif

and then
gdalwarp -t_srs EPSG:3857 out_temp.tif out_final.tif.

-Jukka Rahkonen-

Using -a_srs EPSG:4326 makes more sense but I am not sure if the source image is using that CRS                                                                                                                                      .

Lähettäjä: gdal-dev <gdal-dev-bounces at lists.osgeo.org> Puolesta Sam McClatchie
Lähetetty: torstai 22. joulukuuta 2022 22.54
Vastaanottaja: gdal-dev at lists.osgeo.org
Aihe: [gdal-dev] problem with wrong corner coordinates in a projected raster


Colleagues

I want to georeference and project a raster image. I have an incorrect result where the image is improperly projected, and I am unsure why.

The original image is "SST_plot_New_Zealand_Whangarei_clahe.tif" <http://u.pc.cd/fy8><https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fu.pc.cd%2Ffy8&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Ca852b8ccc2b74558135308dae463a020%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638073413802579283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=EVX0k4kjH%2BPud5Ufh4Y4qkz%2BX089vO5jinTUdkja46w%3D&reserved=0>. (Note: I used links to my cloud server directory to avoid sending attachments to the list).  I created this image with known bounding box limits:

/snip

# elif region == "New_Zealand_Whangarei":
    #     lat_min = (-36.0)  # needs to exactly match the ERDDAP lat/lon ranges
    #     lat_max = (-35.0)
    #     lon_min = (172.5)
    #     lon_max = (175.0)

/end snip

I used these commands in the command line:

gdal_translate -of GTiff -outsize 1400 0 -a_srs EPSG:3857 -a_ullr 172.5 -35.0 175.0 -36.0 ./SST_plot_New_Zealand_Whangarei_clahe.tif ./test_trans.tif

gdalwarp ./test_trans.tif ./test_proj.tif

The result from gdal translate is test_trans.tif <http://u.pc.cd/D4EctalK><https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fu.pc.cd%2FD4EctalK&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Ca852b8ccc2b74558135308dae463a020%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638073413802579283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=wEh2%2B5v%2Fw%2BqlCefeLt7wCmgO6PiuO4Lnw8yjoY1NckI%3D&reserved=0>. The result from gdal warp is test_proj.tif <http://u.pc.cd/a2actalK><https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fu.pc.cd%2Fa2actalK&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Ca852b8ccc2b74558135308dae463a020%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638073413802579283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=CIPJfCE5bCY4vL6bTO3R2LAwr7IV3y1OqXfAnsVMKe0%3D&reserved=0>. The problem, as you will see in the ./test_proj.tif file, is that the corner coordinates are not projected, which means the file is not properly projected. I'm obviously making a mistake.Would someone mind helping me to correct my error, please?

Best fishes

Sam

---
Sam McClatchie (fisheries oceanographer)
& Elena Turin (accounting & auditing)
FishOcean Enterprises Ltd<https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.nzbn.govt.nz%2Fmynzbn%2Fnzbndetails%2F9429049352344%2F%3Fsw%3D&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Ca852b8ccc2b74558135308dae463a020%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638073413802579283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=4EKPVYwDwvW2pqXWfH0uekwAxot%2F29pQiXdwlnJdFro%3D&reserved=0>
www.fishocean.info<https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.fishocean.info%2F&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Ca852b8ccc2b74558135308dae463a020%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638073413802579283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=asijzvLfewigcCgclEpj3%2Bw1iZJg0b526UeU2hAtOy4%3D&reserved=0>
38 Upland Rd, Huia, Auckland 0604, New Zealand
cell: 027 752 8495


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20221222/5c8c6001/attachment-0001.htm>


More information about the gdal-dev mailing list