问题描述:
需要对一批shp文件读取,提取其中部分字段到数据库
解决方法:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OSGeo.GDAL;
using OSGeo.OGR;
namespace learnGDAL
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Gdal.AllRegister();
Ogr.RegisterAll();
OSGeo.GDAL.Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
OSGeo.GDAL.Gdal.SetConfigOption("SHAPE_ENCODING", "CP936");
string shpFilePath = @"E:\GDAL\gdal\learnGDAL\learnGDAL\testdata\110105dp.shp";
OSGeo.OGR.Driver driver = Ogr.GetDriverByName("ESRI Shapefile");
DataSource ds = null;

本文介绍了如何在C#中利用GDAL库读取SHP文件的属性字段,并针对读取过程中可能出现的乱码问题提供了解决策略,包括尝试的解决方法以及最终自定义的解决方案。
最低0.47元/天 解锁文章
2048

被折叠的 条评论
为什么被折叠?



