GeoJSONTables.jl

Read GeoJSON spatial files to tables.
Author visr
Popularity
10 Stars
Updated Last
1 Year Ago
Started In
August 2019

GeoJSONTables

Status: This package has become the new GeoJSON.jl as of v0.6, which adds GeoInterface v1 support. Therefore this repository has been archived.

Read GeoJSON FeatureCollections using JSON3.jl, and provide the Tables.jl interface.

This package is unregistered and in development, so expect changes. It only supports reading, and only of FeatureCollections.

This package is heavily inspired by, and borrows code from, JSONTables.jl, which does the same thing for the general JSON format. GeoJSONTables puts the geometry in a geometry column, and adds all properties in the columns individually. The geometry and non-scalar properties are kept as JSON3.Object and JSON3.Array. Right now that means the geometries are hard to use, but at least parsing is fast.

Going forward, it would be nice to try developing a GeoTables.jl, similarly to Tables.jl, but with special support for a geometry column, that supports a diverse set of geometries, such as those of LibGEOS, Shapefile, ArchGDAL.jl, GeometryBasics and of course this package.

It would also be good to explore integrating this code into GeoJSON.jl and archiving this package. See GeoJSON.jl#23 for discussion.

Usage

julia> using GeoJSONTables, DataFrames

julia> jsonbytes = read("path/to/a.geojson");

julia> fc = GeoJSONTables.read(jsonbytes)
FeatureCollection with 171 Features

julia> first(fc)
Feature with geometry type Polygon and properties Symbol[:geometry, :timestamp, :version, :changeset, :user, :uid, :area, :highway, :type, :id]

# use the Tables interface to convert the format, extract data, or iterate over the rows
julia> df = DataFrame(fc)