Skip to content

Add FlatGeoBuf encoding #4

@m-mohr

Description

@m-mohr

Proposed by @StefanBrand in fiboa/specification#24 and fiboa/specification#32.

All the following has been written by @StefanBrand and more can be found in fiboa/specification#24:

Some related resources:

Here are some experiments based on the Austrian GSA dataset.

Tools

Steps

  1. Convert to FlatGeobuf:
    ogr2ogr GSA_Austria_2023-2_sample.fgb INSPIRE_SCHLAEGE_2023-2_POLYGON.gpkg \
      -limit 2 \
      -mo 'fiboa={"fiboa_version": "0.2.0", "fiboa_extensions": []}' \
      -nomd \
      -nln parcels
  2. Find length of Header: hexdump --skip 8 -n 4 -d GSA_Austria_2023-2_sample.fgb -> 2084
  3. Dump header into file: dd skip=12 count=2084 bs=1 if=GSA_Austria_2023-2_sample.fgb > header.bin
  4. Deserialize into JSON: flatc --json --strict-json --raw-binary src/fbs/header.fbs -- header.bin

Result

This is the resulting JSON:

{
  "name": "parcels",
  "envelope": [
    672737.349999999977,
    476317.109999999986,
    675804.430000000051,
    477193.350000000035
  ],
  "geometry_type": "Polygon",
  "columns": [
    {
      "name": "FS_KENNUNG",
      "type": "Double",
      "precision": 0
    },
    {
      "name": "SNAR_BEZEICHNUNG",
      "type": "String",
      "width": 240
    },
    {
      "name": "SL_FLAECHE_BRUTTO_HA",
      "type": "Double",
      "precision": 0
    },
    {
      "name": "GEO_ID",
      "type": "Double",
      "precision": 0
    },
    {
      "name": "INSPIRE_ID",
      "type": "String",
      "width": 500
    },
    {
      "name": "GML_ID",
      "type": "String",
      "width": 500
    },
    {
      "name": "GML_IDENTIFIER",
      "type": "String",
      "width": 500
    },
    {
      "name": "SNAR_CODE",
      "type": "String",
      "width": 30
    },
    {
      "name": "GEO_PART_KEY",
      "type": "Double",
      "precision": 0
    },
    {
      "name": "LOG_PKEY",
      "type": "Double",
      "precision": 0
    },
    {
      "name": "GEOM_DATE_CREATED",
      "type": "DateTime",
      "width": 0
    },
    {
      "name": "FART_ID",
      "type": "Double",
      "precision": 0
    },
    {
      "name": "GEO_TYPE",
      "type": "String",
      "width": 50
    },
    {
      "name": "GML_GEOM",
      "type": "Binary",
      "width": 0
    },
    {
      "name": "GML_LENGTH",
      "type": "Double",
      "precision": 0
    },
    {
      "name": "KZ_BIO_OEPUL_JN",
      "type": "String",
      "width": 1
    }
  ],
  "features_count": 2,
  "crs": {
    "org": "EPSG",
    "code": 31287,
    "name": "MGI / Austria Lambert",
    "wkt": "PROJCRS[\"MGI / Austria Lambert\",BASEGEOGCRS[\"MGI\",DATUM[\"Militar-Geographische Institut\",ELLIPSOID[\"Bessel 1841\",6377397.155,299.1528128,LENGTHUNIT[\"metre\",1]]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433]],ID[\"EPSG\",4312]],CONVERSION[\"Austria Lambert\",METHOD[\"Lambert Conic Conformal (2SP)\",ID[\"EPSG\",9802]],PARAMETER[\"Latitude of false origin\",47.5,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8821]],PARAMETER[\"Longitude of false origin\",13.3333333333333,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8822]],PARAMETER[\"Latitude of 1st standard parallel\",49,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8823]],PARAMETER[\"Latitude of 2nd standard parallel\",46,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8824]],PARAMETER[\"Easting at false origin\",400000,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8826]],PARAMETER[\"Northing at false origin\",400000,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8827]]],CS[Cartesian,2],AXIS[\"northing (X)\",north,ORDER[1],LENGTHUNIT[\"metre\",1]],AXIS[\"easting (Y)\",east,ORDER[2],LENGTHUNIT[\"metre\",1]],USAGE[SCOPE[\"Topographic mapping (medium and small scale).\"],AREA[\"Austria.\"],BBOX[46.4,9.53,49.02,17.17]],ID[\"EPSG\",31287]]"
  },
  "metadata": "{\"fiboa\":\"{\\\"fiboa_version\\\": \\\"0.2.0\\\", \\\"fiboa_extensions\\\": []}\"}"
}

Note that OGR already seems to quote the JSON, which results in too many quoted characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions