How to read the properties information of kml data

조회 수: 5 (최근 30일)
주영
주영 2024년 9월 11일
답변: Shivam 2024년 9월 11일
I got geographical information using 'readgeotable',
but I want to bring properties information of actual kml data.
In more detail, I would like to bring each field within the kml data and the property information corresponding to the field.
Is there any way?

답변 (1개)

Shivam
Shivam 2024년 9월 11일
Using readgeotable for the kml data, gives a nxm table where n corresponds to no. of 'Placemark' inside the kml document. In the below mentioned workaround, I have used a sample data with 2 Placemarks, plotted it using wmmarker function and and illustrated how to extract individual field values.
>> T = readgeotable('path/to/kmlfile.kml');
>> wmmarker(T); % Plot the source locations on a web map.
>> T
T =
2×3 table
Shape Name Description
_______________________ ____________ ______________________________
(37.4223°N, 122.0822°W) "Location 1" "This is the first location."
(37.4220°N, 122.0850°W) "Location 2" "This is the second location."
>> fieldNames = T.Properties.VariableNames; % Get the keys (field names) of the table
fieldNames =
1×3 cell array
{'Shape'} {'Name'} {'Description'}
Here's how you can extract column corresponding to 'Shape' fieldName and also extract value of first row:
% Extract the 'Shape' column
shapeColumn = T.Shape;
% Access the first row of the 'Shape' column
firstShape = T.Shape(1);
Also note that I am providing the sample data in a .txt file because this community platform does not support attaching .kml files directly. You can copy the data from the .txt file into a .kml file on your system to test the workaround.
I hope it helps.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by