使用投影将 Lon、Lat 坐标写入 Matlab 中的 shapefile
我有一个经度和纬度点列表,用于在地图上绘制随时间移动的对象;它有点像一条稍微弯曲的线。我正在使用 Matlab 生成这些点,并希望将它们导出到折线 shapefile 中以在 ArcGIS 中加载。
从 mathworks 网站查看此示例后,我能够创建一个线 geostruct 对象:
[Tracks(1:length(myLon)-1).Geometry] = deal('Line');
trackType = 'gc';
[Tracks.Type] = deal(trackType);
for i = 1:(length(myLon)-1)
[Tracks(i).Lon Tracks(i).Lat] = track2(trackType, myLon(i, 1), myLat(i, 1), myLon(i+1, 1), myLat(i+1, 1));
end
shapewrite(Tracks, 'path_line');
这通常工作正常,但 Geostruct 不包含任何类型的投影,尽管文档声称 Mapstruct 包含。不幸的是,我没有看到任何有关如何创建 Mapstruct 的示例或函数。有谁知道我会怎么做?
另外,我尝试使用 mathworks 示例创建一个点地理结构而不是一条线,但它不会生成 .dbf 文件,仅生成 .shp 和 .shx 文件。对此有什么解释吗?感谢您的任何建议!
I have a list of longitude and latitude points that plot an object moving over time on a map; it sort of forms a line that curves around a bit. I am using Matlab to generate these points and would like to export them into a polyline shapefile to load in ArcGIS.
After looking at this example from the mathworks website, I am able to create a line geostruct object:
[Tracks(1:length(myLon)-1).Geometry] = deal('Line');
trackType = 'gc';
[Tracks.Type] = deal(trackType);
for i = 1:(length(myLon)-1)
[Tracks(i).Lon Tracks(i).Lat] = track2(trackType, myLon(i, 1), myLat(i, 1), myLon(i+1, 1), myLat(i+1, 1));
end
shapewrite(Tracks, 'path_line');
This generally works fine but Geostruct does not contain any type of projection, although the documentation claims Mapstruct does. Unfortunately I don't see any examples or functions on how to create a Mapstruct. Does anyone know how I would go about doing that?
Also, I tried to create a Point Geostruct instead of a line using the mathworks example, but it doesn't generate the .dbf file, only .shp and .shx files. Is there any explanation for this? Thanks for any suggestions!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用 arcgis 中的“定义投影”工具来定义导入的折线的投影。这应该创建一个相应的 .prj 文件。
you would need to use the "define projection" tool in arcgis to define the projection of your imported polyline. This should create a corresponding .prj file.
除了要创建的 .dbf 文件的经纬度和几何值之外,地理结构中还必须至少有一个“属性”
you have to have at least one 'attribute' in the geostruct other than the lat and lon and geometry values for the .dbf file to be created
我知道为时已晚,但是...使用 Matlab 2020,您需要使用下一个过程创建 .prj 文件(在本示例中我使用点):
在本示例中,您将获得 *.shp、*.prj 文件。您可以在 QGIS 中使用的 dbf、*.shx 和 *.prj 文件。
我的答案基于此另一个
例子是使用折线和表格来创建带有投影的形状文件。此代码只能在 Matlab 2021b 上运行:
I know that is too late, but... Using Matlab 2020, you need to create the .prj file using the next procedure (in this example I use points):
With this example, you will get the *.shp, *.dbf, *.shx and *.prj files that you can use in QGIS.
My answer is based on this post
Another example is using a polyline and table to create a shapefile with its projection. This code only would run with Matlab 2021b: