马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 newer 于 2021-1-13 21:11 编辑
world file 是由地理信息系统(GIS)用于地理参考栅格地图图像的六行纯文本Sidecar文件。 文件规范由Esri [1] [2]引入,由仿射变换的六个系数组成,这些系数描述了地图上栅格的位置,比例和旋转.
- /// <summary>
- /// Create tfw - world file.
- /// </summary>
- /// <param name="filename">tif image full filename</param>
- private void CreateWorldFile(string filename)
- {
- using (var bitmapImage = new Bitmap(filename))
- {
- PropertyItem[] imageProps = bitmapImage.PropertyItems;
- var modelscale = imageProps.First(a => a.Id == GEOTIFF_MODELPIXELSCALETAG);
- var tiepoint = imageProps.First(a => a.Id == GEOTIFF_MODELTIEPOINTTAG);
- double x = BitConverter.ToDouble(tiepoint.Value, 0 + 24);
- double y = BitConverter.ToDouble(tiepoint.Value, 0 + 32);
- double xscale = BitConverter.ToDouble(modelscale.Value, 0);
- double yscale = BitConverter.ToDouble(modelscale.Value, 0 + 8);
- string tfwFileName = Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".tfw";
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(tfwFileName))
- {
- file.WriteLine(xscale);
- file.WriteLine("0.0");
- file.WriteLine("0.0");
- file.WriteLine(yscale);
- file.WriteLine(x);
- file.WriteLine(y);
- }
- }
- }
- private readonly int GEOTIFF_MODELPIXELSCALETAG = 33550;
- private readonly int GEOTIFF_MODELTIEPOINTTAG = 33922;
|