<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div>Im working a project using gdal to slice TMS style png tiles. The code currently works, but I'm running into some trouble optimizing to run fast enough for use on mobile devices.</div><div>My current strategy:</div><div>Open the source data(currently testing with BSB):</div><div>Get the transform, using GDALGetGeoTransform, and get the inverse transform</div><div>get coordinate transformers from dataset coordinates to lat/lon</div><div>store all that for when tiles are needed</div><div><br></div><div>When a tile is needed:</div><div>Determine the pixel coordinates of the source data that is needed, taking into account a clip line for the data that is not at the edge of the source image.</div><div>Create a new VRT using VRTCreate(tileSize, tileSize)</div><div>Copy data to the VRT: </div><div> VRTAddSimpleSource(destBand, sourceBand,<br> sourceDataRegion.origin.x, sourceDataRegion.origin.y,<br> sourceDataRegion.size.width, sourceDataRegion.size.height,<br> destDataRegion.origin.x, destDataRegion.origin.y,<br> destDataRegion.size.width, destDataRegion.size.height,<br> "NEAREST",<br> VRT_NODATA_UNSET<br> );</div><div><br></div><div>Create a copy the VRT slice as PNG</div><div> GDALDriverH pngDriver = GDALGetDriverByName("PNG");<br> GDALDatasetH pngCopy = GDALCreateCopy(pngDriver, path.UTF8String, datasetToWrite, false, NULL, NULL, NULL);<br> GDALClose(pngCopy);</div><div><br></div><div><br></div><div>Currently GDALCreateCopy is using 70% of the total CPU time</div><div><br></div><div>I've tried reusing the same VRT, but did not see a significant speed increase from that.</div><div><br></div><div>Is there a more CPU efficient way to do this? Should I be creating a vet of the whole dataset warped to the target CRS using GDALAutoCreateWarpedVRT then slicing tiles from that?</div><div><br></div><div>Any suggestions for optimizing this would be greatly appreciated.</div><div><br></div><div>Also see that attached screenshot at <a href="https://s3.amazonaws.com/com.gaiagps.static/Screenshot_4_9_13_4_58_PM.png">https://s3.amazonaws.com/com.gaiagps.static/Screenshot_4_9_13_4_58_PM.png</a> for a breakdown of CPU usage</div><div><br></div><div>Thanks,</div><div>Jesse Crocker</div></body></html>