Clear Filters
Clear Filters

How to find the Lat/Lon of the ends of a geolineshape?

7 views (last 30 days)
When I read the shape data of a table obtained using readgeotable function using T.Shape, it returns:
ans =
geolineshape with properties:
NumParts: 1
Geometry: "line"
CoordinateSystemType: "geographic"
GeographicCRS: [1×1 geocrs]
How can I find the Latitude and Longitude data?
  3 Comments
KSSV
KSSV on 2 Jun 2022
This is a new function, introduced in 2021b. It seems the functions has layers to specify. If you specify the layers, you may get coordinates.
T = readgeotable("sample_tracks.gpx",Layer="track_points");
Pedro Torres
Pedro Torres on 2 Jun 2022
It is a .gdb file. Some layers are points and others a lines. The Points I can use the .Latitude and .Longitude properties to access the coordinates, however Lines do not have such properties.
clc,clear
filenameBDGD = "CELPA_371_2019-12-31_M10_20200903-1416.gdb";
T = readgeotable(filenameBDGD,Layer="SSDAT");
>> T(1:5,:)
ans =
5×21 table
Shape COD_ID PN_CON_1 PN_CON_2 CONJ DIST PAC_1 PAC_2 FAS_CON TIP_CND POS ODI_FAS TI_FAS ODI_NEU TI_NEU COMP DESCR SITCONTFAS SITCONTNEU ARE_LOC Shape_Length
____________ ________ _________ _________ _____ ____ _________ _________ _______ _______ ____ _______ ______ _______ ______ ______ __________________________ __________ __________ _______ ____________
geolineshape "109741" "A111989" "A111988" 15898 371 "A111212" "A111213" "ABC" "AT38" "PD" "40086" "58" "00" "00" 368.32 "PARADA DO BENTO / PORTEL" "AT1" "0" "NU" 0.0031884
geolineshape "109740" "A111988" "A111987" 15898 371 "A111213" "A111214" "ABC" "AT38" "PD" "40086" "58" "00" "00" 362.19 "PARADA DO BENTO / PORTEL" "AT1" "0" "NU" 0.0031354
geolineshape "109739" "A111987" "A111986" 15898 371 "A111214" "A111215" "ABC" "AT38" "PD" "40086" "58" "00" "00" 358.5 "PARADA DO BENTO / PORTEL" "AT1" "0" "NU" 0.0031034
geolineshape "109738" "A111986" "A111985" 15898 371 "A111215" "A111216" "ABC" "AT38" "PD" "40086" "58" "00" "00" 377.61 "PARADA DO BENTO / PORTEL" "AT1" "0" "NU" 0.0032688
geolineshape "109737" "A111985" "A111984" 15898 371 "A111216" "A111217" "ABC" "AT38" "PD" "40086" "58" "00" "00" 388.28 "PARADA DO BENTO / PORTEL" "AT1" "0" "NU" 0.0033612
>> T.Shape(1)
ans =
geolineshape with properties:
NumParts: 1
Geometry: "line"
CoordinateSystemType: "geographic"
GeographicCRS: [1×1 geocrs]

Sign in to comment.

Answers (1)

Siraj
Siraj on 7 Sep 2023
Edited: Siraj on 7 Sep 2023
Hi! It is my understanding that you want to access the latitude and longitude of a shape stored in the "geolineshape" object.
You read the geographical data from the file "CELPA_371_2019-12-31_M10_20200903-1416.gdb" using the "readgeotable" function. This function will create a geospatial table that includes the "geolineshape" objects in its first column.
However, it's important to note that in your case the "geolineshape" object represents a line geometry, and the latitude and longitude properties do not exist for non-point geometries.
Therefore, a possible workaround to access the coordinate data of the line is to convert the geospatial table to a regular table using the "geotable2table" function.
Refer to the code below for better understanding.
T = readgeotable(filenameBDGD);
T = geotable2table(GT,["Latitude","Longitude"]);
This will create Latitude and Longitude table columns.
You can refer to the following link for detailed information about the "geotable2table" function:
Please note that without access to the specific data file mentioned, I am unable to personally verify the correctness of the solution. However, I hope that the information and the "geotable2table" function will be helpful.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!