[Qgis-developer] [Qgis-user] Using/visualizing 3D data (Z values)
Etienne Tourigny
etourigny.dev at gmail.com
Wed Sep 26 04:42:02 PDT 2012
Thanks for the info.
I was able to use shapely pretty easily, by passing the wkb from qgis
to shapely via shapely.wkb.loads(wkb)
This removed the need for actual file parsing, which qgis seem to do
well (apart from the z-level values, which it reads but does not
report),
here is the relevant python code:
from shapely.wkb import loads
feat = QgsFeature()
provider = layer.dataProvider()
provider.select(provider.attributeIndexes())
if provider.nextFeature(feat):
lines = loads(feat.geometry().asWkb())
if len(lines) == 1:
coords = lines[0].coords
(x,y,z[i]) = coords[i]
cheers
Etienne
On Wed, Sep 26, 2012 at 3:26 AM, gene <martin.laloux at gmail.com> wrote:
> Hello, In Python:
> - For shapefiles, , I use the pyshp ( pyshp: Python Shapefile Library/
> <http://code.google.com/p/pyshp/> ) module of Joel Lawhead to read or write
> 3D shapefiles:
> (see CreateElevationValues : How to work with elevation (a.k.a. z) values.
> <http://code.google.com/p/pyshp/wiki/CreateElevationValues>
>>>>import shapefile
>>>>r = shapefile.Reader("MyPolyZ")
>>>>r.shapes()[0].points
> [[-89.0, 33.0], [-90.0, 31.0], [-91.0, 30.0]]
>>>>r.shapes()[0].z
> [12, 11, 12]
>
> I use it without problem in the Python console to process the results with
> Shapely, Numpy or Grass.script
>
> - For kml files, it is relatively easy to parse files with standard modules
> like Elementtree, or with more specialized modules (
> http://pypi.python.org/pypi?%3Aaction=search&term=kml&submit=search
> <http://pypi.python.org/pypi?%3Aaction=search&term=kml&submit=search> )
>
> I also use this approach in the Python console
>
>
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/Re-Qgis-user-Using-visualizing-3D-data-Z-values-tp5004272p5004487.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the Qgis-developer
mailing list