creating a shapefile or geojson file
35 次查看(过去 30 天)
显示 更早的评论
I have geopoints of a boat track and other vectors like dateTime vector, CourseOverGround(degree),Speed over Ground(in knots) . I am not able to write the shape file . Only geopoints are written. Please help.
2 个评论
回答(1 个)
Siraj
2023-9-18
Hi!
It is my understanding that you have a boat track dataset consisting of geopoints representing the boat's locations at different times, along with other attributes such as timestamp, “CourseOverGround (in degrees)”, and “Speed over Ground (in knots)” and want to store data in a shape file but are facing some issues.
To address this, one alternative approach can be to use the "geopoint" function to create a container object that holds geographic point coordinates and attributes. By utilizing the dot notation, attributes such as “dateTime”, “CourseOverGround”, and “SpeedOverGround” can be dynamically added to the "geopoint" object. Subsequently, the enhanced object can be written to a shapefile using the "shapewrite" function. Refer to the following code for a clearer understanding.
% Define the range for latitudes and longitudes
latRange = [8, 37]; % Latitude range
lonRange = [68, 97]; % Longitude range f
% Generate vectors of latitudes and longitudes
latitudes = linspace(latRange(1), latRange(2), 10);
longitudes = linspace(lonRange(1), lonRange(2), 10);
% Generating CourseOverGround
numPoints = 10; % Number of points, same as the length of latitudes and longitudes
minCOG = 0; % Minimum value for CourseOverGround
maxCOG = 360; % Maximum value for CourseOverGround
% Generate random values for CourseOverGround
CourseOverGround = rand(1, numPoints) * (maxCOG - minCOG) + minCOG;
% Generating SpeedOverGround
numPoints = 10; % Number of points, same as the length of latitudes and longitudes
minSOG = 0; % Minimum value for SpeedOverGround
maxSOG = 10; % Maximum value for SpeedOverGround
% Generate random values for SpeedOverGround
SpeedOverGround = rand(1, numPoints) * (maxSOG - minSOG) + minSOG;
shape = geopoint(latitudes, longitudes);
shape.CourseOverGround = CourseOverGround;
shape.SpeedOverGround = SpeedOverGround;
dbfspec = makedbfspec(shape);
shapewrite(shape, "test.shp", 'DbfSpec',dbfspec)
S = shaperead("test.shp");
T = struct2table(S)
Refer to the following links for more information about the "geopoint" and "shapewrite" functions.
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!