Giter VIP home page Giter VIP logo

spatialite-tools-docker's Introduction

spatialite-tools-docker

One way you can use this Docker container is to run spatialite command-line tools interactively. I use this to avoid the hassle of settings things up on my personal laptop.

Example Invocation of Docker Container

  • Download some shapefiles to your desktop to a path like:

~/Desktop/GIS_project/GIS_data/Single_Member_Council_Districts

You can get a copy of the same data I used here by clicking Export in the upper right hand corner and downloading the Shapefile version.

  • Invoke the container like this giving the docker read only access to those shapefiles: docker run -v ~/Desktop/GIS_project/GIS_data/Single_Member_Council_Districts:/mnt:ro -i -t docker-spatialite /bin/bash

Example Usage of Spatialite

Once the container has started, here are some example commands. Please see spatialite docs for more options and explanations. I found this tutorial and this tutorial helpful.

  • Start up spatialite and create a sqlite DB:

spatialite city_districts.sqlite

  • Spatialite responds with info about versions:

<output about versions>

  • Tell Spatialite to load the shapefiles.

Note, the last parameter '2277' is the SRID of the input data and is critical! How to find this info

.loadshp /mnt/single_member_districts districts cp1252 2277

Response:

========
Loading shapefile at '/mnt/single_member_districts' into SQLite table 'districts'

BEGIN;
CREATE TABLE "districts" (
"PK_UID" INTEGER PRIMARY KEY AUTOINCREMENT,
"SINGLE_MEM" INTEGER,
"CREATED_DA" DOUBLE,
"CREATED_BY" TEXT,
"MODIFIED_D" DOUBLE,
"MODIFIED_B" TEXT,
"COUNCIL_DI" INTEGER,
"SHAPE_AREA" DOUBLE,
"SHAPE_LEN" DOUBLE);
SELECT AddGeometryColumn('districts', 'Geometry', -1, 'MULTIPOLYGON', 'XY');
COMMIT;

Inserted 10 rows into 'districts' from SHAPEFILE
  • Try an example SQL query:

select * from districts;

and response:

1|1|2456810.5|meekss|2457219.5|DrescherA|1|1272664566.63|599544.609967|
2|2|2456810.5|meekss|2457219.5|DrescherA|2|1263833912.62|680488.027708|
3|3|2456810.5|meekss|2456810.5|meekss|3|502791105.936|153982.266685|
4|4|2456810.5|meekss|2456810.5|meekss|4|330875387.854|105092.713667|
5|5|2456810.5|meekss|2457219.5|DrescherA|5|660839756.698|342350.0903|
6|6|2456810.5|meekss|2456810.5|meekss|6|1374405322.5|749161.180799|
7|7|2456810.5|meekss|2456810.5|meekss|7|782497876.307|285534.759773|
8|8|2456810.5|meekss|2457219.5|DrescherA|8|1219474429.14|495355.425095|
9|9|2456810.5|meekss|2456810.5|meekss|9|348217049.758|135780.24555|
10|10|2456810.5|meekss|2457219.5|DrescherA|10|1193325385.08|456486.67025|
  • Another SQL query you can run now. Note the 4326 and 2277. Those are important!

select * from districts where within(ST_Transform(GeomFromText('POINT(-97.837543 30.418986)', 4326), 2277),districts.Geometry);

Response:

6|6|2456810.5|meekss|2456810.5|meekss|6|1374405322.5|749161.180799|

spatialite-tools-docker's People

Contributors

kristina-hager avatar

Watchers

James Cloos 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.