SlideShare une entreprise Scribd logo
1  sur  47
Télécharger pour lire hors ligne
geometry commands
Jared Erickson
CUGOS
June 20th 2012
What is it?
Command line application for
geometry
Buffer a point
echo "POINT (1 1)" | geom buffer -d 100
Reproject a Point
echo "POINT (1 1)" | geom project -s "EPSG:4326" -t "EPSG:2927"
Generate random points
echo "POINT (1 1)" | geom buffer -d 100 | geom random -n 200
"Write programs that do
one thing and do it well.
Write programs to work
together.Write programs
to handle text streams,
because that is a universal
interface."
Write programs that do
one thing and do it well...
buffer centroid envelope convexHull voronoiDiagram
Write programs to work
together...
Unix Pipes
stdin -> program -> stdout
... program -> stdout -> stdin -> program ...
buffer | centroid | envelope
wkt -> buffer -> wkt | wkt -> centroid -> wkt | wkt -> envelope -> envelope
Write programs to handle
text streams...
WKT
POINT (1 1)
LINESTRING (0 0, 5 5, 10 10)
POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))
Geometry Commands
• Java command line application
• JTS - Geometry
• Proj4j - Projections
• Args4j - Command line parsing
• https://github.com/jericks/geometrycommands
Commands
geom list
list arc arcpoly area boundary buffer centroid combine
contains convexHull coordinates count countpoints coveredby
covers crosses delaunay densify draw
dump ellipse difference hausdorffdistance disjoint distance
distanceline envelope equals interiorpoint interpolatepoint
intersection intersects isclosed isempty isrectangle isring issimple
isvalid iswithindistance kochsnowflake linemerge locatepoint type grid
endpoint get startpoint mincircle minclearance mindiameter minrect
node normalize octagonalenvelope overlaps placepoint pointatangle
polygonize project random randomwalk rectangle
reflect relate reverse rotate scale shear sierpinskicarpet similarity
simplify sinestar snap squircle subline supercircle symdifference text
touches translate union voronoi within
Process
echo "POINT (10 10)" | geom buffer -d 5
POLYGON ((15 10, 14.903926402016152 9.024548389919358, 14.619397662556434 8.08658283817455, 14.157348061512726
7.222148834901989, 13.535533905932738 6.464466094067262, 12.777851165098012 5.842651938487274, 11.91341716182545
5.380602337443566, 10.975451610080642 5.096073597983848, 10 5, 9.024548389919358 5.096073597983848, 8.086582838174552
5.380602337443566, 7.22214883490199 5.842651938487274, 6.464466094067262 6.464466094067262, 5.842651938487274
7.222148834901989, 5.380602337443566 8.086582838174554, 5.096073597983847 9.024548389919362, 5 10.000000000000004,
5.096073597983849 10.975451610080647, 5.380602337443569 11.913417161825455, 5.842651938487277 12.777851165098017,
6.4644660940672685 13.535533905932743, 7.222148834901996 14.157348061512732, 8.08658283817456 14.619397662556437,
9.024548389919369 14.903926402016154, 10.000000000000012 15, 10.975451610080654 14.90392640201615,
11.913417161825462 14.619397662556429, 12.777851165098024 14.157348061512717, 13.535533905932748
13.535533905932725, 14.157348061512735 12.777851165097996, 14.619397662556441 11.913417161825432,
14.903926402016156 10.975451610080622, 15 10))
Compare
echo "POINT (10 10)" | geom buffer -d 5 | geom
contains -o "POINT (5 5)"
false
Reproject
echo "POINT (1 1)" | geom project -s "EPSG:4326" -t
"EPSG:2927"
POINT (39722967.09614658 19129704.97907105)
Draw
echo "POINT (10 10)" | geom buffer -d 5 | geom draw
&& open image.png
Call command per line
cat > points.wkt
POINT (1 1)
POINT (2 2)
cat points.wkt | while read line; do geom buffer -d 10 -g
"$line"; done;
POLYGON ((11 1, 10.807852804032304 -0.9509032201612824, … , 10.807852804032311 2.9509032201612437, 11 1))
POLYGON ((12 2, 11.807852804032304 0.0490967798387176, … , 12 2))
cat points.wkt | while read -r line; do geom buffer -d 10 -g
"$line"; done
POLYGON ((11 1, 10.807852804032304 -0.9509032201612824, … , 11 1))
POLYGON ((12 2, 11.807852804032304 0.0490967798387176, … , 12 2))
Combine
cat points.wkt | while read -r line; do geom buffer -d 10 -g
"$line"; done | geom combine
MULTIPOLYGON (((11 1, 10.807852804032304 -0.9509032201612824, 10.238795325112868 -2.826834323650898, 9.314696123025453
-4.555702330196022, 8.071067811865476 -6.071067811865475, 6.555702330196023 -7.314696123025453, 4.826834323650898
-8.238795325112868, 2.9509032201612833 -8.807852804032304, 1.0000000000000007 -9, -0.9509032201612819 -8.807852804032304,
-2.826834323650897 -8.238795325112868, -4.55570233019602 -7.314696123025453, -6.071067811865475 -6.0710678118654755,
-7.314696123025453 -4.555702330196022, -8.238795325112868 -2.8268343236508944, -8.807852804032306 -0.9509032201612773, -9
1.0000000000000075, -8.807852804032303 2.950903220161292, -8.238795325112862 4.826834323650909, -7.3146961230254455
6.555702330196034, -6.071067811865463 8.071067811865486, -4.555702330196008 9.314696123025463, -2.826834323650879
10.238795325112875, -0.9509032201612606 10.807852804032308, 1.0000000000000249 11, 2.950903220161309 10.807852804032299,
4.826834323650925 10.238795325112857, 6.555702330196048 9.314696123025435, 8.071067811865499 8.07106781186545,
9.314696123025472 6.555702330195993, 10.238795325112882 4.826834323650862, 10.807852804032311 2.9509032201612437, 11 1)),
((12 2, 11.807852804032304 0.0490967798387176, 11.238795325112868 -1.826834323650898, 10.314696123025453
-3.5557023301960218, 9.071067811865476 -5.071067811865475, 7.555702330196023 -6.314696123025453, 5.826834323650898
-7.238795325112868, 3.9509032201612833 -7.807852804032304, 2.0000000000000004 -8, 0.0490967798387181 -7.807852804032304,
-1.826834323650897 -7.238795325112868, -3.55570233019602 -6.314696123025453, -5.071067811865475 -5.0710678118654755,
-6.314696123025453 -3.5557023301960218, -7.238795325112868 -1.8268343236508944, -7.807852804032306 0.0490967798387227, -8
2.0000000000000075, -7.8078528040323025 3.950903220161292, -7.2387953251128625 5.826834323650909, -6.3146961230254455
7.555702330196034, -5.071067811865463 9.071067811865486, -3.5557023301960076 10.314696123025463, -1.8268343236508788
11.238795325112875, 0.0490967798387394 11.807852804032308, 2.000000000000025 12, 3.950903220161309 11.807852804032299,
5.826834323650925 11.238795325112857, 7.555702330196048 10.314696123025435, 9.071067811865499 9.07106781186545,
10.314696123025472 7.555702330195993, 11.238795325112882 5.826834323650862, 11.807852804032311 3.9509032201612437, 12 2)))
Dump
echo "POINT (1 1)" | geom buffer -d 100 | geom random -
n 100 | geom dump > random.wkt
POINT (23.161455744394658 -77.95246871808072)
POINT (58.930083365685135 -61.904759742385096)
POINT (-68.59023262463613 -54.78626222287515)
POINT (-82.5800340659446 -28.375102984177744)
POINT (62.05862576956568 45.25807594023459)
POINT (74.43518384825472 -10.092639433362095)
…
Draw multiple geometries
echo "POINT (10 10)" > geoms.wkt
cat geoms.wkt | geom buffer -d 10 >> geoms.wkt
cat geoms.wkt | geom combine | geom draw && open
image.png
Draw multiple geometries
echo "POINT (100 100)" > geoms.wkt
cat geoms.wkt | geom get -n 0 | geom buffer -d 10 >> geoms.wkt
cat geoms.wkt | geom get -n 0 | geom buffer -d 20 >> geoms.wkt
cat geoms.wkt | geom get -n 0 | geom buffer -d 30 >> geoms.wkt
cat geoms.wkt | geom combine | geom draw && open image.png
Point at Angle
echo "POINT (10 10)" > center.wkt
cat center.wkt | geom pointatangle -a 0 -d 10 >> center.wkt
cat center.wkt | geom get -n 0 | geom pointatangle -a 45 -d 5 >> center.wkt
cat center.wkt | geom get -n 0 | geom pointatangle -a 90 -d 10 >> center.wkt
cat center.wkt | geom get -n 0 | geom pointatangle -a 135 -d 5 >> center.wkt
cat center.wkt | geom get -n 0 | geom pointatangle -a 180 -d 10 >> center.wkt
cat center.wkt | geom get -n 0 | geom pointatangle -a 225 -d 5 >> center.wkt
cat center.wkt | geom get -n 0 | geom pointatangle -a 270 -d 10 >> center.wkt
cat center.wkt | geom get -n 0 | geom pointatangle -a 315 -d 5 >> center.wkt
cat center.wkt | geom combine | geom draw && open image.png
Backtics
echo "POINT (10 10)" > point.wkt
echo "POINT (0 0)" | geom buffer -d 10 | geom
contains -o "`cat point.wkt | geom get -n 0`"
false
Generate Random Points
echo "POINT (1 1)" | geom buffer -d 100 | geom
random -n 20
MULTIPOINT ((28.654023089302072 -44.01821817278271), (81.83017489687163 -23.86819073039706), (2.105166479839937
36.12893454538721), (4.227942694802536 -75.42526935983172), (70.36226203781283 55.09734125747187), (-24.57828687972821
40.21049354265716), (43.29398472591029 91.04707992971149), (-10.753927532104086 29.320031764200024),
(-81.14902146405959 8.312362640063384), (29.670956290372317 1.1014786268571584), (42.092039630473465
83.01841893953664), (-3.8268655554251154 -33.81236693090035), (-54.61643432275327 -69.03248995687024),
(18.216453654179105 -46.68047579703787), (69.16611402164975 31.101723885056686), (-43.36423562242582
-76.70347656510657), (84.68024160811188 -46.630576818012635), (-52.67048441979452 -65.85207992789142),
(-82.00381658701411 -14.714381798142469), (72.18321150088343 -60.363316389278076))
Random Walk
echo "POINT (100 100)" | geom randomwalk -n 100 -a 45
-d 10 | geom draw -c && open image.png
Koch Snowflake
echo "POINT (1 1)" | geom envelope -e 100 | geom
kochsnowflake -n 1000 | geom draw && open image.png
Sierpinski Carpet
echo "POINT (1 1)" | geom envelope -e 100 | geom
sierpinskicarpet -n 1000 | geom draw && open
image.png
Text
geom text -t "Hi" | geom draw -c && open image.png
Sine Star
echo "POINT (100 100)" | geom sinestar -l 0.9 -n 12 -p
1000 -w 500 -h 500 | geom draw && open image.png
Rectangle
echo "POINT (100 100)" | geom rectangle -p 30 -w 500 -h
500 | geom draw -c && open image.png
Ellipse
echo "POINT (100 100)" | geom ellipse -p 30 -w 500 -h
500 | geom draw -c && open image.png
Squircle
echo "POINT (100 100)" | geom squircle -p 30 -w 500 -h
500 | geom draw -c && open image.png
Supercircle
echo "POINT (100 100)" | geom supercircle -o 3 -p 100 -
w 500 -h 500 | geom draw -c && open image.png
Arc
echo "POINT (100 100)" | geom arc -a 45 -e 90 -d -p 20 -
w 500 -h 500 | geom draw -c && open image.png
Arc polygon
echo "POINT (100 100)" | geom arcpoly -a 45 -e 90 -d -p
20 -w 500 -h 500 | geom draw -c && open image.png
PostgreSQL
psql -U postgres -d postgres -c "select St_asText
(the_geom) from washington_2927 where fid=5" -t |
geom draw && open image.png
PostgreSQL
psql -U postgres -d postgres -c "select St_asText
(st_collect(the_geom)) from washington_2927" -t | geom
draw && open image.png
PostgreSQL
psql -U postgres -d postgres -c "select St_asText
(the_geom) from washington_2927" -t | geom combine |
geom draw && open image.png
GeoScript: convert to kml
echo "POINT (1 1)" | geom buffer -d 10 | geoscript-
groovy -e "println geoscript.geom.Geometry.fromWKT
(System.in.text).kml"
<Polygon><outerBoundaryIs><LinearRing><coordinates>11.0,1.0 10.807852804032304,-0.9509032201612824
10.238795325112868,-2.826834323650898 9.314696123025453,-4.555702330196022 8.071067811865476,-6.071067811865475
6.555702330196023,-7.314696123025453 4.826834323650898,-8.238795325112868 2.9509032201612833,-8.807852804032304
1.0000000000000007,-9.0 -0.9509032201612819,-8.807852804032304 -2.826834323650897,-8.238795325112868
-4.55570233019602,-7.314696123025453 -6.071067811865475,-6.0710678118654755 -7.314696123025453,-4.555702330196022
-8.238795325112868,-2.8268343236508944 -8.807852804032306,-0.9509032201612773 -9.0,1.0000000000000075
-8.807852804032303,2.950903220161292 -8.238795325112862,4.826834323650909 -7.3146961230254455,6.555702330196034
-6.071067811865463,8.071067811865486 -4.555702330196008,9.314696123025463 -2.826834323650879,10.238795325112875
-0.9509032201612606,10.807852804032308 1.0000000000000249,11.0 2.950903220161309,10.807852804032299
4.826834323650925,10.238795325112857 6.555702330196048,9.314696123025435 8.071067811865499,8.07106781186545
9.314696123025472,6.555702330195993 10.238795325112882,4.826834323650862 10.807852804032311,2.9509032201612437
11.0,1.0</coordinates></LinearRing></outerBoundaryIs></Polygon>
GeoScript: draw shapefile
geoscript-groovy -e "println new
geoscript.geom.GeometryCollection(new
geoscript.layer.Shapefile('states.shp').features.collect
{it.geom}).wkt" | geom draw && open image.png
GeoScript: write shapefile
echo "POINT (1 1)" | geom buffer -d 100 | geom random -
n 100 | geoscript-groovy -e "new
geoscript.workspace.Directory('.').create(new
geoscript.feature.Schema('random',
[['the_geom','Point','EPSG:4326']])).add
(geoscript.geom.Geometry.fromWKT
(System.in.text).geometries.collect{new
geoscript.feature.Feature(['the_geom': it],null)})"
Geocoding
curl "http://geocoder.us/service/csv/geocode?zip=95472" |
awk -F ", " '{print "POINT ("$2 " " $1 ")"}' | geom buffer -d
10 | geom draw && open image.png
USGS Earthquakes
curl http://earthquake.usgs.gov/earthquakes/catalogs/
eqs1day-M2.5.txt | awk -F ',' '{if (NR!=1) {print "POINT
("$8" "$7")"}}' | geom combine | geom draw && open
image.png
WMS
curl -o map.jpg "http://vmap0.tiles.osgeo.org/wms/vmap0?
LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetM
ap&STYLES=&FORMAT=image%2Fjpeg&SRS=EPSG
%3A4326&BBOX=-123.07,46.66,-121.14,47.48&WIDTH=500&HEIG
HT=400"
echo "POINT (-122.429452 47.125627)" | geom buffer -d 0.2 | geom
draw -w 500 -h 400 -e "-123.07,46.66,-121.14,47.48" -i map.jpg &&
open image.png
Install
• Install Java
• Download
• https://github.com/jericks/geometrycommands/
downloads
• Put on path
• export PATH = /whereever/you/put/it/geom/bin
Help
• View commands
• geom list
• Get help on a command
• geom buffer --help
• Man pages
• man geom
• man geom-buffer
Web Site (Sphinx)
Extend
• Create a Java class that implements Command
Interface
• or extends GeometryCommand
• or extends OtherGeometryCommand
• Add command line options by creating an
Options subclass with Args4J annotations
• Java Service Provider Interface
• META-INF/services/org.geometrycommands/Command
• Add line with the full path (package and class name)
Thank you!

