skeenp / qgis3-getwkt Goto Github PK
View Code? Open in Web Editor NEWQGIS plugin that permits you to see the WKT of a geometry
License: GNU General Public License v3.0
QGIS plugin that permits you to see the WKT of a geometry
License: GNU General Public License v3.0
This error came up when trying to install your plugin.
Couldn't load plugin 'QGIS3-getWKT' due to an error when calling its classFactory() method
TypeError: 'QVariant' object is not subscriptable
Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 423, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/Users/mark/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QGIS3-getWKT/__init__.py", line 32, in classFactory
return getwkt3(iface)
File "/Users/mark/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QGIS3-getWKT/getwkt3.py", line 58, in __init__
locale = QSettings().value('locale/userLocale')[0:2]
TypeError: 'QVariant' object is not subscriptable
Python version: 3.9.5 (default, Sep 10 2021, 16:18:19) [Clang 12.0.5 (clang-1205.0.22.11)]
QGIS version: 3.34.3-Prizren Prizren, 47373234acd
Getting the following Python Error when I run the plugin to get a polygon's WKT. Running QGIS 3.16.2 and Python 3.7
An error has occurred while executing Python code:
TypeError: QgsGeometry.asWkt(): argument 1 has unexpected type 'str'
Traceback (most recent call last):
File "C:/Users/rwcar/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGIS3-getWKT\getwkt3.py", line 212, in run_wkt
self.run('wkt')
File "C:/Users/rwcar/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGIS3-getWKT\getwkt3.py", line 287, in run
wkt = geom.asWkt(dp_count) if dp_count else geom.asWkt()
TypeError: QgsGeometry.asWkt(): argument 1 has unexpected type 'str'Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS version: 3.16.2-Hannover Hannover, f1660f9da5Python Path:
C:/PROGRA1/QGIS31.16/apps/qgis/./python
C:/Users/rwcar/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/rwcar/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA1/QGIS31.16/apps/qgis/./python/plugins
C:\PROGRA1\QGIS31.16\apps\Python37
C:\PROGRA1\QGIS31.16\apps\Python37\Scripts
C:\Program Files\QGIS 3.16\bin\python37.zip
C:\PROGRA1\QGIS31.16\apps\Python37\DLLs
C:\PROGRA1\QGIS31.16\apps\Python37\lib
C:\Program Files\QGIS 3.16\bin
C:\PROGRA1\QGIS31.16\apps\Python37\lib\site-packages
C:\PROGRA1\QGIS31.16\apps\Python37\lib\site-packages\win32
C:\PROGRA1\QGIS31.16\apps\Python37\lib\site-packages\win32\lib
C:\PROGRA1\QGIS31.16\apps\Python37\lib\site-packages\Pythonwin
C:/Users/rwcar/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\rwcar\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\kmltools\libs
.
C:\Users\rwcar\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs
C:/Users/rwcar/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vrtbuilderplugin
C:\Users\rwcar\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vrtbuilderplugin\vrtbuilder
C:/Users/rwcar/Desktop
Simply copying a feature copies also its WKT representation.
What does the plugin add to it?
Thanks.
When getting the WKT for polgyon with z values, the format does not following the standard (see section 7.2.3): there should be a space between "polygon" and "z".
E.g. when getting the WKT for the following GML layer:
<ogr:FeatureCollection
gml:id="aFeatureCollection"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml/3.2">
<ogr:featureMember>
<ogr:export gml:id="id.1.geom">
<gml:boundedBy>
<gml:Envelope srsDimension="3" srsName="http://www.opengis.net/def/crs/EPSG/0/7416">
<gml:lowerCorner>722120.48 6178866.39 24.28</gml:lowerCorner>
<gml:upperCorner>722184.83 6178905.66 25.01</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<ogr:geometryProperty>
<gml:Polygon srsName="http://www.opengis.net/def/crs/EPSG/0/7416" gml:id="id.1.geom">
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">722178.52 6178866.39 24.61 722184.83 6178880.97 24.61 722137.52 6178901.05 24.7 722135.5 6178901.91 25.01 722126.66 6178905.66 24.61 722120.48 6178891.19 24.61 722126.3 6178888.7 24.28 722178.52 6178866.39 24.61</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</ogr:geometryProperty>
</ogr:export>
</ogr:featureMember>
</ogr:FeatureCollection>
The WKT retrieved with the plugin is
PolygonZ ((722178.52000000001862645 6178866.38999999966472387 24.60999999999999943, 722184.82999999995809048 6178880.96999999973922968 24.60999999999999943, 722137.52000000001862645 6178901.04999999981373549 24.69999999999999929, 722135.5 6178901.91000000014901161 25.01000000000000156, 722126.66000000003259629 6178905.66000000014901161 24.60999999999999943, 722120.47999999998137355 6178891.19000000040978193 24.60999999999999943, 722126.30000000004656613 6178888.70000000018626451 24.28000000000000114, 722178.52000000001862645 6178866.38999999966472387 24.60999999999999943))
It should start with Polygon Z
, not PolygonZ
.
There is an additional issue: the plugin also returns too many decimals, these are not specified in the GML. But that may be a QGIS issue?
When using ogrinfo:
ogrinfo export.gml -wkt_format WKT2 -al -q
the result is
Layer name: export
OGRFeature(export):0
POLYGON Z ((722178.52 6178866.39 24.61,722184.83 6178880.97 24.61,722137.52 6178901.05 24.7,722135.5 6178901.91 25.01,722126.66 6178905.66 24.61,722120.48 6178891.19 24.61,722126.3 6178888.7 24.28,722178.52 6178866.39 24.61))
And when using ogr2ogr:
ogr2ogr -f CSV export.csv export.gml -lco GEOMETRY=AS_WKT
the result in the CSV file is also
POLYGON Z ((722178.52 6178866.39 24.61,722184.83 6178880.97 24.61,722137.52 6178901.05 24.7,722135.5 6178901.91 25.01,722126.66 6178905.66 24.61,722120.48 6178891.19 24.61,722126.3 6178888.7 24.28,722178.52 6178866.39 24.61))
So ogr writes the WKT according to the standard, including a space between polygon and z.
IBM does it according to the standard too, see https://www.ibm.com/support/knowledgecenter/SSHRBY/com.ibm.swg.im.dashdb.spatial.doc/doc/rsbp4120.html?view=embed
Hi,
The plugin seem to not works with QGIS 3.8.
The text area display :
ERROR: Layer selected is not vector
When pushing the WKT-button 2 problems occur.
Problem 1: everything is a multipolygon, even single polygons
Problem 2: although not visible in the windows, when copying the data, the attribute table data is included in the copy. This can become a problem when you paste it in an other application.
Mac OS 10.14.6
QGIS 3.10
GetWKT 1.3
Thanks for writing this excellent plugin. It is useful for me because I have the default WKT copy option turned off. I can use this plugin without having to turn it on.
The issue that I am having is that once I have a WKT window open and then click a different feature and then click the plugin buttons the pop-up window will be buried under other windows and will not pop up to the front.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.