Giter VIP home page Giter VIP logo

spatialite's Introduction

Install

Note that you have to install first sqlite3 / mod_spatialite and spatialite to run this library.

composer require vincjo/spatialite

Tests

./vendor/bin/phpunit tests

Basic usage

Create a new empty DB :

use Spatialite\SPL;

$db = new SPL( SPL::CreateNewEmptyDB('test.sqlite') );

// Or connect an existing Spatialite DB :
$db = new SPL( 'path/to/mydb.sqlite' );

Load shapfile :

$db->loadShapefile('path/to/shapefile/commune', 'commune', [
    'srid' => 2154, 
    'charset' => 'UTF-8'
]);

Query :

$result = $db->query("
    SELECT numero, nom_acc, statut, AsText( ST_Centroid(geom) ) AS centroid
    FROM commune 
    LIMIT 3
")->fetchAll(SPL::FETCH_OBJ);

// output :
Array
(
    [0] => stdClass Object
        (
            [numero] => 71176
            [nom_acc] => Digoin
            [statut] => Chef-lieu de canton
            [centroid] => POINT(778668.545898 6599300.563594)
        )

    [1] => stdClass Object
        (
            [numero] => 71590
            [nom_acc] => Volesvres
            [statut] => Commune simple
            [centroid] => POINT(789596.3737 6597690.519251)
        )

    [2] => stdClass Object
        (
            [numero] => 71325
            [nom_acc] => La Motte-Saint-Jean
            [statut] => Commune simple
            [centroid] => POINT(773591.803208 6602067.726544)
        )

)

Dump shapefile :

$db->dumpShapefile('./shapefile', 'commune', [
    'charset' => 'UTF-8',
    'geomcolumn' => 'geom'
]);

About Spatialite

SpatiaLite implements spatial extensions following the specification of the Open Geospatial Consortium (OGC).
At a very basic level, a DBMS that supports Spatial Data offers an SQL environment that has been extended with a set of geometry types, and thus may be usefully employed i.e. by some GIS application.
A geometry-valued SQL column is implemented as a column that has a geometry type. The OGC specification describe a set of SQL geometry types, as well as functions on those types to create and analyze geometry values.

SpatiaLite 4.2.0 - SQL functions reference list

spatialite's People

Contributors

cd71-mthd avatar vincjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.