当前位置:网站首页>Geojson format description (detailed format)
Geojson format description (detailed format)
2022-06-28 02:10:00 【The most ferocious little seal】
1. brief introduction
GeoJSON Is a format that encodes geographic data structures .GeoJSON Objects can represent geometric information 、 An element or collection of elements .GeoJSON The following geometry types are supported :Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon and GeometryCollection
.GeoJSON The element in contains a geometric object and an attribute object , A feature set represents a collection of multiple features . A complete GeoJSON The data structure is always a JSON object . stay GeoJSON in , Objects consist of a collection of key value pairs . For every member , Names are always strings . The value of the member is either character string 、 Numbers 、 object 、 Array , Or "true","false" and "null"
, The array and object are composed of the values of the above types .
geojson Data acquisition address :http://datav.aliyun.com/tools/atlas/#&lat=31.769817845138945&lng=104.29901249999999&zoom=4
2. GeoJSON object
GeoJSON Always consists of a single object . This object represents geometry 、 An element or collection of elements , An object can have any number of members ( Key value pair ).
- GeoJSON The object must have a name of "type" Members of . The value of this member is determined by GeoJSON The string determined by the type of the object .
{
"type": "FeatureCollection",
"features": [
// Other content
]
}
type The value of the member must be one of the following :“Point”, “MultiPoint”, “LineString”, “MultiLineString”, “Polygon”, “MultiPolygon”, “GeometryCollection”, “Feature”, perhaps “FeatureCollection”.( Similar to the code above )
GeoJSON Object may have an optional "crs" member , Its value must be an object of a coordinate reference system ( see 3. Coordinate reference system object ).
{
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [
// Other content
]
}
GeoJSON The object may have a "bbox" member , Its value must be an array of bounding boxes **( see 4. Bounding box )**.
{
"type": "FeatureCollection",
"bbox": [-180.0, -90.0, 180.0, 90.0],
"features": [
// Other content
]
}
2.1 Geometry object
The geometric (Geometry) It's a kind of GeoJSON object , At this time type The value of the member is one of the following strings :"Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", perhaps "GeometryCollection"
. except “GeometryCollection”
Any other type of GeoJSON Geometric objects must have a name of "coordinates"
Members of .coordinates
The value of a member is always an array . The structure of the elements in this array is determined by the geometric type .
{
"type": "FeatureCollection",
"features": [
{
"type": "GeoJSON",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
108.953361,
34.292663
],
[
108.953404,
34.289539
],
[
108.950857,
34.289529
]
// Multiple latitude and longitude points
]
]
]
}
}
]
}
2.1.1.Position( Base point )
position Is the basic geometry . Of geometric objects "coordinates"
The members consist of a position( Here is the geometric point )、position Array ( Line or geometric multipoint ),position Array of arrays ( Noodles 、 Multi line ) perhaps position Multidimensional array of ( In many ways ) form .
position Represented by an array of numbers ( It can be understood as latitude and longitude ). Must have at least two elements , There can be more elements . The order of the elements must follow x,y,z
The order ( The east direction of coordinates in the projection coordinate reference system 、 To the north 、 Elevation or coordinate longitude in geographic coordinate reference system 、 latitude 、 Altitude ). Any number of other elements is allowed, and this article does not discuss the project .
2.1.2. type type :Point( spot )
Right type "Point" Come on ,“coordinates" The member must be a separate position.
{
"type": "Point", "coordinates": [100.0, 0.0] }
2.1.3. type type :MultiPoint( Multipoint )
Right type "MultiPoint" Come on ,"coordinates" Members must be position Array .
{
"type": "MultiPoint",
"coordinates": [ [100.0, 0.0], [101.0, 1.0] ]
}
2.1.4. type type :LineString( Line )
Right type "LineString" Come on ,“coordinates" Members must be two or more position Array of .
A linear ring has 4 One or more position A closed line of . The first and last positions are the same ( They represent the same point ). Although linear rings do not explicitly act as GeoJSON Geometric type , However, it is mentioned in the definition of surface geometry type .
{
"type": "LineString",
"coordinates": [ [100.0, 0.0], [101.0, 1.0] ]
}
2.1.5. type type :MultiLineString( Multi line )
Right type “MultiLineString" Come on ,"coordinates" The member must be an array of linear coordinates .
{
"type": "MultiLineString",
"coordinates": [
[ [100.0, 0.0], [101.0, 1.0] ],
[ [102.0, 2.0], [103.0, 3.0] ]
]
}
2.1.6. type type :Polygon( Noodles )
Right type "Polygon" Come on ,"coordinates" The member must be an array of linear circular coordinates . For faces with multiple rings , The first ring must be an outer ring , Others must be internal rings or holes , And the direction of the inner ring and the outer ring is opposite .
Without holes :
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}
Porous ( The direction of the outer ring and the inner ring is always opposite )
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}
2.1.7. type type :MultiPlygon( In many ways )
Right type "MultiPlygon" Come on ,"coordinates" The member must be an array of face coordinates .
{
"type": "MultiPolygon",
"coordinates": [
[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
[
[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]
]
]
}
2.1.8. type type :Geometry Collection( Geometric set )
The type is "GeometryCollection" Of GeoJSON An object is a collection object , It represents a collection of geometric objects . A geometric set must have a name "geometries" Members of . And "geometries" The corresponding value is an array . Each element in this array is a GeoJSON Geometry object .
{
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [100.0, 0.0]
},
{
"type": "LineString",
"coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
}
]
}
2.2 Feature object
The type is "Feature" Of GeoJSON The object is Feature object
.
- The element object must have a name of
"geometry"
Members of , The value of this geometric member is defined above geometry Object or JSON Of null value . - The element object must have a name of
“properties"
Members of , The value of this property member is an object ( whatever JSON Object or JSON Of null value ). - If the element is a common identifier , Then this identifier should contain the name “id” Members of the object .
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"adcode": 610102,
"name": " New town ",
"center": [
108.959903,
34.26927
],
"centroid": [
108.991696,
34.271932
],
"childrenNum": 0,
"level": "district",
"parent": {
"adcode": 610100
},
"subFeatureIndex": 0,
"acroutes": [
100000,
610000,
610100
]
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
108.953361,
34.292663
],
[
108.953404,
34.289539
],
[
108.950857,
34.289529
]
// Multiple latitude and longitude points
]
]
]
}
}
]
}
2.2.1 “properties" member
“properties" The content of the member is to save Feature object
Other attribute information , For example Feature object
Of name Information, etc .
2.3. FeatureCollection object
The type is "FeatureCollection" Of GeoJSON An object is a feature set object .
The type is "FeatureCollection" The object of must have a name "features" Members of . And “features" The corresponding value is an array . Each element in this array is defined above feature object .
You can refer to 2.2 Example
3. Coordinate reference system object
GeoJSON Object's coordinate reference system (CRS) By it "crs" Members to determine . If the object does not crs member , So it's a parent or a grandparent crs Members may be acquired as its crs. If this has not yet been achieved crs member , So the default CRS Will be applied to GeoJSON object .
- default CRS Is a geographic coordinate reference system , It uses WGS84 data , The units of length and height are decimal .
- The name is "crs" The value of a member must be JSON object ( It means the following CRS object ) perhaps JSON Of null. If CRS The value of is null, Then assume that there is no CRS 了 .
- crs Members should be located at ( Feature set 、 features 、 Of geometric order ) In the hierarchy GeoJSON Top level of object , And it should not be repeated or overwritten in self objects or grandchildren .
- Non empty CRS Object has two mandatory objects :“type" and "properties”.
- type The value of a member must be a string , This string indicates CRS Type of object .
- The value of a property member must be an object .
- CRS The coordinate order cannot be changed **( see 2.1.1. Location )**
{
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [
// Other content
]
}
3.1. CRS
CRS Objects can pass through name To indicate the coordinate reference system . under these circumstances , its "type" The value of a member must be a string "name". its "properties" The value of a member must contain "name" Member's object . This "name" The value of the member must be a string that identifies the coordinate reference system . such as “urn:ogc:def:crs:OGC:1.3:CRS84" Of OGC CRS Of URN Should take precedence over old identifiers such as "EPSG:4326" Selected .
3.2. On-line CRS
CRS Objects can also be connected to the Internet CRS Parameters . under these circumstances , its "type" The value of a member must be a string "link", its "properties" The value of a member must be a linked object .
- The connection object consists of a required member :“href”, And an optional member :“type”.
- Essential "href" The value of a member must be dereferenced URI( Unified resource identification ).
- Optional "type" The value of a member must be a string , And this string implies the provided URI Used in to indicate CRS Parameter format . The recommended value is :“proj4”,“ogcwkt”,esriwkt", However, other values can be used .
{
"type": "FeatureCollection",
"crs": {
"type": "link",
"properties": {
"href": "http://example.com/crs/42",
"type": "proj4"
}
},
"features": [
// Other content
]
}
The auxiliary file of the relative path can also be used as CRS Deal directly with :
{
"type": "FeatureCollection",
"crs": {
"type": "link",
"properties": {
"href": "data.crs",
"type": "ogcwkt"
}
},
"features": [
// Other content
]
}
4.Bounding Boxes
To include geometry、feature perhaps feature collection Coordinate range information ,GeoJSON The object may have a name of "bbox Members of .bbox The value of a member must be 2*n Array , here n Is the number of dimensions of the contained geometric objects , And the maximum and minimum values of all coordinate axes .bbox The order of the coordinate axes of follows the order of the geometric coordinate axes . besides ,bbox The coordinate reference system of is assumed to match where it is located GeoJSON Object's coordinate reference system .
feature On the object bbox Examples of members :
{
"type": "Feature",
"bbox": [-180.0, -90.0, 180.0, 90.0],
"geometry": {
"type": "Polygon",
"coordinates": [[
[-180.0, 10.0], [20.0, 90.0], [180.0, -5.0], [-30.0, -90.0]
]]
}
}
feature collection In the object bbox Examples of members :
{
"type": "FeatureCollection",
"bbox": [100.0, 0.0, 105.0, 1.0],
"features": [
// Other content
]
}
Reference resources :
https://zhuanlan.zhihu.com/p/510882183
https://blog.csdn.net/qq_36213352/article/details/117534921
边栏推荐
- Arrays. Aslist() pit
- Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
- Four classic training modes in comparative learning
- [Yocto RM]1 - System Requirements
- 指南针股票开户是会有什么风险吗?指南针开户安全吗
- Ten MySQL locks, one article will give you full analysis
- 嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
- TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language
- 树莓派实现温控风扇智能降温
- How to understand query, key and value in transformer
猜你喜欢
Hi, you have a code review strategy to check!
Database query optimization: master-slave read-write separation and common problems
Import the data table in MySQL into Excel
Cesium 多边形(polygon)extrudedHeight 和 height 的区别
766. 托普利茨矩阵
Overview of drug discovery-01 overview of drug discovery
如何理解 Transformer 中的 Query、Key 与 Value
将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
数据库查询优化:主从读写分离及常见问题
TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language
随机推荐
如何理解 Transformer 中的 Query、Key 与 Value
Capacitor
Lmsoc: a socially sensitive pre training method
树莓派实现温控风扇智能降温
Solve storage problems? WMS warehouse management system solution
Ten thousand words long article understanding business intelligence (BI) | recommended collection
I/o limit process and CPU limit process
Modular development
Four classic training modes in comparative learning
Cesium 获取屏幕所在经纬度范围
[Yocto RM]9 - QA Error and Warning Messages
Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)
[Yocto RM]8 - OpenEmbedded Kickstart (.wks) Reference
Overview of drug discovery-01 overview of drug discovery
Review of drug discovery-02-prediction of molecular properties
Hi, you have a code review strategy to check!
pytorch_ lightning. utilities. exceptions. MisconfigurationException: You requested GPUs: [1] But...
General process after reference layer reboot
MapReduce elementary programming practice
Import the data table in MySQL into Excel