Ik gebruik een script waarbij ik een shp bestand wil inlezen met deze class: http://gasparesganga.com/labs/php-shapefile/#features


require_once(DOC_ROOT.'spider/php-shapefile-2.2.0/src/ShapeFileAutoloader.php');


\ShapeFile\ShapeFileAutoloader::register();

// Import classes
use \ShapeFile\ShapeFile;
use \ShapeFile\ShapeFileException;

try {
    // Open shapefile
    $ShapeFile = new ShapeFile(DOC_ROOT.'gadm28_levels.shp/gadm28_adm0.shp');
    
    // Read all the records
	$t=0;
    while ($record = $ShapeFile->getRecord(ShapeFile::GEOMETRY_BOTH)) 
	{
		$t++;
        if ($record['dbf']['_deleted']) continue;

		// Geometry
     //  echo $record['shp']['wkt'];
	 
	 //echo $t;
        }
}


Na 40 records is de memory overloaded. Ik gebruik PHP7 en de garbage collection:
gc_enable();

Hoe is dit te verhelpen? Weet iemand een manier om de shp file te splitten als het niet lukt om de memory usage te verlagen?

Reageren