Skip to content

Instantly share code, notes, and snippets.

@theduckylittle
Created March 11, 2019 16:40
Show Gist options
  • Save theduckylittle/a495fb911fdeba069cb326899f19bf83 to your computer and use it in GitHub Desktop.
Save theduckylittle/a495fb911fdeba069cb326899f19bf83 to your computer and use it in GitHub Desktop.
Fun with OGR
ducky@thinkduck /tmp $ cat test.geojson
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": { "smlint": 1 },
"geometry": {
"type" : "Point",
"coordinates" : [0, 0]
}
}
]
}
ducky@thinkduck /tmp $ rm output.gpkg ; ogr2ogr -f SQLite output.gpkg ./test.geojson -sql "SELECT cast(smlint as SMALLINT) from ogrgeojson"
ducky@thinkduck /tmp $ sqlite3 output.gpkg
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.
sqlite> .schema
CREATE TABLE geometry_columns ( f_table_name VARCHAR, f_geometry_column VARCHAR, geometry_type INTEGER, coord_dimension INTEGER, srid INTEGER, geometry_format VARCHAR );
CREATE TABLE spatial_ref_sys ( srid INTEGER UNIQUE, auth_name TEXT, auth_srid TEXT, srtext TEXT);
CREATE TABLE 'ogrgeojson' ( ogc_fid INTEGER PRIMARY KEY, 'GEOMETRY' BLOB, 'smlint' INTEGER_INT16);
sqlite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment