geotable2table
Description
Examples
Convert Geospatial Table to Table
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")
View WKT String Representations of Geometry
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
GT
— Geospatial table
geospatial table
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
varnames
— Table variable names
string scalar | two-element string vector
Table variable names used to replace the Shape
variable of the
geospatial table, specified as a string scalar or two-element string vector.
To replace the shape objects in the
Shape
variable with WKT string representations of geometry, specifyvarnames
as a string scalar, such as"WKTStrings"
. Unlike shape objects, WKT string representations of geometry do not contain information about the coordinate reference system.To replace the
Shape
variable with two table variables containing latitude and longitude coordinates or x- and y-coordinates, specifyvarnames
as a two-element string vector, such as["Latitude" "Longitude"]
.
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
T
— Output table
table
object | timetable
object
Output table, returned as a table
or timetable
object.
When you specify
varnames
as a string scalar, the output table contains WKT string representations of geometry.When you specify
varnames
as a two-element string vector, the output table contains latitude-longitude or x- y 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.
Data Types: table
Version History
Introduced in R2021b
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)