How can I create a point shapefile from a csv (or matrix) with lat/long columns?
2 views (last 30 days)
Show older comments
I have a csv file (or I can use a matrix object) within Matlab that I need to convert to a shapefile (points). An example of the first 3 rows of my data is below.
% X Y var1 var2 var3
%463310.925537576 5013978.52568211 5 8 1
%464344.150891795 5013195.54547050 2 4 9
%463782.424931854 5012644.08397560 2 1 8
I want to create the point shp with this data. I've tried this:
%lat long needs to be plotted.
[T.Geometry] = 'Point';
T.x = 'X'; % latitude
T.y = 'Y'; % longitude
T.var1 = 'var1';
T.var2 = 'var2';
T.var3 = 'var3';
T
I've tried this:
%lat long needs to be plotted.
[T(1:1780).Geometry] = deal('Point');
T.x = 'X'; % latitude
T.y = 'Y'; % longitude
T.var1 = 'var1';
T.var2 = 'var2';
T.var3 = 'var3';
T
The problem is that these two methods only work if you delinate each point one at a time. I have a csv with 1780 points...
0 Comments
Answers (1)
Stijn Haenen
on 23 Mar 2020
Im not sure what you want, but maybe this can help:
for i=1:1780
T.(sprintf('var%g',i))=sprintf('var%g',i);
end
This creates a structure with 1780 fields
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!