www.gusucode.com > map 案例源码 matlab代码程序 > map/RetrievePointDataFromShapeFileAndWriteDataToKMLFileExample.m

    %% Retrieve Point Data from Shape File and Write Data to KML File 
% 
%%
% Read the locations of major cities from a shape file into a geostruct.
latlim = [ 30; 75];
lonlim = [-25; 45];
cities = shaperead('worldcities.shp','UseGeoCoords', true, ...
       'BoundingBox', [lonlim, latlim]);
%%
% Get the latitudes, longitudes, and names of the cities from the
% geostruct.
lat = [cities.Lat];
lon = [cities.Lon];
name = {cities.Name};
%%
% Define the name of the KML file you want to create.
filename = 'European_Cities.kml';
%%
% Write the geographic data to the file, specifying the names of the cities
% and the size of the icon.
kmlwritepoint(filename, lat, lon, 'Name', name, 'IconScale', 2);