2

I have a shapefile with polygon type geometry. I want WKB format of the geometry values. Is there any such tool in QGIS so that without using gdal/ogr I can do this?

  • 2
    How you want to use it? As you can´t store it within the shapefile (beside already having it as binary in the .shp) you need another dataformat. A true WKB is also binary and would be safed as a raw byte datastream. The other option is a hexadecimal text-representation. There is a tool called "Plain geometry editor" that shows you the hex-WKB for the selected feature. If this is not what you need you only have the options using some python code or SpatiaLite. Both is built in QGIS but not a ready tool for an export. – Matte Feb 20 '17 at 17:04
  • I want to save it within the shapefile. May be in an added column. Binary or hexadecimal both format is fine. I can build the python or C code using GDAL/OGR. But I want to that is there any ready tool? – LSG Feb 20 '17 at 20:27
  • 1
    Within the Shapefile is not possible as the shapefile does not have the datatype blob (binary) and the text-type only has 254 characters max. And the wkb expression is way to long to fit into this. – Matte Feb 20 '17 at 20:30
  • Yes, when I tried to do the C code using GDAL, I also found this problem of 254 character-limit. But we have 'ExportToWKB' function for python, C, C++. Then, is this function for exporting the geometry to WKB formats and writing it to other file, not to shapefile? – LSG Feb 21 '17 at 7:58
  • 1
    As you are using postgres try a char_length(your_wkb_column). All that are longer than 254 are broken when you export them this way. You will not be able to recreate a geometry out of it. – Matte Feb 21 '17 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.