How to calculate the length value for a field in QGIS
Really I should have titled this article. "How to create a shapefile with a field to store length values and then fill the field with length values using Quantum GIS aka. QGIS "
NOTES:
- Using Quantum GIS 1.7 r14693 from the osgeo4w-setup.exe
- OS Windows 7 Professional 32 bit
- example will use EPSG 31258 but you can of course use your own local EPSG code.
- Generally I already have some other data in EPSG 31258 I use as background data so I can see where my new file is in the world. When QGIS starts it has a default location of 0.00 x and 0.00 y at the center of your map window which = no where in particular. You should then define your project coordinate system under Settings > Project Properties > tab coordiate reference systems and set to EPSG 31258.
For more funky spatial reference EPSG fun check out spatialreference.org- Using Quantum GIS 1.7 r14693 from the osgeo4w-setup.exe
- OS Windows 7 Professional 32 bit
- example will use EPSG 31258 but you can of course use your own local EPSG code.
- Generally I already have some other data in EPSG 31258 I use as background data so I can see where my new file is in the world. When QGIS starts it has a default location of 0.00 x and 0.00 y at the center of your map window which = no where in particular. You should then define your project coordinate system under Settings > Project Properties > tab coordiate reference systems and set to EPSG 31258.
Part 1. Creating an empty Shapefile to store our data with lengths.
- Open Quantum GIS Go to Layer > New > New Shapefile Layer…
- Select the radio box Line
- Select your local coordinate system for us here in Klagenfurt, Austria we are going to use EPSG 31258 (ESRI “MGI_Austria_GK_M31″).
- Add a new attribute field one called id. (this can later be used as a primary key value)
Name: id
Type: whole number
Length: 10 (default) - Click Add to attributes list
- Add a new attribute field one called length. (here we will store our length value)
Name: length
Type: real
Length: 10 (default) - Click Add to attributes list
- Click OK Save As menu pops up and now give your shapefile a name and a location to save it on your computer. Enter filename: examplename
- Click SAVE
Part 2. Editing our newly created shapefile and then finally populating the length field with values.
- Select your newly created shapefile in the Layers by clicking on the name (this will highlight the name in blue on windows 7 pro default settings)
- Click the Toggle editing button in the editing toolbar (the one that looks like a pen)
- Click the Capture line button and start clicking to draw your line (left click, left click , left click ,left click … Right Click = DONE)
- Click the Open Attribute Table button
- Click the Open Field calculator button (looks like a calculator)
- Select update existing field
- select the length field
- select the button called Length with a double click (now $length should show up in the field calculator expression box)
- Click OK
If you have any feedback please let me know.
Unitl next time
Comments
Post a Comment