如何使用GDAL从tiff和4个角的经度和纬度创建geotiff [英] How to use GDAL to create geotiff from tiff and 4 corners latitude and longitude

查看:695
本文介绍了如何使用GDAL从tiff和4个角的经度和纬度创建geotiff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张没有TIFF格式地理数据的图像(地图).
我需要从图像中获取GeoTIFF文件.我在地图的每个角都有经度和纬度.如何在Google空间参考中将地理数据添加到图像中以获取Geotiff?我知道GDAL可以帮助我.谁能帮我建立命令

I have an image (map) without geo data in TIFF format.
I need to get GeoTIFF file from my image. I have latitude and longitude for each corner of my map. How can I add my geo data to my image in Google spatial refence to get geotiff? I know that GDAL can help me with that. Can anyone help me build a command

推荐答案

您的回答正确,但请允许我扩展.没错,您需要使用gdal_translate工具设置地面控制点(gcps)以对图像进行地理配准.但是命令行参数应该像这样:

You have the right idea in your answer but allow me to expand. You are correct, you'll need to use the gdal_translate tool to set ground control points (gcps) to georeference the image. But the command line argument should go like so:

gdal_translate -of GTiff -a_srs EPSG:4326 -gcp [pixel line easting northing] -gcp [pixel line easting northing] -gcp [pixel line easting northing] sourcefile outpulfile

您不必一定要输出到VRT,如果您想对文件执行其他算法,向文件中添加更多数据集并最终将其输出为KML,则可以使用VRT,其中包括您可以继续阅读的内容.此处( http://www.gdal.org/gdal_vrttut.html ).但是为此目的,将-of设置为GTiff是理想的.

You don't necessarily have to output to a VRT, VRT's are useful if you want to perform other algorithms to your file, add more datasets to it, eventually output it as a KML - amongst others which you can read up on here ( http://www.gdal.org/gdal_vrttut.html ). But for this purpose setting -of to GTiff is ideal.

-a_srs EPSG:4326

接下来,在正确的空间参考中,应该将其参考到Google地球使用的坐标系WGS84,但是我们使用EPSG:4326进行指定-这只是地理信息委员会已同意识别坐标的编码方案全世界的系统( http://www.epsg.org/).

Next, in the spatial reference you are correct it should be referenced to WGS84 the coordinate system used by google earth, however we specify it using EPSG:4326 - this is just the coding scheme the Geomatics Committee has agreed on to identify coordinate systems worldwide ( http://www.epsg.org/ ).

-gcp [pixel line easting northing]

地面控制点可能是命令行参数中最棘手的部分.前两个数字代表实际图像的像素和线坐标,例如,图像左上角的(0,0).应遵循的第二组数字是应参考图像的相应纬度/经度坐标.现在,您只需要这些-gcps中的3个,因为如果您的图像是正方形/矩形,将确定第4个.

The ground control points, are probably the most trickiest part of the command line argument. The first 2 numbers represent the pixel and line coordinate of your actual image, for instance (0,0) for the top left most corner of your image. The second set of numbers that should follow is the corresponding lat/long coordinates that your image should be referenced to. Now, you'll only need 3 of these -gcps because the 4th one will be determined if your image is a square/rectangle.

sourcefile outputfile

这部分应该是不言自明的,只要记住它们都是* .tif文件即可.

This part should be self-explanatory, just remember they are both *.tif files.

现在,如果需要做最后一件事来完成任务.您必须将图像实际投影到坐标系中才能对齐.使用gdalwarp命令( http://www.gdal.org/gdalwarp.html ).

Now, there if one last thing you will need to do to complete your task. You will have to actually project the image to the coordinate system for it to be aligned. This is down using the gdalwarp command ( http://www.gdal.org/gdalwarp.html ).

gdalwarp -t_srs EPSG:4326 sourcefile outputfile

如果应该将-of(输出文件格式)指定为GeoTiff以外的其他格式,则必须指定-of(输出文件格式),但是默认格式为GTiff,因此您无需指定它.

You'll have to specify an -of (output fileformat) if it was supposed to something other than a GeoTiff - but the default format is GTiff so you don't need to specify it.

这篇关于如何使用GDAL从tiff和4个角的经度和纬度创建geotiff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