0

I have map "my_pointmap" with 3D points with ids=(1,2,3...N). I have also list of subsets of these point ids , S = [(1,2,3,4),(2,4,10,12), ...]. I would love to get GRASS GIS vector map with |S| 3D convex hulls.

for s in S:
    s_ids_string = ",".join(map(str, s))
    gscript.run_command('v.hull',
                     input="my_pointmap",
                     output="my_hullmap",
                     layer = 1,
                     where = "id in ("+s_ids_string +")")

This of course works only for the first iteration. The second one throws error that the layer "my_hullmap" already exists. I could create |S| maps called "my_hullmap_%s". But since S is quite long, I would end up with humongous number of maps.

Note: Since ST_Hull in PostGIS is not doing what it should/could, I am here. Once I will have the map of 3D hulls, I will use v.out.postgis to store it back to postgis.

  • How about creating a "tmp_hullmap" (with overwrite) then add v.patch at each iteration to combine them together? However this will slice up the convex hulls where they intersect. But since you're concerned with the number of hull vectors, I don't see anyway to avoid this. – Micha Apr 10 at 19:08
  • Hi, thank you for comment @Micha. For now, I have created all |S| "my_hullmap_s". I have changed "cat" attribute in each map to its ID using: gscript.run_command('v.category', input="my_hullmap_i", output="my_hullmap_i_new", cat = i, layer = 1, option="sum") Then I have used v.patch to put them all into one layer. It seems they did not get sliced up. Anyway - it is not nice and it is pretty slow :/ – Dead Vil Apr 11 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.