Error occurs under Windows in QGIS 2.8.3 and 2.10.1, answers to similar questions e.g. 57418 have not helped.

The shapefile in question was created as follows:

  1. Vector/GPS/GPS tools/Load GPX file (Routes)
  2. Layer / save as ESRI shapefile [....\epsg4326\routes.shp]

The failing sequence is:

  • Start a new map/add vector layer [routes.shp]
  • Open attribute table
  • Add new column AREA [decimal real width=17 precision=8]
  • Manually edit both AREA values to verify format.
  • Select all entries [2 entries]
  • Field calculator / existing /AREA / geometry / $area

Always get NULL

I have tried countless combinations of width and precision for AREA. I have uninstalled/reinstalled/installed different releases. All to no avail.

What's up Doc?

Beginning to smell a rat in the direction of either the GPS tool or the shapefile. Starting with the shapefile, how may I independently verify it?

  • 1
    If it's a routes layer then are these line geometries? If so then they would not have any area. What does the length calculation return?
    – bosth
    Commented Sep 29, 2015 at 1:37
  • In fact, the only value returned was via the $length function. This were all less than .1 meter for expected values of kilometers. The routes are closed, (end point equals start point) and I assumed they would be treated as polygons.
    – Bad Loser
    Commented Sep 29, 2015 at 2:27
  • It's possible the wrong EPSG code was used when creating the Shapefile. But getting back to the original question, I think the QGIS behaviour was expected since these are lines not polygons.
    – bosth
    Commented Sep 29, 2015 at 2:30
  • Thank-you @bosth. I quite agree. Would you perchance have a tip on how I might create a shape file that describes polygons or a tool that might let me analyse an existing shape file? Is there a log file to which a routine like $area could write a meaningful message such as 'Lines do not have areas'?
    – Bad Loser
    Commented Sep 29, 2015 at 2:48
  • From inside QGIS you can create a new Shapefile and set the type to Polygon. Then you can draw your own shapes. However if you just want to play wish some data, go to Natural Earth and there are many data sets of various types. The countries data set is all polygons and you can experiment with it. The QGIS logs can be found with the little message baloon icon in the bottom right corner of the window. I'm not sure if $area will generate any messages when you input lines, however.
    – bosth
    Commented Sep 29, 2015 at 3:07

1 Answer 1


There are two things you get wrong:

  1. GPX data is always in EPSG:4326 latlong degrees. If you want measurements in meters, you have to reproject the data to your local UTM zone. Use Save As ..., not Set Layer CRS for that.
  2. GPX only knows about points and lines. If you want polygons, you have to close the line. If you have any self-intersection within your track, you will not get a valid polygon. So you have to sanitize your data first if you want to get a polygon out of GPS data.

A closed way is not automatically a polygon. In QGIS, you can use Vector -> Geometry Tools -> Lines to Polygons to create a polygon layer from the data. If you still get no result, try Vector -> Geometry Tools -> Check Geometry Vailidity.

Self-intersection means that the line crosses itself somewhere (not necessarily at the ends). GPS data is prone for that, if you stand still, and the unit is improving its reception quality.

  • I saved the raw GPX route layer with CRS of UTM zone 59N - appropriate for New Zealand - and now at least get a meaningful $length. Thank-you. Could you clarify part 2 of your answer.<br> As you would have read above, I thought I had 'sanitised' my data by providing identical start/end points thereby unmistakeably describing a 'closed' polygon to a GPS import tool smart enough to listen. I unsuccessfully repeated the experiment leaving the route 'open' (thus removing what you described as 'self intersection'.)<br> So are you saying that I must sanitize my GPX data AFTER import and if so how?
    – Bad Loser
    Commented Sep 29, 2015 at 8:36
  • Could somebody please tell me how to accept the above answer? [Why can't I see an 'Accept this answer' button anywhere]
    – Bad Loser
    Commented Sep 29, 2015 at 8:46
  • See my extended answer for some clarification.
    – AndreJ
    Commented Sep 29, 2015 at 9:18

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.