GeoJSON
Страница в процессе перевода. |
Documentation for GeoJSON.
See the GeoInterfaces.jl and Tables.jl documentation for most applicable methods.
#
GeoJSON.GeoJSON
— Module
GeoJSON
This package is heavily inspired by, and borrows code from, JSONTables.jl, which does the same thing for the general JSON format. GeoJSON puts the geometry in a geometry
column, and adds all properties in the columns individually.
Usage
GeoJSON only provides simple read
and write
methods. GeoJSON.read
takes a file path, string, IO, or bytes.
julia> using GeoJSON, DataFrames
julia> fc = GeoJSON.read("path/to/a.geojson")
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)
# write to string
julia> write(fc)
"{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-69.99693762899992...
HTTP access
To read JSON from a URL, use HTTP.jl
julia> using GeoJSON, HTTP
julia> resp = HTTP.get("https://path/to/file.json")
julia> fc = GeoJSON.read(resp.body)
#
GeoJSON.CRS
— Type
CRS(type::String, properties::Dict{String,Any})
A Coordinate Reference System for compatibility. Should not be used, as it is not part of the GeoJSON specification. The CRS of a GeoJSON object is always WGS84.
#
GeoJSON.Feature
— Type
Feature{D,T}(id::Union{String,Nothing}, bbox::Union{Nothing,Vector{T}}, geometry::Union{Nothing,AbstractGeometry{D,T}}, properties::Union{Nothing,Dict{String,Any}})
A Feature with D
dimensional geometry.
#
GeoJSON.FeatureCollection
— Type
FeatureCollection{D,T}(bbox::Union{Nothing,Vector{T}}, features::Vector{Feature{D,T}}, crs::Union{Nothing,CRS})
A FeatureCollection with D
dimensional geometry in its features.
#
GeoJSON.GeometryCollection
— Type
GeometryCollection{D,T}(geometries::Vector{AbstractGeometry{D,T}})
A GeometryCollection geometry with D
dimensions.
#
GeoJSON.LazyFeatureCollection
— Type
LazyFeatureCollection{D,T}(bbox::Union{Nothing,Vector{T}}, features::Vector{LazyFeature{D,T}}, crs::Union{Nothing,String})
A FeatureCollection with D
dimensional geometry in its features, but its features are lazily parsed from the GeoJSON string. Indexing into the collection will parse the feature. This can be more efficient when interested in only a few features from a large collection, or parsing a very large collection iteratively without loading it all into memory.
#
GeoJSON.LineString
— Type
LineString{D,T}(coordinates::Union{Nothing,Vector{NTuple{D,T}}})
A LineString geometry with D
dimensions.
#
GeoJSON.MultiLineString
— Type
MultiLineString{D,T}(coordinates::Union{Nothing,Vector{Vector{NTuple{D,T}}}})
A MultiLineString geometry with D
dimensions.
#
GeoJSON.MultiPoint
— Type
MultiPoint{D,T}(coordinates::Union{Nothing,Vector{NTuple{D,T}}})
A MultiPoint geometry with D
dimensions.
#
GeoJSON.MultiPolygon
— Type
MultiPolygon{D,T}(coordinates::Union{Nothing,Vector{Vector{Vector{NTuple{D,T}}}}})
A MultiPolygon geometry with D
dimensions.
#
GeoJSON.Point
— Type
Point{D,T}(coordinates::Union{Nothing,NTuple{D,T}})
A Point geometry with D
dimensions.
#
GeoJSON.Polygon
— Type
Polygon{D,T}(coordinates::Union{Nothing,Vector{Vector{NTuple{D,T}}}})
A Polygon geometry with D
dimensions.
#
GeoJSON.read
— Method
GeoJSON.read(json; lazyfc=false, ndim=2, numbertype=Float32)
Read GeoJSON to a GeoInterface.jl compatible object.
Arguments
-
json
: A file path, string, IO, or bytes (AbstractVector{UInt8
) containing JSON to read. -
lazyfc::Bool=false
: When reading in huge featurecollections (1M+ features), setlazyfc=true
to only parse them into memory when accessed. -
ndim::Int=2
: Use 3 for 3D geometries, which is also used when 2D parsing fails. -
numbertype::DataType=Float32
: Use Float64 when the precision is required.
#
GeoJSON.write
— Method
write([io], geometry)
Write a GeoInterface.jl compatible feature or geometry to a GeoJSON String
.
io
may be a filename String
or IO
object.