3

I've got a txt/csv file with the utm coordinates and the hights. Now I want to upload this into qgis. This is not a problem so far. The problem is to create a shapefile out of the data with an attribute table for adding other values to work with. Has anyone an idea how to do this?

3 Answers 3

6

There's a plugin called Add Delimited Text Layer. I believe it is included in a default 1.8 install. Once the plugin is enabled, an option appears in the Layer toolbar and menu, where the Add Vector, Add Raster, etc. options are. The wizard should be self-explanatory, but feel free to ask further if you experience issues.

An imported text file still can't be edited by QGIS. Once you've imported the layer, you can use Layer > Save As... to save a shapefile, or any other format. Save the shapefile and then import it into QGIS, and you can edit as normal.

Full help here.

3
  • 2
    FYI Add Delimited Text Layer is now core and no longer a plugin.
    – Nathan W
    May 24, 2013 at 6:37
  • @NathanW, do you mean that the user no longer has to enable it in the plugin manager? Do you know which version this changed in?
    – dericke
    May 24, 2013 at 18:41
  • 1
    It will be in 2.0 once it comes out.
    – Nathan W
    May 24, 2013 at 21:44
2

Rightclick -> Save as ... to a shapefile should not be a problem. Then you can add additional columns to the attribute table of the shapefile with Table manager plugin or field calculator in the attribute table.

If you want to keep the attributes in a separate table outside QGIS, you need a common id field, with which you can join shapefile and external table data.

You can add the data table with Add vector layer (which does not sound logical for non-vector data) and define a join in the properties of the shapefile layer.

2

You can also use ogr for this, see this. In essence, this is what you need (from that previous link)

Consider the following CSV file (test.csv):

Latitude,Longitude,Name
48.1,0.25,"First point"
49.2,1.1,"Second point"
47.5,0.75,"Third point"

You can write the associated VRT file (test.vrt):

<OGRVRTDataSource>
    <OGRVRTLayer name="test">
        <SrcDataSource>test.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="Longitude" y="Latitude"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

You might need to change the LayerSRS to your UTM, but you get the idea: test.vrt can be opened by OGR, QGIS, etc. You might even convert it to another format (Shapefile, whatever) using ogr2ogr for example!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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