I have some large geotiff file,size range from 200MB to 10GB.
They are produced by drones following a specific route, capturing images at a certain width.
Here is an example with mosaic:
sample tiff
The file size is about 200MB.
Now i want to get the polygon info in this tif file,like the area marked by red line in the picture.
So i tried to use **PolygonExtractionProcess **to do the job,but it takes like forever and my cpu almost runs up to 100%,i have to give up.
Then i find some “middle” tif files which are only white and black,their size is quite small(from 50KB to 10MB),like this:
black white tiff
After i use this small tif as input,the polygonize process last about 1-2minutes,i get some result like this(not exactly what i want but pretty close,i only want the black part):
polygonize result
The code is like this(just very simple usage):
AbstractGridCoverage2DReader gridCoverage2DReader = gridFormat.getReader(iis, hints);
GridCoverage2D coverage = gridCoverage2DReader.read(null);
PolygonExtractionProcess process = new PolygonExtractionProcess();
SimpleFeatureCollection features = process.execute(coverage, 0, Boolean.TRUE, null, null, null, null);
SimpleFeatureIterator sfi = features.features();
After some search, i realize that before polygonize,i need to greyscale or black white binarization the tiff file to reduce the file size.But it seems very hard to do so with JAVA/GeoTools,lots of solutions are using GDAL or GIS software like QGIS/ARCGIS.
My questions are:
1,am i on the right track? if not,is there any standard solution?
2,Can Java/Geotools do the greyscale job of large tif file efficiently and not using to much memory?
3,how can i only get the black part polygon from the black white tiff?
simon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.