PostgreSQL/PostGIS data to Matlab - How to display
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Ross
el 13 de En. de 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
Respuestas (1)
Walter Roberson
el 11 de Jun. de 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 comentarios
Ver también
Categorías
Más información sobre Database Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!