Discussion:
[otb-users] Zonal stats: updating polygons of a vector file by adding fields computed from a raster
Jordi Inglada
2018-08-03 15:34:32 UTC
Permalink
Hi,

Given an image (raster) and a vector file containing polygons, I need to
compute a series of values for each polygon like the mean of a
particular band of the raster, etc. and then produce a new (or update
the) vector file with new fields. I think these are called zonal
statistics.

It looks like the LSMSVectorization application does that, but it uses a
raster segmentation instead of an input vector file. Given that my
polygons cover only a small fraction of the input raster, I don't think
than rasterizing the vector file to use this application will be
efficient. An besides, I would have to link back the attributes to the
original polygons, which is an additional step.

Is there any other way to do that with existing OTB applications? Maybe
gdal command line tools can do that? I have been looking around and it
seems that this is usually done the way LSMSVectorization does it (burn
the vector to raster, then compute using rasters only).

Do you have any advice on how to proceed if I need to write my own
application for that? I guess I will have to if I want to be able to
compute other features than mean and variance of the raster bands.

By the way, my images and vector data are huge, so streaming and
multi-threading will be needed.

I was thinking about the following approach:

1. Read in a set of polygons until a total surface is reached (so that
we can associate that with the RAM needed for the total number of raster
pixels to keep in memory).
2. Project the polygons onto the raster geometry and read in the pixels
3. Parallel computation of the stats (either with an OpenMP loop or a
simple thread pool [1])
4. Write the geometries and the stats to the output file
5. Release the memory and go back to 1

Any comments on that?

Thanks.

Jordi

[1] https://jordiinglada.net/wp/2015/05/13/a-simple-thread-pool-to-run-parallel-prosail-simulations/
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Guillaume Pasero
2018-08-10 08:10:08 UTC
Permalink
Daniel McInerney
2018-08-13 13:57:48 UTC
Permalink
Hi Jordi,


In my opinion the tool that you have proposed would be a really valuable
addition to OTB. Such a tool's ability to

also calculate percentiles would be relevant for the analysis of LiDAR
derived products for forestry applications.


The GDAL based pktools [1] provides a tool (pkextractogr [2]), which to a
large extent, provides much of the functionality

that you have outlined in your email and maybe useful for
review/comparison. While GRASS-GIS provides v.rast.stats [3],

with extended statistics being calculated by specifying the -e flag.


best regards,

Daniel.


[1]: http://pktools.nongnu.org/html/index.html

[2]: http://pktools.nongnu.org/html/pkextractogr.html

[3]: https://grass.osgeo.org/grass74/manuals/v.rast.stats.html
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...