How to read the properties information of kml data
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
Shivam
el 11 de Sept. de 2024
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.
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!