How to convert projection of png tile from epsg:4326 to epsg:3857 by one command using gdal

随声附和 提交于 2021-01-28 20:50:41

问题


I have tiled png files and those projection is EPSG:4326. I convert projection to EPSG:3857 with below 2 commands:

gdal_translate -of Gtiff -a_ullr 135.00000000000003 36.59788913307022 140.62500000000003 31.952162238024975 -a_srs EPSG:4326 4326.png 4326.tiff
gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3857 4326.tiff 3857.png

Can I make it with 1 command ?


回答1:


I don't know how to do it with one command, but if you are working on a Unix-like environment, you can use a pipe to avoid creating an intermediate file.

gdal_translate -of VRT -a_ullr 135.00000000000003 36.59788913307022 140.62500000000003 31.952162238024975 -a_srs EPSG:4326 4326.png /vsistdout/ | \
        gdalwarp -t_srs EPSG:3857 /vsistdin/ 3857.png

/vsistdin/ and /vsistdout/ are part of a feature called "GDAL Virtual File Systems", which represents a virtual file that represents standard input and standard output. The output format of gdal_translate could be GTiff, but I tried to use VRT which contains only metadata. If this doesn't work, try changing VRT to GTiff.



来源:https://stackoverflow.com/questions/63320724/how-to-convert-projection-of-png-tile-from-epsg4326-to-epsg3857-by-one-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!