2

I have a .csv file with hundreds of rows pulled out via PostGIS.

The geospatial information is in "the_geom" field which seems to be in WKB-format.

How can I convert this to shapefile using simple free tools?

4
  • 2
    did u try QGIS...?
    – Ade'l
    May 27, 2016 at 11:18
  • 1
    Any chance of a sample for download?
    – Spacedman
    May 27, 2016 at 11:19
  • 3
    I'm slightly worried about WKB in a CSV file, because CSV should be text, and WKB is Binary, so could have stray commas and quotemarks and zero-characters and line-ends that could mess up any text-parser. However if its WKT, the Text format, in your data then its trivial.
    – Spacedman
    May 27, 2016 at 11:44
  • @Spacedman makes a good point. OP, can you copy/paste a couple rows of the csv data into your question? Make sure to click the edit link below your question rather than adding them as a comment :)
    – elrobis
    May 27, 2016 at 14:59

2 Answers 2

5

You can skip the CSV step and just go straight to shapefile using pgsql2shp, which is installed a part of PostGIS.

You could also use ogr2ogr.

2

As a free on-line solution for the conversion of CSV with WKB data you can use MyGeodata Converter. Just name your column with WKB data as "wkb" - like this example:

id,name,wkb
1,Point 1,010100000000000000000048400000000000003340
2,Point 2,010100000000000000000046400000000000002E40

The WKB data will be automatically recognized based on the occurence of "wkb" string in a CSV column. Any geometry type is supported - point, linestring, polygon, ... If you have WKT, use name "wkt" of the column... Hope it helps - for me it works. It is based on GDAL/OGR VRT driver. Most of GIS/CAD formats are supported - both input and output data.

1
  • That's a hexadecimal string representation of WKB. I reckon that's probably what the OP has, rather than raw WKB bytes.
    – Spacedman
    May 27, 2016 at 15:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.