用上一篇里面 C#不用ArcEngine,生成Shp文件(二) 读取到的.shp文件信息,生成一个一样的.shp文件。测试数据下载地址为:http://download.youkuaiyun.com/detail/gis0911178/9650967
读取到的信息如下:
--------------------------------------------------------------------------------
文件长度:110
Xmin:120.062485706624
Ymin:27.752624080108
Xmax:120.102341678472
Ymax:27.7716597681547
文件记录号为:1
坐标长度为:56
几何类型:5
Box[0]:120.062485706624
Box[1]:27.752624080108
Box[2]:120.102341678472
Box[3]:27.7716597681547
子面个数:1
坐标点个数:4
每个子环在坐标点内的起始位置:
parts[0]:0
Points数组:
Points[0]:120.062485706624 27.7618444915056
Points[1]:120.102341678472 27.7716597681547
Points[2]:120.081521394671 27.752624080108
Points[3]:120.062485706624 27.7618444915056
------------------------------------------------------------------------------------------------------
按照以上信息,生成.shp文件的代码(代码下载地址http://download.youkuaiyun.com/detail/gis0911178/9598945):
string path = @shpFullNameDir;
if (!File.Exists(path))
{
using (FileStream fs = new FileStream(path, FileMode.Create,FileAccess.Write))
{
//byte[] data = new UTF8Encoding().GetBytes("abcdefg");
//fs.Write(data, 0, data.Length);
//写入FileCode
int fileCode = ChangeByteOrder(9994);
byte[] fc = System.BitConverter.GetBytes(fileCode);
fs.Seek(0,SeekOrigin.Begin);
fs.Write(fc,0,fc.Length);
//写入文件长度
int fileLength = ChangeByteOrder(110);
byte[] fl = System.BitConverter.GetBytes(fileLength);
fs.Seek(24, SeekOrigin.Begin);
fs.Write(fl, 0, fl.Length);
//写入版本号
int versionNumber = 1000;
byte[] vn = System.BitConverter.GetBytes(versionNumber);
fs.Seek(28, SeekOrigin.Begin);

这篇博客介绍了如何使用C#不依赖ArcEngine来生成.shp格式文件。通过读取已有.shp文件信息,博主提供了生成相同.shp文件的代码示例,包括写入文件头信息、坐标数据等关键步骤。代码可供下载参考,但.dbf文件的生成仍在学习中。
最低0.47元/天 解锁文章
4003

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



