Tag: gdal

在C#中使用GDAL时出现exception

我开始在我的应用程序中使用gdal_csharp dll并读取geotiff文件。 但它说: The type initializer for ‘OSGeo.GDAL.GdalPINVOKE’ threw an exception. 这是我的代码 string fileName = @”/path to geotiff file”; OSGeo.GDAL.Dataset DS = OSGeo.GDAL.Gdal.Open(fileName, OSGeo.GDAL.Access.GA_ReadOnly); 有人可以帮忙吗? 编辑: 我有这些dll 这是完整的错误消息: 它说无法加载gdal_wrap 。 但是,当我要将dll添加到我的应用程序时,会显示以下消息:

GDAL GDALRATSetValueAsString()如何保存汉字(c#)?

我需要GDAL的帮助。 带有中文符号的字符串值未被正确读取/保存(C#)。 对于SAVING网格值,我们使用: private static extern void GDALRATSetValueAsString(IntPtr handle,int row,int field,[In] [MarshalAs(UnmanagedType.LPStr)] string value); 方法(c#)保存字符串值, 似乎这个方法将字符串保存为ANSI字符串 。 阅读: private static extern IntPtr GDALRATGetValueAsString(IntPtr handle, int row, int field); 在。 示例我的字符串“银行Flamwood C2”有​​通过指针获取值的方法(在GDALRATGetValueAsString方法中使用): var pointer = GDALRATGetValueAsString(GDALRasterAttributeTableH, row, field); a) var b = Marshal.PtrToStringUni(pointer); // value: “㼿汆浡潷摯䌠2” b) var a = Marshal.PtrToStringAnsi(pointer); // value: “??Flamwood C2” c) […]