2

I have a polygon shapefile and a (merged) line shapefile (both are zipped). When I use Vector -> Analysis Tools -> Sum Line Lengths on these shapefiles, I get a layer with some of the LENGTHS filled with numeric values. However, a significant portion of the LENGTHS are now 'nan', even when the COUNT is a non-zero value.

Here are a few possible explanations, but I'm not sure which one is correct:

  1. Error with the shapefiles.
  2. Shapefiles are too big.
  3. The data type of the LENGTH field is inappropriate.
  4. I need to unzip them.

I've tried doing the same with a few of the unmerged line shapefiles and this problem still seems to occur.

  • Quick thought - have you checked for any null geometry in your files (and then eliminate any such features)? – MappaGnosis Oct 20 '18 at 9:35
0

I was having this same problem recently and it turns out that some of my lines had vertices that were too close together. I did not empirically confirm this, but I believe that these segments were too short to be considered as valid given the geoprocessing coordinate precision.

The solution which worked for me was to run Vector Geometry > Simplify with a very low precision (in my case, 0.1). This deleted the invalid segments and had an imperceptible effect on all other lines. After that, I had no more nan values when calculating lengths.

| improve this answer | |
0

I was having the same problem and I tried the solution suggested by wfgeo (Vector Geometry > Simplify), but it didn't work for me.

So I used Clip to clip the road layer with the option "itearte over the polygon layer", the green arrow (one layer for each feature of the polygon layer) and then I merged all the results into one line layer. With the field calculator I found the length of all the single lines and then I summarized on the basis of the polygon layer field.

Some features of the clipped road layer, had the result equal to "-2147483648". This happened when the feature line completely shared the perimeter of a polygon layer feature. I checked the "Sum Line Lengths" result and the "nan" problem occurred exactly for the feature that shared the perimeter with a feature of the line layer.

I think that's why simplify works in some cases.

| improve this answer | |

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.