Solved

wkt: No attributes in inspector and in writer


Badge

I try to read a csv-file, that contains geometries in wkt as well as attributes and want to convert these in a shapefile.

The first two lines look as follows:

WKT,fid,objectid,y,bt_nummer,flaeche_qm,name_stat_,x,shape_area,shape_len

 

MultiPolygon(((4469285.3 5337544.1, 4469292.1 5337435.9, 4469311.4 5337437.0))),1,10,5336470.71,12.4,1297528.91423,Münchener Freiheit,4469371.47,,

(note that I have shortened and cut the vertices)

There are two problems arising:

  1. The inspector doesn't show the attributes at all
  2. The shapefile writer (connected directly) gives only empty - but correctly named - columns in the attribute table

What am I missing?

icon

Best answer by jdh 11 July 2017, 15:56

View original

4 replies

Userlevel 2
Badge +16

A few questions arise:

Did you set the CSV reader to have field names on the first row?

Did you convert (GeometryReplacer) the WKT attribute to a geometry?

Are the Shape attributes exactly the same as the CSV attributes (case sensitive)?

Badge +22

One issue you might find is that if you try and read the csv directly, the multipolygon coordinates are also separated by a comma, and would be become different columns. Putting quotes around it solves that problem.

 

 

Otherwise I don't see a real issue, other than ensuring the encoding is correct.

 

csvwkt.fmwt
Badge

One issue you might find is that if you try and read the csv directly, the multipolygon coordinates are also separated by a comma, and would be become different columns. Putting quotes around it solves that problem.

 

 

Otherwise I don't see a real issue, other than ensuring the encoding is correct.

 

csvwkt.fmwt
@jdh: Thanks for the example code that greatly helped me a big step further. It turned out the missing quotes were causing that error. Now that I have changed my csv-file accordingly, both geometry and attributes get imported.

 

 

However - all attributes get imported as strings, in spite of me providing a csvt-file, indicating the correct data types!

 

 

As far as my research goes, this is a known problem with the ogr 1.x version library. I have imported my files successfully with ogr2ogr v. 2.x, but unfortunately this is not an option in my current project.

 

 

Badge

A few questions arise:

Did you set the CSV reader to have field names on the first row?

Did you convert (GeometryReplacer) the WKT attribute to a geometry?

Are the Shape attributes exactly the same as the CSV attributes (case sensitive)?

@erik_jan_: I thought I had done those first two points correctly, but it turned out the quotes were missing. Re. the shape attributes: I want to create the shape dynamically - and it turns out that there is still a problem with the data types ahead.

 

Reply