本文介绍了如何使用gdal通过一个命令将png瓷砖的投影从epsg:4326转换为epsg:3857的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经平铺了png文件,而这些投影是EPSG:4326.我使用以下2个命令将投影转换为EPSG:3857:

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

我可以用1个命令完成吗?

Can I make it with 1 command ?

推荐答案

我不知道如何使用一个命令来完成此操作,但是如果您在类Unix环境下工作,则可以使用管道来避免创建中间文件.

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/和/vsistdout/是称为"GDAL虚拟文件系统" ,表示代表标准输入和标准输出的虚拟文件. gdal_translate 的输出格式可能是GTiff,但是我尝试使用仅包含元数据的VRT.如果这不起作用,请尝试将VRT更改为GTiff.

/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.

这篇关于如何使用gdal通过一个命令将png瓷砖的投影从epsg:4326转换为epsg:3857的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 20:22