Contenu connexe

Similaire à Geometry Commands

第5回 様々なファイル形式の読み込みとデータの書き出し
第5回 様々なファイル形式の読み込みとデータの書き出し第5回 様々なファイル形式の読み込みとデータの書き出し
第5回 様々なファイル形式の読み込みとデータの書き出しWataru Shito
 
到都市的權利
到都市的權利到都市的權利
到都市的權利Shuwei Huang
 
RunHeading (x1).docx
RunHeading (x1).docxRunHeading (x1).docx
RunHeading (x1).docxSUBHI7
 
Learning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory ForensicsLearning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory ForensicsVincent Ohprecio
 
Trigonometric tables
Trigonometric tablesTrigonometric tables
Trigonometric tablesJayapal Jp
 
Trigonometric tables
Trigonometric tablesTrigonometric tables
Trigonometric tablesJayapal Jp
 
Acrylic gearbox creative journey
Acrylic gearbox creative journeyAcrylic gearbox creative journey
Acrylic gearbox creative journeyRaymond Bell
 
Image dct shifting
Image dct shiftingImage dct shifting
Image dct shiftingAmr Nasr
 
Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110
Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110
Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110BCV
 
111647298 heritage-dolls-case-study-analysis-calc
111647298 heritage-dolls-case-study-analysis-calc111647298 heritage-dolls-case-study-analysis-calc
111647298 heritage-dolls-case-study-analysis-calcFaheem Mukhtar
 

Similaire à Geometry Commands (20)

Tabel x2
Tabel x2Tabel x2
Tabel x2
 
Gauss seidel
Gauss seidelGauss seidel
Gauss seidel
 
第5回 様々なファイル形式の読み込みとデータの書き出し
第5回 様々なファイル形式の読み込みとデータの書き出し第5回 様々なファイル形式の読み込みとデータの書き出し
第5回 様々なファイル形式の読み込みとデータの書き出し
 
Distribucion Binomial
Distribucion BinomialDistribucion Binomial
Distribucion Binomial
 
ECE469 proj2_Lakshmi Yasaswi Kamireddy
ECE469 proj2_Lakshmi Yasaswi KamireddyECE469 proj2_Lakshmi Yasaswi Kamireddy
ECE469 proj2_Lakshmi Yasaswi Kamireddy
 
到都市的權利
到都市的權利到都市的權利
到都市的權利
 
Distribucion ji cuadrado
Distribucion ji cuadradoDistribucion ji cuadrado
Distribucion ji cuadrado
 
RunHeading (x1).docx
RunHeading (x1).docxRunHeading (x1).docx
RunHeading (x1).docx
 
Tablice beton
Tablice betonTablice beton
Tablice beton
 
Examen final
Examen finalExamen final
Examen final
 
Learning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory ForensicsLearning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory Forensics
 
Trigonometric tables
Trigonometric tablesTrigonometric tables
Trigonometric tables
 
Trigonometric tables
Trigonometric tablesTrigonometric tables
Trigonometric tables
 
Acrylic gearbox creative journey
Acrylic gearbox creative journeyAcrylic gearbox creative journey
Acrylic gearbox creative journey
 
Disaster Management Cycle
Disaster Management CycleDisaster Management Cycle
Disaster Management Cycle
 
GARCH
GARCHGARCH
GARCH
 
Image dct shifting
Image dct shiftingImage dct shifting
Image dct shifting
 
Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110
Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110
Fundamental Equity Analysis - QMS Advisors HDAX FlexIndex 110
 
Session6.0_OCHA.ppt
Session6.0_OCHA.pptSession6.0_OCHA.ppt
Session6.0_OCHA.ppt
 
111647298 heritage-dolls-case-study-analysis-calc
111647298 heritage-dolls-case-study-analysis-calc111647298 heritage-dolls-case-study-analysis-calc
111647298 heritage-dolls-case-study-analysis-calc
 

Dernier

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Dernier (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Geometry Commands

  • 2. What is it? Command line application for geometry
  • 3. Buffer a point echo "POINT (1 1)" | geom buffer -d 100 Reproject a Point echo "POINT (1 1)" | geom project -s "EPSG:4326" -t "EPSG:2927" Generate random points echo "POINT (1 1)" | geom buffer -d 100 | geom random -n 200
  • 4.
  • 5. "Write programs that do one thing and do it well. Write programs to work together.Write programs to handle text streams, because that is a universal interface."
  • 6. Write programs that do one thing and do it well... buffer centroid envelope convexHull voronoiDiagram
  • 7. Write programs to work together... Unix Pipes stdin -> program -> stdout ... program -> stdout -> stdin -> program ... buffer | centroid | envelope wkt -> buffer -> wkt | wkt -> centroid -> wkt | wkt -> envelope -> envelope
  • 8. Write programs to handle text streams... WKT POINT (1 1) LINESTRING (0 0, 5 5, 10 10) POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))
  • 9. Geometry Commands • Java command line application • JTS - Geometry • Proj4j - Projections • Args4j - Command line parsing • https://github.com/jericks/geometrycommands
  • 10. Commands geom list list arc arcpoly area boundary buffer centroid combine contains convexHull coordinates count countpoints coveredby covers crosses delaunay densify draw dump ellipse difference hausdorffdistance disjoint distance distanceline envelope equals interiorpoint interpolatepoint intersection intersects isclosed isempty isrectangle isring issimple isvalid iswithindistance kochsnowflake linemerge locatepoint type grid endpoint get startpoint mincircle minclearance mindiameter minrect node normalize octagonalenvelope overlaps placepoint pointatangle polygonize project random randomwalk rectangle reflect relate reverse rotate scale shear sierpinskicarpet similarity simplify sinestar snap squircle subline supercircle symdifference text touches translate union voronoi within
  • 11. Process echo "POINT (10 10)" | geom buffer -d 5 POLYGON ((15 10, 14.903926402016152 9.024548389919358, 14.619397662556434 8.08658283817455, 14.157348061512726 7.222148834901989, 13.535533905932738 6.464466094067262, 12.777851165098012 5.842651938487274, 11.91341716182545 5.380602337443566, 10.975451610080642 5.096073597983848, 10 5, 9.024548389919358 5.096073597983848, 8.086582838174552 5.380602337443566, 7.22214883490199 5.842651938487274, 6.464466094067262 6.464466094067262, 5.842651938487274 7.222148834901989, 5.380602337443566 8.086582838174554, 5.096073597983847 9.024548389919362, 5 10.000000000000004, 5.096073597983849 10.975451610080647, 5.380602337443569 11.913417161825455, 5.842651938487277 12.777851165098017, 6.4644660940672685 13.535533905932743, 7.222148834901996 14.157348061512732, 8.08658283817456 14.619397662556437, 9.024548389919369 14.903926402016154, 10.000000000000012 15, 10.975451610080654 14.90392640201615, 11.913417161825462 14.619397662556429, 12.777851165098024 14.157348061512717, 13.535533905932748 13.535533905932725, 14.157348061512735 12.777851165097996, 14.619397662556441 11.913417161825432, 14.903926402016156 10.975451610080622, 15 10))
  • 12. Compare echo "POINT (10 10)" | geom buffer -d 5 | geom contains -o "POINT (5 5)" false
  • 13. Reproject echo "POINT (1 1)" | geom project -s "EPSG:4326" -t "EPSG:2927" POINT (39722967.09614658 19129704.97907105)
  • 14. Draw echo "POINT (10 10)" | geom buffer -d 5 | geom draw && open image.png
  • 15. Call command per line cat > points.wkt POINT (1 1) POINT (2 2) cat points.wkt | while read line; do geom buffer -d 10 -g "$line"; done; POLYGON ((11 1, 10.807852804032304 -0.9509032201612824, … , 10.807852804032311 2.9509032201612437, 11 1)) POLYGON ((12 2, 11.807852804032304 0.0490967798387176, … , 12 2)) cat points.wkt | while read -r line; do geom buffer -d 10 -g "$line"; done POLYGON ((11 1, 10.807852804032304 -0.9509032201612824, … , 11 1)) POLYGON ((12 2, 11.807852804032304 0.0490967798387176, … , 12 2))
  • 16. Combine cat points.wkt | while read -r line; do geom buffer -d 10 -g "$line"; done | geom combine MULTIPOLYGON (((11 1, 10.807852804032304 -0.9509032201612824, 10.238795325112868 -2.826834323650898, 9.314696123025453 -4.555702330196022, 8.071067811865476 -6.071067811865475, 6.555702330196023 -7.314696123025453, 4.826834323650898 -8.238795325112868, 2.9509032201612833 -8.807852804032304, 1.0000000000000007 -9, -0.9509032201612819 -8.807852804032304, -2.826834323650897 -8.238795325112868, -4.55570233019602 -7.314696123025453, -6.071067811865475 -6.0710678118654755, -7.314696123025453 -4.555702330196022, -8.238795325112868 -2.8268343236508944, -8.807852804032306 -0.9509032201612773, -9 1.0000000000000075, -8.807852804032303 2.950903220161292, -8.238795325112862 4.826834323650909, -7.3146961230254455 6.555702330196034, -6.071067811865463 8.071067811865486, -4.555702330196008 9.314696123025463, -2.826834323650879 10.238795325112875, -0.9509032201612606 10.807852804032308, 1.0000000000000249 11, 2.950903220161309 10.807852804032299, 4.826834323650925 10.238795325112857, 6.555702330196048 9.314696123025435, 8.071067811865499 8.07106781186545, 9.314696123025472 6.555702330195993, 10.238795325112882 4.826834323650862, 10.807852804032311 2.9509032201612437, 11 1)), ((12 2, 11.807852804032304 0.0490967798387176, 11.238795325112868 -1.826834323650898, 10.314696123025453 -3.5557023301960218, 9.071067811865476 -5.071067811865475, 7.555702330196023 -6.314696123025453, 5.826834323650898 -7.238795325112868, 3.9509032201612833 -7.807852804032304, 2.0000000000000004 -8, 0.0490967798387181 -7.807852804032304, -1.826834323650897 -7.238795325112868, -3.55570233019602 -6.314696123025453, -5.071067811865475 -5.0710678118654755, -6.314696123025453 -3.5557023301960218, -7.238795325112868 -1.8268343236508944, -7.807852804032306 0.0490967798387227, -8 2.0000000000000075, -7.8078528040323025 3.950903220161292, -7.2387953251128625 5.826834323650909, -6.3146961230254455 7.555702330196034, -5.071067811865463 9.071067811865486, -3.5557023301960076 10.314696123025463, -1.8268343236508788 11.238795325112875, 0.0490967798387394 11.807852804032308, 2.000000000000025 12, 3.950903220161309 11.807852804032299, 5.826834323650925 11.238795325112857, 7.555702330196048 10.314696123025435, 9.071067811865499 9.07106781186545, 10.314696123025472 7.555702330195993, 11.238795325112882 5.826834323650862, 11.807852804032311 3.9509032201612437, 12 2)))
  • 17. Dump echo "POINT (1 1)" | geom buffer -d 100 | geom random - n 100 | geom dump > random.wkt POINT (23.161455744394658 -77.95246871808072) POINT (58.930083365685135 -61.904759742385096) POINT (-68.59023262463613 -54.78626222287515) POINT (-82.5800340659446 -28.375102984177744) POINT (62.05862576956568 45.25807594023459) POINT (74.43518384825472 -10.092639433362095) …
  • 18. Draw multiple geometries echo "POINT (10 10)" > geoms.wkt cat geoms.wkt | geom buffer -d 10 >> geoms.wkt cat geoms.wkt | geom combine | geom draw && open image.png
  • 19. Draw multiple geometries echo "POINT (100 100)" > geoms.wkt cat geoms.wkt | geom get -n 0 | geom buffer -d 10 >> geoms.wkt cat geoms.wkt | geom get -n 0 | geom buffer -d 20 >> geoms.wkt cat geoms.wkt | geom get -n 0 | geom buffer -d 30 >> geoms.wkt cat geoms.wkt | geom combine | geom draw && open image.png
  • 20. Point at Angle echo "POINT (10 10)" > center.wkt cat center.wkt | geom pointatangle -a 0 -d 10 >> center.wkt cat center.wkt | geom get -n 0 | geom pointatangle -a 45 -d 5 >> center.wkt cat center.wkt | geom get -n 0 | geom pointatangle -a 90 -d 10 >> center.wkt cat center.wkt | geom get -n 0 | geom pointatangle -a 135 -d 5 >> center.wkt cat center.wkt | geom get -n 0 | geom pointatangle -a 180 -d 10 >> center.wkt cat center.wkt | geom get -n 0 | geom pointatangle -a 225 -d 5 >> center.wkt cat center.wkt | geom get -n 0 | geom pointatangle -a 270 -d 10 >> center.wkt cat center.wkt | geom get -n 0 | geom pointatangle -a 315 -d 5 >> center.wkt cat center.wkt | geom combine | geom draw && open image.png
  • 21. Backtics echo "POINT (10 10)" > point.wkt echo "POINT (0 0)" | geom buffer -d 10 | geom contains -o "`cat point.wkt | geom get -n 0`" false
  • 22. Generate Random Points echo "POINT (1 1)" | geom buffer -d 100 | geom random -n 20 MULTIPOINT ((28.654023089302072 -44.01821817278271), (81.83017489687163 -23.86819073039706), (2.105166479839937 36.12893454538721), (4.227942694802536 -75.42526935983172), (70.36226203781283 55.09734125747187), (-24.57828687972821 40.21049354265716), (43.29398472591029 91.04707992971149), (-10.753927532104086 29.320031764200024), (-81.14902146405959 8.312362640063384), (29.670956290372317 1.1014786268571584), (42.092039630473465 83.01841893953664), (-3.8268655554251154 -33.81236693090035), (-54.61643432275327 -69.03248995687024), (18.216453654179105 -46.68047579703787), (69.16611402164975 31.101723885056686), (-43.36423562242582 -76.70347656510657), (84.68024160811188 -46.630576818012635), (-52.67048441979452 -65.85207992789142), (-82.00381658701411 -14.714381798142469), (72.18321150088343 -60.363316389278076))
  • 23. Random Walk echo "POINT (100 100)" | geom randomwalk -n 100 -a 45 -d 10 | geom draw -c && open image.png
  • 24. Koch Snowflake echo "POINT (1 1)" | geom envelope -e 100 | geom kochsnowflake -n 1000 | geom draw && open image.png
  • 25. Sierpinski Carpet echo "POINT (1 1)" | geom envelope -e 100 | geom sierpinskicarpet -n 1000 | geom draw && open image.png
  • 26. Text geom text -t "Hi" | geom draw -c && open image.png
  • 27. Sine Star echo "POINT (100 100)" | geom sinestar -l 0.9 -n 12 -p 1000 -w 500 -h 500 | geom draw && open image.png
  • 28. Rectangle echo "POINT (100 100)" | geom rectangle -p 30 -w 500 -h 500 | geom draw -c && open image.png
  • 29. Ellipse echo "POINT (100 100)" | geom ellipse -p 30 -w 500 -h 500 | geom draw -c && open image.png
  • 30. Squircle echo "POINT (100 100)" | geom squircle -p 30 -w 500 -h 500 | geom draw -c && open image.png
  • 31. Supercircle echo "POINT (100 100)" | geom supercircle -o 3 -p 100 - w 500 -h 500 | geom draw -c && open image.png
  • 32. Arc echo "POINT (100 100)" | geom arc -a 45 -e 90 -d -p 20 - w 500 -h 500 | geom draw -c && open image.png
  • 33. Arc polygon echo "POINT (100 100)" | geom arcpoly -a 45 -e 90 -d -p 20 -w 500 -h 500 | geom draw -c && open image.png
  • 34. PostgreSQL psql -U postgres -d postgres -c "select St_asText (the_geom) from washington_2927 where fid=5" -t | geom draw && open image.png
  • 35. PostgreSQL psql -U postgres -d postgres -c "select St_asText (st_collect(the_geom)) from washington_2927" -t | geom draw && open image.png
  • 36. PostgreSQL psql -U postgres -d postgres -c "select St_asText (the_geom) from washington_2927" -t | geom combine | geom draw && open image.png
  • 37. GeoScript: convert to kml echo "POINT (1 1)" | geom buffer -d 10 | geoscript- groovy -e "println geoscript.geom.Geometry.fromWKT (System.in.text).kml" <Polygon><outerBoundaryIs><LinearRing><coordinates>11.0,1.0 10.807852804032304,-0.9509032201612824 10.238795325112868,-2.826834323650898 9.314696123025453,-4.555702330196022 8.071067811865476,-6.071067811865475 6.555702330196023,-7.314696123025453 4.826834323650898,-8.238795325112868 2.9509032201612833,-8.807852804032304 1.0000000000000007,-9.0 -0.9509032201612819,-8.807852804032304 -2.826834323650897,-8.238795325112868 -4.55570233019602,-7.314696123025453 -6.071067811865475,-6.0710678118654755 -7.314696123025453,-4.555702330196022 -8.238795325112868,-2.8268343236508944 -8.807852804032306,-0.9509032201612773 -9.0,1.0000000000000075 -8.807852804032303,2.950903220161292 -8.238795325112862,4.826834323650909 -7.3146961230254455,6.555702330196034 -6.071067811865463,8.071067811865486 -4.555702330196008,9.314696123025463 -2.826834323650879,10.238795325112875 -0.9509032201612606,10.807852804032308 1.0000000000000249,11.0 2.950903220161309,10.807852804032299 4.826834323650925,10.238795325112857 6.555702330196048,9.314696123025435 8.071067811865499,8.07106781186545 9.314696123025472,6.555702330195993 10.238795325112882,4.826834323650862 10.807852804032311,2.9509032201612437 11.0,1.0</coordinates></LinearRing></outerBoundaryIs></Polygon>
  • 38. GeoScript: draw shapefile geoscript-groovy -e "println new geoscript.geom.GeometryCollection(new geoscript.layer.Shapefile('states.shp').features.collect {it.geom}).wkt" | geom draw && open image.png
  • 39. GeoScript: write shapefile echo "POINT (1 1)" | geom buffer -d 100 | geom random - n 100 | geoscript-groovy -e "new geoscript.workspace.Directory('.').create(new geoscript.feature.Schema('random', [['the_geom','Point','EPSG:4326']])).add (geoscript.geom.Geometry.fromWKT (System.in.text).geometries.collect{new geoscript.feature.Feature(['the_geom': it],null)})"
  • 40. Geocoding curl "http://geocoder.us/service/csv/geocode?zip=95472" | awk -F ", " '{print "POINT ("$2 " " $1 ")"}' | geom buffer -d 10 | geom draw && open image.png
  • 41. USGS Earthquakes curl http://earthquake.usgs.gov/earthquakes/catalogs/ eqs1day-M2.5.txt | awk -F ',' '{if (NR!=1) {print "POINT ("$8" "$7")"}}' | geom combine | geom draw && open image.png
  • 42. WMS curl -o map.jpg "http://vmap0.tiles.osgeo.org/wms/vmap0? LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetM ap&STYLES=&FORMAT=image%2Fjpeg&SRS=EPSG %3A4326&BBOX=-123.07,46.66,-121.14,47.48&WIDTH=500&HEIG HT=400" echo "POINT (-122.429452 47.125627)" | geom buffer -d 0.2 | geom draw -w 500 -h 400 -e "-123.07,46.66,-121.14,47.48" -i map.jpg && open image.png
  • 43. Install • Install Java • Download • https://github.com/jericks/geometrycommands/ downloads • Put on path • export PATH = /whereever/you/put/it/geom/bin
  • 44. Help • View commands • geom list • Get help on a command • geom buffer --help • Man pages • man geom • man geom-buffer
  • 46. Extend • Create a Java class that implements Command Interface • or extends GeometryCommand • or extends OtherGeometryCommand • Add command line options by creating an Options subclass with Args4J annotations • Java Service Provider Interface • META-INF/services/org.geometrycommands/Command • Add line with the full path (package and class name)