Problem using shapefile in matlab
8 次查看(过去 30 天)
显示 更早的评论
I'm working with the free m_map toolbox for the first time. I would like to overlay an image with a vector (shape file) "clip" by doing this:
M=m_shaperead('clip');
clf;
for k=1:length(M.ncst),
line((M.ncst{k}(:,1)),M.ncst{k}(:,2));
end;
I got the following message:
Subscript indices must either be real positive integers or logicals.
Error in carta4 (line 5)
line((M.ncst{k}(:,1)),M.ncst{k}(:,2));
these are simple positive lat/lon values, for example: 13.2130 17.2304, even when transforming these values to integer ( 13210 17230) the error persists, could someone explain me which is the easiest way of reading shapefiles with the m_map toolbox?
Thank you very much
0 个评论
回答(2 个)
Kelly Kearney
2014-6-12
I don't see anything wrong with that code, and substituting another shapefile works fine. Can you show us the details of M?
Are you sure you copied your code correctly? The error isn't in the shapefile read, but rather in the plotting line. It seems to indicate that k isn't an integer, but I'm not sure how that could occur.
On a side note, you seem to have an extra set of parentheses in there (around M.ncst{k}(:,1)), but again I don't think that would cause any issues.
0 个评论
Jose Luis
2014-6-12
1 个评论
Kelly Kearney
2014-6-12
Okay, that all looks fine. What is the value of k when the code throws the error?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!