Skip to main content
Solved

wkt: No attributes in inspector and in writer


dollargis
Contributor
Forum|alt.badge.img+1

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?

Best answer by jdh

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
View original
Did this help you find an answer to your question?

4 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • July 11, 2017

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)?


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • July 11, 2017

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

dollargis
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • July 11, 2017
jdh wrote:

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.

 

 


dollargis
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • July 11, 2017
erik_jan wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings