GeoYaml support in geoc
GeoYaml is a new geospatial format inspired heavily by GeoJSON. The geoc command line application inherited support from the GeoScript Groovy library.
The geoc geometry convert command can read and write geometries in numerous formats. With the addition of GeoYaml to GeoScript, you can now convert WKT to GeoYaml.
geoc geometry convert -i "POINT (1 1)" -f yaml
---
geometry:
type: "Point"
coordinates:
- 1.0
- 1.0
By default geoc geometry convert will convert just the geometry but can easily ask it to convert to a feature
geoc geometry convert -i "POINT (1 1)" -f yaml -t feature
---
type: "Feature"
properties: {}
geometry:
type: "Point"
coordinates:
- 1.0
- 1.0
or a layer.
geoc geometry convert -i "POINT (1 1)" -f yaml -t layer
---
type: "FeatureCollection"
features:
- properties: {}
geometry:
type: "Point"
coordinates:
- 1.0
- 1.0
GeoScript contains a Layer reader and writer for GeoYaml, so the geoc vector to and geoc vector from commands can likewise read and write GeoYaml.
Lets create three random features using geoc vector randompoints.
geoc vector randompoints -g 0,0,10,10 -n 3
By default geoc produces CSV.
"id:Integer","the_geom:Point:EPSG:4326"
"0","POINT (7.60636796157687 2.3753549784903196)"
"1","POINT (4.9745726514566755 6.675365381718297)"
"2","POINT (2.405351418662609 2.2208167175513727)"
To produce GeoYaml, pipe the result to the geoc vector to command.
geoc vector randompoints -g 0,0,10,10 -n 3 | geoc vector to -f yaml
---
type: "FeatureCollection"
features:
- properties:
id: 0
geometry:
type: "Point"
coordinates:
- 3.1283949383907506
- 4.498820498273048
- properties:
id: 1
geometry:
type: "Point"
coordinates:
- 7.56963076658114
- 9.56291571535017
- properties:
id: 2
geometry:
type: "Point"
coordinates:
- 5.867742925735375
- 3.5465273540308253
Save the results of this command to a file.
geoc vector randompoints -g 0,0,10,10 -n 3 | geoc vector to -f yaml > points.yaml
Then, you can use that file to pipe to the geoc vector from command, buffer all features by 10, and save it back to GeoYaml using the geoc vector to command.
cat points.yaml | geoc vector from -f yaml | geoc vector buffer -d 10 | geoc vector to -f yaml
---
type: "FeatureCollection"
features:
- properties:
id: 0
geometry:
type: "Polygon"
coordinates:
- - - 15.495055730350103
- 9.778758641351073
- - 15.302908534382407
- 7.827855421189791
- - 14.73385105546297
- 5.9519243177001755
- - 13.809751853375555
- 4.223056311155052
- - 12.566123542215578
- 2.707690829485599
- - 11.050758060546126
- 1.4640625183256208
- - 9.321890054001003
- 0.5399633162382056
- - 7.445958950511387
- -0.0290941626812309
- - 5.495055730350105
- -0.2212413586489266
- - 3.544152510188822
- -0.0290941626812309
- - 1.6682214066992067
- 0.5399633162382056
- - -0.0606465998459162
- 1.4640625183256208
- - -1.5760120815153709
- 2.707690829485598
- - -2.819640392675349
- 4.223056311155052
- - -3.743739594762764
- 5.951924317700175
- - -4.3127970736822006
- 7.8278554211897875
- - -4.504944269649896
- 9.778758641351072
- - -4.3127970736822006
- 11.729661861512357
- - -3.743739594762764
- 13.60559296500197
- - -2.8196403926753506
- 15.334460971547093
- - -1.5760120815153735
- 16.849826453216547
- - -0.060646599845918
- 18.093454764376524
- - 1.6682214066992005
- 19.017553966463936
- - 3.544152510188817
- 19.586611445383376
- - 5.495055730350102
- 19.778758641351075
- - 7.445958950511387
- 19.586611445383376
- - 9.321890054001004
- 19.01755396646394
- - 11.050758060546123
- 18.093454764376528
- - 12.566123542215578
- 16.84982645321655
- - 13.809751853375555
- 15.334460971547095
- - 14.733851055462967
- 13.605592965001978
- - 15.302908534382407
- 11.72966186151236
- - 15.495055730350103
- 9.778758641351073
- properties:
id: 1
geometry:
type: "Polygon"
coordinates:
- - - 16.57678364800894
- 7.3124236621644805
- - 16.384636452041246
- 5.361520442003198
- - 15.81557897312181
- 3.4855893385135825
- - 14.891479771034394
- 1.7567213319684587
- - 13.647851459874417
- 0.2413558502990059
- - 12.132485978204963
- -1.002272460860972
- - 10.40361797165984
- -1.9263716629483874
- - 8.527686868170225
- -2.495429141867824
- - 6.576783648008941
- -2.6875763378355195
- - 4.625880427847658
- -2.495429141867824
- - 2.7499493243580435
- -1.9263716629483874
- - 1.0210813178129206
- -1.002272460860972
- - -0.4942841638565341
- 0.241355850299005
- - -1.737912475016512
- 1.7567213319684587
- - -2.6620116771039273
- 3.4855893385135817
- - -3.2310691560233638
- 5.3615204420031946
- - -3.4232163519910594
- 7.31242366216448
- - -3.2310691560233638
- 9.263326882325764
- - -2.6620116771039273
- 11.139257985815377
- - -1.7379124750165138
- 12.8681259923605
- - -0.4942841638565367
- 14.383491474029956
- - 1.0210813178129188
- 15.627119785189933
- - 2.7499493243580373
- 16.551218987277345
- - 4.625880427847654
- 17.120276466196785
- - 6.576783648008939
- 17.31242366216448
- - 8.527686868170223
- 17.120276466196785
- - 10.403617971659841
- 16.551218987277345
- - 12.132485978204958
- 15.627119785189935
- - 13.647851459874413
- 14.383491474029958
- - 14.891479771034394
- 12.868125992360502
- - 15.815578973121806
- 11.139257985815384
- - 16.384636452041242
- 9.263326882325767
- - 16.57678364800894
- 7.3124236621644805
- properties:
id: 2
geometry:
type: "Polygon"
coordinates:
- - - 18.677820738141843
- 0.3949081260986553
- - 18.485673542174148
- -1.555995094062627
- - 17.91661606325471
- -3.431926197552243
- - 16.992516861167296
- -5.160794204097367
- - 15.748888550007319
- -6.6761596857668195
- - 14.233523068337867
- -7.9197879969267975
- - 12.504655061792741
- -8.843887199014212
- - 10.628723958303127
- -9.412944677933648
- - 8.677820738141843
- -9.605091873901344
- - 6.726917517980562
- -9.412944677933648
- - 4.850986414490946
- -8.843887199014212
- - 3.1221184079458233
- -7.9197879969267975
- - 1.6067529262763687
- -6.67615968576682
- - 0.3631246151163907
- -5.160794204097367
- - -0.5609745869710245
- -3.4319261975522437
- - -1.130032065890461
- -1.5559950940626308
- - -1.3221792618581567
- 0.3949081260986541
- - -1.130032065890461
- 2.345811346259939
- - -0.5609745869710245
- 4.221742449749552
- - 0.3631246151163889
- 5.950610456294675
- - 1.606752926276366
- 7.46597593796413
- - 3.1221184079458215
- 8.709604249124109
- - 4.85098641449094
- 9.63370345121152
- - 6.7269175179805565
- 10.202760930130959
- - 8.677820738141842
- 10.394908126098656
- - 10.628723958303127
- 10.20276093013096
- - 12.504655061792743
- 9.633703451211522
- - 14.233523068337862
- 8.70960424912411
- - 15.748888550007317
- 7.465975937964132
- - 16.992516861167296
- 5.950610456294677
- - 17.916616063254708
- 4.221742449749559
- - 18.485673542174148
- 2.3458113462599424
- - 18.677820738141843
- 0.3949081260986553