PostgreSQL/PostGIS data to Matlab - How to display
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have successfully connected to a postgreSQL database from matlab and importad a field that contains geometric data (postgreSQL data type of the field is 'geometry'). Here's my code.
curs = exec(conn, 'select location from gps'); setdbprefs('DataReturnFormat','cellarray'); curs = fetch(curs, 10); AA = curs.Data
this gives the following output: [1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
[1x1 org.postgresql.util.PGobject]
The field 'location' contains point features and the postgreSQL data type is geometry. I want to display the actual values. Please tell me a way to do that.
1 commentaire
Ross
le 13 Jan 2017
Obviously really old post, but the easier way it to use SQL to convert the location into x, y and z coordinates in the query.
SELECT ST_X(location_column_name), ST_Y(location_column_name), ST_Z(location_column_name) FROM table_name
Réponses (1)
Walter Roberson
le 11 Juin 2011
numA = length(AA);
Geometries = cell(numA,1);
for Gidx = 1:numA;
G = AA(Gidx).getGeometry;
NP = G.numPoints;
Points = cell(NP,1);
for PN = 1:NP
P = G.getPoint(PN);
Points{PN} = [P.x, P.y, P.z];
end
Geometries{Gidx} = Points;
end
I am not sure if there needs to be a step to go from PGobject to PGgeometry.
0 commentaires
Voir également
Catégories
En savoir plus sur Database Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!