Many existing data types:
float
- int
- char
- string
- timestamp
Can't we just make it with these data types?
Comma Separated Values
name, type, latitude, longitude
BU Bridge, bridge, 42.353, -71.1106
Prudential Tower, skyscraper, 42.347, -71.082
'That place where we measured 108.6" of snow', airport, 42.3605, -71.006638
GDAL: translate spatial data between formats.
brew install gdal
apt-get install gdal
Everyone uses it, you should too!
cd data/
# ogr2ogr is confusingly <OUTPUT NAME> <INPUT NAME>
ogr2ogr -f "GeoJSON" locations.geojson locations.csv
World's tiniest trumpet — doesn't work. Why? GDAL wants to know: Which columns are our spatial data? How are they registered to the surface of the earth?
<OGRVRTDataSource>
<OGRVRTLayer name="locations">
<SrcDataSource>locations.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="PointFromColumns" x="longitude" y="latitude"/>
</OGRVRTLayer>
</OGRVRTDataSource>
Simpler ways:
So what's all this XML? I thought we were just making a point?
Want data formats that let us store geometric information. We have an attribute model, like the CSV, but want an additional "entity" model to store the geographic information.
Geometries bring their own edge cases:
POLYGON((0 0, 10 10, 0 10, 10 0, 0 0))
.shp, .shx, .dbf
) plus some optional extras (.prj
, .sbn
, ...).shp
contains the shapes themselves (in binary).shx
contains the index to look up shape locations in the .shp
16-bit int
, so only 2GB files# default output of OGR is a shapefile, no `-f format` needed
ogr2ogr locations.shp locations.vrt
JSON
has a massive ecosystem! Spatial is always better when it bootstraps the existing technology ecosystem{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "name": "BU Bridge", "type": "bridge", "latitude": "42.353", "longitude": "-71.1106" }, "geometry": { "type": "Point", "coordinates": [ -71.1106, 42.353 ] } },
{ "type": "Feature", "properties": { "name": "Prudential Tower", "type": "skyscraper", "latitude": "42.347", "longitude": "-71.082" }, "geometry": { "type": "Point", "coordinates": [ -71.082, 42.347 ] } },
{ "type": "Feature", "properties": { "name": "That place where we measured 109in of snow", "type": "airport", "latitude": "42.3605", "longitude": "-71.006638" }, "geometry": { "type": "Point", "coordinates": [ -71.006638, 42.3605 ] } }
]
}
E00
, parcel fabric) and now, with TopoJSONPostGIS, GeoPackage (SQLite), SQL Server, Esri Geodatabase, ...
This stuff + computational geometry:
Koop: Expose Open Data as GeoJSON and Feature Services: