geotable2table
R2026bConvert geospatial table to table
Description
Examples
Convert a geospatial table to a table, then write the data to an Excel® spreadsheet file.
Import a shapefile containing the coordinates of world cities as a geospatial table.
GT = readgeotable("worldcities.shp");Find the coordinate reference system type. The coordinate reference system type helps you determine appropriate variable names for the table.
GT.Shape.CoordinateSystemType
ans = "geographic"
Convert the geospatial table to a table. Replace the Shape variable with two variables containing coordinates by specifying the second argument as a two-element vector. The coordinate system is geographic, so use the variable names "Latitude" and "Longitude".
T = geotable2table(GT,["Latitude" "Longitude"]);
Write the table to an Excel spreadsheet file.
writetable(T,"worldcities.xlsx")Import a shapefile containing a road network in Boston, MA, as a geospatial table. The Shape variable of the geospatial table contains maplineshape objects.
GT = readgeotable("boston_roads.shp");
class(GT.Shape)ans = 'maplineshape'
Convert the geospatial table to a table. The geotable2table function replaces the objects in the Shape variable with WKT string representations of geometry.
T = geotable2table(GT);
View the WKT string for the road called C STREET.
wkt = T.Shape(T.STREETNAME == "C STREET")wkt = "LINESTRING (237527.171875 899661.1875,237343.875 899443.0625)"
Input Arguments
Geospatial table. A geospatial table is a table or timetable object with a
Shape variable that contains geopointshape,
geolineshape,
geopolyshape,
mappointshape,
maplineshape, or
mappolyshape
objects. The Shape variable must be the first variable.
For more information about geospatial tables, see Create Geospatial Tables.
Data Types: table
Table variable names used to replace the Shape variable of the
geospatial table, specified as a string scalar, a two-element vector of strings, or a
three-element vector of strings.
String scalar — Replaces the shape objects in the
Shapevariable with WKT string representations of geometry. For example,"WKTStrings". Unlike shape objects, WKT string representations of geometry do not contain information about the coordinate reference system. This argument supports WKT string representations of 3-D points. (since R2026b)Two-element vector of strings — Replaces the
Shapevariable with two table variables that contain latitude-longitude or xy-coordinates. For example,["Latitude","Longitude"].Three-element vector of strings — Replaces the
Shapevariable with three table variables containing latitude-longitude-height or xyz-coordinates. For example,["Latitude","Longitude","Height"]. (since R2026b)
The geotable2table function does not project or unproject
coordinates. For more information about projecting or unprojecting coordinates, see
projfwd or projinv.
Data Types: string
Output Arguments
Output table, returned as a table or timetable
object. The format of the output table depends on the format of the
varnames input.
When
varnamesis a string scalar, the output table contains WKT string representations of 2-D or 3-D geometry.When
varnamesis a two-element string vector, the output table contains latitude-longitude or xy-coordinates. If a table row represents an individual point, then the coordinates are returned as numeric scalars. Otherwise, the coordinates are returned as cell arrays of numeric vectors.When
varnamesis a three-element string vector, the output table contains latitude-longitude-height or xyz-coordinates. If a table row represents an individual point, then the coordinates are returned as numeric scalars. Otherwise, the coordinates are returned as cell arrays of numeric vectors. (since R2026b)
Version History
Introduced in R2021bConvert geospatial tables containing 3-D point data to tables by specifying
varnames as one of these options:
The name of a table variable, when you want the output table to contain WKT string representations of 3-D points.
The names of three table variables, when you want the output table to contain latitude-longitude-height coordinates or xyz-coordinates.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)