<div dir="ltr"><div><div><br><br>On Tue, May 8, 2018 at 4:01 PM, Nikos Alexandris <<a href="mailto:nik@nikosalexandris.net">nik@nikosalexandris.net</a>> wrote:<br>><br>> Dears,<br>><br>> the following concerns an update of an existing workflow, part of which<br>> is GRASS GIS, that makes use of a large PostgreSQL data base which does<br>> not reside locally.<br>><br>><br>> The original data set consists of tens of thousands of (overlapping)<br>> polygons. The data are required solely to build raster MASKs.<br>> So, importing the whole of it, is an overkill. Instead, options, already<br>> working, are to split all records in single tables or views. Then access<br>> these via GRASS to perform some analytics.<br>><br>><br>> First instructions of the workflow are:<br>><br>> - read a (external) vector map<br>> - set the computational region<br>> - build a raster mask.<br>><br>><br>> Building a MASK using a pseudo vector map that links to an<br>> external table, stored in a PostgreSQL data base, is times slower than<br>> importing the vetor of interest in GRASS GIS and then building a MASK<br>> using the "native" GRASS GIS vector map.<br>><br>><br>> Giacomo timed different options, using `v.external` as well as importing<br>> the data using `v.in.ogr`. Specifically,<br>><br>> - building a MASK using one pseudo vector map (without and with a<br>>  spatial-index), takes about 9 minutes (real time).<br>><br>> time r.mask vector=test_nogeoindex --o<br>><br>> real 8m40.306s<br>> user 5m14.225s<br>> sys 0m56.378s<br>><br>> and<br>><br>> time r.mask vector=test_geoindex --o<br>><br>> real 8m46.096s<br>> user 5m15.693s<br>> sys 0m56.346s<br>><br>> - building a MASK using a native GRASS GIS vector map, imported via a<br>>  table or a view, takes about 0.4 seconds.<br>><br>> real 0m0.373s<br>> user 0m0.191s<br>> sys 0m0.111s<br>><br>> and<br>><br>> real 0m0.350s<br>> user 0m0.179s<br>> sys 0m0.115s<br><br></div>you need to include v.external/v.in.ogr in your timing in order to get real timings for creating a raster MASK from a vector stored in a remote database.<br><br></div>as a general rule of thumb, processing becomes faster if you create a local copy of the data to be processed, particularly if these data need to be accessed repeatedly.<br><div><div>><br>><br>> For the latter, building a view is way faster than a table (half a<br>> minute for more than 20000 views, while it would take approximately an<br>> hour to build single tables).<br>><br>> The trade-off appears to be space vs time. If data are imported, more<br>> disk space is required. If data are not imported, and `v.external` is<br>> used, then `r.mask` takes too much time to build a raster MASK.<br>><br>> - Is it acceptable for `r.mask` to take so long in building a MASK based<br>>  on an external vector map stored in a PostgreSQL data base?<br>><br>> - Is network connection a limiting factor here, since the PG data base<br>>  is not local?<br><br></div><div>you could check the network connection speed with some data transfer, ideally by transferring ordinary files/directories<br><br></div><div>Markus M<br></div><div><br>><br>> - Would anyone have any recommendations/considerations on this approach?<br>><br>> Thank you, Nikos<br>><br>> _______________________________________________<br>> grass-user mailing list<br>> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br><br></div></div></div>