creating a shapefile or geojson file
조회 수: 36 (최근 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!