1

Given the following format options:

all.json, all.xml, all.xls, all.csv, all.kml, all.gjson

Which one is the best/easiest to convert the data into standard ERSI Shapefiles which contains the coordinates as well as the data attributes for each feature?

I tried importing KML and JSON via QGIS but the data attributes are squashed into a single column (see screenshot). Conversion via ogr2ogr was successful neither - it spits out a DBF file only. Conversion via csv2shp did not work at all - I could not figure out how to run the command.

QGIS Attributes Table


I came up with the following all.vrt as suggested by afalciano.

<OGRVRTDataSource>
    <OGRVRTLayer name="all">
        <SrcDataSource>all.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="laengengrad" y="breitengrad"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

All features are printed to the console running: ogrinfo -ro -al all.vrt

3
  • It sounds like you are saying that four of the six are not working (well) for you and implied that you have not tried the other two. I think you should decide which is your preferred format and focus your Question on how to get that converted satisfactorily. If that works then getting the others working becomes more or less moot, or can be researched/asked separately. Dealing with six workflows in one Question is not going to align well with our Q&A format. Whereas one Question per workflow will likely yield a clean and valuable Q&A about each.
    – PolyGeo
    Jan 30 '14 at 10:45
  • The point is that I have no idea which source format and conversion tool allows to separate the data columns as desired for the ShapeFiles. That is why I do not decide on a format to work with.
    – JJD
    Jan 30 '14 at 10:48
  • CSV format is more human readable than others and QGIS treats it very fine. IMHO the choice is very simple here. Jan 30 '14 at 10:54
3

You can easily add all.csv using semicolon as custom delimiter, laengengrad field as X and breitengrad one as Y. Finally save as SHP and you're done.

enter image description here

Sorry for the Italian ui.

6
  • Awesome! I tried this before but missed to change the column separator to semicolon. Sometimes it is that easy! Can you tell how to the same via ogr2ogr?
    – JJD
    Jan 30 '14 at 10:54
  • 2
    You should use the OGR VRT format in order to manage delimiters and geometry fields. I suggest to read this doc. Hope this helps. Jan 30 '14 at 10:58
  • 2
    Odd thing about the data is that Northing and Easting data has decimal comma and thousand points, while Laengengrad and Breitengrad has decimal point.
    – AndreJ
    Jan 30 '14 at 11:01
  • @afalciano Does the .vrt file help me with the conversion? Still ogr2ogr -f "ESRI Shapefile" all.shp all.csv outputs the .dbf only.
    – JJD
    Jan 30 '14 at 11:30
  • 1
    It should be ogr2ogr all.shp all.vrt using the all.vrt you added in your question. OGR recognizes the separator automatically (if possible), so you don't need to declare it. Jan 30 '14 at 11:56
0

Ansuming that XML stands for GML, that's the way I would go. I regularly use QGis to convert from ShapeFile to GML and vice-versa. The only issue that sometimes arises is wrong attribute types.

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.