PHP code example of teamzac / laravel-shapefiles

1. Go to this page and download the library: Download teamzac/laravel-shapefiles library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

teamzac / laravel-shapefiles example snippets


...
$reader->each(function($geometry) {
    $geometry->asGeoJson(); // passes through to the getGeoJSON() method with the "as" verbiage commonly used in Laravel
    $geometry->asJson(); // a convenience method that runs the GeoJSON through json_decode first
    $geometry->getData('ID'); // allows retreival of a specific key in the data array
    $geometry->ID; // you can also access the data array as properties on the Geometry class

    $geometry->getDataArray(); // methods are passed through to the underlying Shapefile\Geometry\Geometry class
    $geometry->getRaw(); // you can retrieve the underlying Shapefile\Geometry\Geometry class with the getRaw() method
});
...
 php
$reader = new TeamZac\LaravelShapefiles\Reader('file_or_directory_path_here');

$reader->count(); // total number of records
$reader->each(function($geometry) {
    // do something
});