问题
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