4

I use v.extract module in a python script : grass.run_command('v.extract', input=UH, output=centroids, type='centroid', overwrite='True', stdout = DEVNULL, stderr = DEVNULL)

when I compare the result with result from calculation with QGIS I notice some differences. enter image description here

red : GRASS v.extract, blue : QGIS. One of my colleague observed the same with its own shapefile. SAGA module (Polygon centroids) gives same result as QGIS. It seems that v.extract calculation isn't correct.

enter image description here

  • I also tried v.centroids which returns same result as v.extract. I'm going to test v.centerpoint but I'd really like to know why there is so much differences between all the results. – Christine Jun 21 '17 at 8:55
  • Thanks, italic_v.centerpoint_italic is giving an acceptable result. But I've only found it for GRASS 7. There's programs using GRASS 6 that can't be upgraded to GRASS 7. It seems there is no solutions for these. – Christine Jun 21 '17 at 9:46
  • Please define "It seems that v.extract calculation isn't correct." - what do you mean? – markusN Jun 27 '17 at 18:47
  • I added another screenshot to my question where we can see that red crosses are centroids calculated with v.centroids and blue crosses with v.centerpoint (polygons are derivated from raster and special process and they are very "irregular"). Blue crosses are more "central", better corresponding to what we expect (for modelisation aims). I'd really like to know why the results are so different. – Christine Jun 28 '17 at 7:11
  • So, you want to have the centroid in the barycenter? This is not a condition of putting centroids: think of a "banana" shape - the barycenter may be outside of the banana but a GIS style centroid must remain inside. Hence not necessarily the same thing. [or I still don't get your problem] – markusN Jun 29 '17 at 20:46
4

I would try v.centerpoint https://grass.osgeo.org/grass72/manuals/addons/v.centerpoint.html with the default value acenter=mean. v.extract and v.centroid are probably creating points which are more like point-on-surface, not accurate but guaranteed to be within the polygon, see comments in https://trac.osgeo.org/grass/ticket/1654.

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.