<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sean Gillies (Posts about pipes)</title><link>https://sgillies.net/</link><description></description><atom:link href="https://sgillies.net/tags/pipes.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sun, 31 Dec 2023 01:26:25 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Rasterio 0.15 and a cheat sheet</title><link>https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;Here is what's new in &lt;a class="reference external" href="https://github.com/mapbox/rasterio/blob/master/CHANGES.txt#L4"&gt;Rasterio 0.15&lt;/a&gt;. The biggest
changes are the ones under the hood to permit opening non-TIFF formats in 'r+'
and 'w' modes. The one API change was made to align better with Numpy: any
&lt;code class="docutils literal"&gt;output&lt;/code&gt; keyword args are superceded by &lt;code class="docutils literal"&gt;out&lt;/code&gt; and we warn you about
future removal of &lt;code class="docutils literal"&gt;output&lt;/code&gt;. In the command line programs we're adding &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;-f&lt;/span&gt;&lt;/code&gt; and
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--format&lt;/span&gt;&lt;/code&gt; as preferred aliases for the older &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--driver&lt;/span&gt;&lt;/code&gt; option. We're closing
in on the programming and command line interfaces that will be finalized in 1.0.&lt;/p&gt;
&lt;p&gt;Inspired by Derek Watkins, I've begun a &lt;a class="reference external" href="https://github.com/sgillies/frs-cheat-sheet"&gt;Fiona/Rasterio/Shapely cheat sheet&lt;/a&gt; modeled after his popular
GDAL/OGR command line cheat sheet. It's been a great rubric for identifying the
key features that should be in the Fiona and Rasterio CLIs. It also has fun
examples of &lt;a class="reference external" href="https://github.com/sgillies/frs-cheat-sheet#filter-a-vector-file-in-parallel"&gt;using fio and rio with GNU Parallel, jq, and geojsonio-cli&lt;/a&gt;.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_01e562c30d974e16b115f2f11cf92d5c-1" name="rest_code_01e562c30d974e16b115f2f11cf92d5c-1" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_01e562c30d974e16b115f2f11cf92d5c-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat input.shp --x-json-seq-no-rs &lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_01e562c30d974e16b115f2f11cf92d5c-2" name="rest_code_01e562c30d974e16b115f2f11cf92d5c-2" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_01e562c30d974e16b115f2f11cf92d5c-2"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; parallel --pipe &lt;span class="s2"&gt;"jq -c 'select(.id==\"10\")'"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_01e562c30d974e16b115f2f11cf92d5c-3" name="rest_code_01e562c30d974e16b115f2f11cf92d5c-3" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_01e562c30d974e16b115f2f11cf92d5c-3"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; fio collect &lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_01e562c30d974e16b115f2f11cf92d5c-4" name="rest_code_01e562c30d974e16b115f2f11cf92d5c-4" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_01e562c30d974e16b115f2f11cf92d5c-4"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; geojsonio
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;0.15 features in the cheat sheet include version inspection,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_08881c73355f431095b6c492c038104a-1" name="rest_code_08881c73355f431095b6c492c038104a-1" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_08881c73355f431095b6c492c038104a-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;rio --version
&lt;a id="rest_code_08881c73355f431095b6c492c038104a-2" name="rest_code_08881c73355f431095b6c492c038104a-2" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_08881c73355f431095b6c492c038104a-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;0.15&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;format driver enumeration,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_137c3c30df404712b36c151355167284-1" name="rest_code_137c3c30df404712b36c151355167284-1" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;rio env --formats
&lt;a id="rest_code_137c3c30df404712b36c151355167284-2" name="rest_code_137c3c30df404712b36c151355167284-2" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;AAIGrid: Arc/Info ASCII Grid&lt;/span&gt;
&lt;a id="rest_code_137c3c30df404712b36c151355167284-3" name="rest_code_137c3c30df404712b36c151355167284-3" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-3"&gt;&lt;/a&gt;&lt;span class="go"&gt;ACE2: ACE2&lt;/span&gt;
&lt;a id="rest_code_137c3c30df404712b36c151355167284-4" name="rest_code_137c3c30df404712b36c151355167284-4" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-4"&gt;&lt;/a&gt;&lt;span class="go"&gt;ADRG: ARC Digitized Raster Graphics&lt;/span&gt;
&lt;a id="rest_code_137c3c30df404712b36c151355167284-5" name="rest_code_137c3c30df404712b36c151355167284-5" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-5"&gt;&lt;/a&gt;&lt;span class="go"&gt;AIG: Arc/Info Binary Grid&lt;/span&gt;
&lt;a id="rest_code_137c3c30df404712b36c151355167284-6" name="rest_code_137c3c30df404712b36c151355167284-6" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-6"&gt;&lt;/a&gt;&lt;span class="go"&gt;ARG: Azavea Raster Grid format&lt;/span&gt;
&lt;a id="rest_code_137c3c30df404712b36c151355167284-7" name="rest_code_137c3c30df404712b36c151355167284-7" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-7"&gt;&lt;/a&gt;&lt;span class="go"&gt;AirSAR: AirSAR Polarimetric Image&lt;/span&gt;
&lt;a id="rest_code_137c3c30df404712b36c151355167284-8" name="rest_code_137c3c30df404712b36c151355167284-8" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-8"&gt;&lt;/a&gt;&lt;span class="go"&gt;...&lt;/span&gt;
&lt;a id="rest_code_137c3c30df404712b36c151355167284-9" name="rest_code_137c3c30df404712b36c151355167284-9" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_137c3c30df404712b36c151355167284-9"&gt;&lt;/a&gt;&lt;span class="go"&gt;ZMap: ZMap Plus Grid&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and stacking raster bands to produce new multiband datasets.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_6f14e4ca5afa4b19803287e1cc688d25-1" name="rest_code_6f14e4ca5afa4b19803287e1cc688d25-1" href="https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html#rest_code_6f14e4ca5afa4b19803287e1cc688d25-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;rio stack tests/data/RGB.byte.tif --bidx &lt;span class="m"&gt;1&lt;/span&gt;..3 -o stacked.jpg -f JPEG
&lt;/pre&gt;&lt;/div&gt;</description><category>cli</category><category>fiona</category><category>parallel</category><category>pipes</category><category>rasterio</category><category>unix</category><category>work</category><guid>https://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html</guid><pubDate>Sat, 11 Oct 2014 06:00:00 GMT</pubDate></item><item><title>Unix style spatial ETL with fio cat, collect, and load</title><link>https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html</link><dc:creator>Sean Gillies</dc:creator><description>&lt;p&gt;In Fiona 1.4.0 I added a fio-cat command to the CLI which works much UNIX cat.
It opens one or more vector datastets, concatenating their features and
printing them to stdout as a sequence of GeoJSON features.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-1" name="rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-1" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat docs/data/test_uk.shp &lt;span class="p"&gt;|&lt;/span&gt; head -n &lt;span class="m"&gt;2&lt;/span&gt;
&lt;a id="rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-2" name="rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-2" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;{"geometry": {"coordinates": [...], "type": "Polygon"}, "id": "0", "properties": {"AREA": 244820.0, "CAT": 232.0, "CNTRY_NAME": "United Kingdom", "FIPS_CNTRY": "UK", "POP_CNTRY": 60270708.0}, "type": "Feature"}&lt;/span&gt;
&lt;a id="rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-3" name="rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-3" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3f5eafa7c2fc46ac8f698b6aa97d7424-3"&gt;&lt;/a&gt;&lt;span class="go"&gt;{"geometry": {"coordinates": [...], "type": "Polygon"}, "id": "1", "properties": {"AREA": 244820.0, "CAT": 232.0, "CNTRY_NAME": "United Kingdom", "FIPS_CNTRY": "UK", "POP_CNTRY": 60270708.0}, "type": "Feature"}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I've replaced most of the coordinates with ellipses to save space in the code
block above, something I'll continue to do in examples below.&lt;/p&gt;
&lt;p&gt;I said that fio-cat concatenates features of multiple files and you can see
this by using &lt;code class="docutils literal"&gt;wc &lt;span class="pre"&gt;-l&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_6c265843309349ea934188ccedb97125-1" name="rest_code_6c265843309349ea934188ccedb97125-1" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_6c265843309349ea934188ccedb97125-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat docs/data/test_uk.shp &lt;span class="p"&gt;|&lt;/span&gt; wc -l
&lt;a id="rest_code_6c265843309349ea934188ccedb97125-2" name="rest_code_6c265843309349ea934188ccedb97125-2" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_6c265843309349ea934188ccedb97125-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;      48&lt;/span&gt;
&lt;a id="rest_code_6c265843309349ea934188ccedb97125-3" name="rest_code_6c265843309349ea934188ccedb97125-3" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_6c265843309349ea934188ccedb97125-3"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat docs/data/test_uk.shp docs/data/test_uk.shp &lt;span class="p"&gt;|&lt;/span&gt; wc -l
&lt;a id="rest_code_6c265843309349ea934188ccedb97125-4" name="rest_code_6c265843309349ea934188ccedb97125-4" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_6c265843309349ea934188ccedb97125-4"&gt;&lt;/a&gt;&lt;span class="go"&gt;      96&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you look closely at the output, you'll see that every GeoJSON feature is a
standalone text and each is preceded by an ASCII RS (0x1E) control character.
These allow you to cat pretty-printed GeoJSON (using the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--indent&lt;/span&gt;&lt;/code&gt; option)
containing newlines that can still be understood as a sequence of texts by
other programs. Software like Python's json module and Node's underscore-cli
will trip over unstripped RS, so you can disable the RS control characters and
emit LF delimited sequences of GeoJSON (with no option to pretty print, of
course) using &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--x-json-seq-no-rs&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To complement fio-cat I've written fio-load and fio-collect. They
read features from a sequence (RS or LF delimited) and respectively write them
to a formatted vector file (such as a Shapefile) or print them as a GeoJSON
feature collection.&lt;/p&gt;
&lt;p&gt;Here's an example of using fio-cat and load together. You should tell fio-load
what coordinate reference system to use when writing the output file because
that information isn't carried in the GeoJSON features written by fio-cat.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-1" name="rest_code_faee96aa67a9455983e887f8335412ed-1" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat docs/data/test_uk.shp &lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-2" name="rest_code_faee96aa67a9455983e887f8335412ed-2" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-2"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt; fio load --driver Shapefile --dst_crs EPSG:4326 /tmp/test_uk.shp
&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-3" name="rest_code_faee96aa67a9455983e887f8335412ed-3" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-3"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;ls -l /tmp/test_uk.*
&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-4" name="rest_code_faee96aa67a9455983e887f8335412ed-4" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-4"&gt;&lt;/a&gt;&lt;span class="go"&gt;-rw-r--r--  1 seang  wheel     10 Oct  5 10:09 /tmp/test_uk.cpg&lt;/span&gt;
&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-5" name="rest_code_faee96aa67a9455983e887f8335412ed-5" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-5"&gt;&lt;/a&gt;&lt;span class="go"&gt;-rw-r--r--  1 seang  wheel  11377 Oct  5 10:09 /tmp/test_uk.dbf&lt;/span&gt;
&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-6" name="rest_code_faee96aa67a9455983e887f8335412ed-6" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-6"&gt;&lt;/a&gt;&lt;span class="go"&gt;-rw-r--r--  1 seang  wheel    143 Oct  5 10:09 /tmp/test_uk.prj&lt;/span&gt;
&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-7" name="rest_code_faee96aa67a9455983e887f8335412ed-7" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-7"&gt;&lt;/a&gt;&lt;span class="go"&gt;-rw-r--r--  1 seang  wheel  65156 Oct  5 10:09 /tmp/test_uk.shp&lt;/span&gt;
&lt;a id="rest_code_faee96aa67a9455983e887f8335412ed-8" name="rest_code_faee96aa67a9455983e887f8335412ed-8" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_faee96aa67a9455983e887f8335412ed-8"&gt;&lt;/a&gt;&lt;span class="go"&gt;-rw-r--r--  1 seang  wheel    484 Oct  5 10:09 /tmp/test_uk.shx&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And here's one of fio-cat and collect.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-1" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-1" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat docs/data/test_uk.shp &lt;span class="p"&gt;|&lt;/span&gt; fio collect --indent &lt;span class="m"&gt;4&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; head
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-2" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-2" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-2"&gt;&lt;/a&gt;&lt;span class="go"&gt;{&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-3" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-3" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-3"&gt;&lt;/a&gt;&lt;span class="go"&gt;    "features": [&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-4" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-4" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-4"&gt;&lt;/a&gt;&lt;span class="go"&gt;        {&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-5" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-5" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-5"&gt;&lt;/a&gt;&lt;span class="go"&gt;            "geometry": {&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-6" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-6" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-6"&gt;&lt;/a&gt;&lt;span class="go"&gt;                "coordinates": [&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-7" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-7" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-7"&gt;&lt;/a&gt;&lt;span class="go"&gt;                    [&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-8" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-8" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-8"&gt;&lt;/a&gt;&lt;span class="go"&gt;                        [&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-9" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-9" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-9"&gt;&lt;/a&gt;&lt;span class="go"&gt;                            0.899167,&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-10" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-10" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-10"&gt;&lt;/a&gt;&lt;span class="go"&gt;                            51.357216&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-11" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-11" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-11"&gt;&lt;/a&gt;&lt;span class="go"&gt;                        ],&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-12" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-12" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-12"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat docs/data/test_uk.shp &lt;span class="p"&gt;|&lt;/span&gt; fio collect --indent &lt;span class="m"&gt;4&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tail
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-13" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-13" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-13"&gt;&lt;/a&gt;&lt;span class="go"&gt;                "CAT": 232.0,&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-14" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-14" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-14"&gt;&lt;/a&gt;&lt;span class="go"&gt;                "CNTRY_NAME": "United Kingdom",&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-15" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-15" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-15"&gt;&lt;/a&gt;&lt;span class="go"&gt;                "FIPS_CNTRY": "UK",&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-16" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-16" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-16"&gt;&lt;/a&gt;&lt;span class="go"&gt;                "POP_CNTRY": 60270708.0&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-17" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-17" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-17"&gt;&lt;/a&gt;&lt;span class="go"&gt;            },&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-18" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-18" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-18"&gt;&lt;/a&gt;&lt;span class="go"&gt;            "type": "Feature"&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-19" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-19" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-19"&gt;&lt;/a&gt;&lt;span class="go"&gt;        }&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-20" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-20" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-20"&gt;&lt;/a&gt;&lt;span class="go"&gt;    ],&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-21" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-21" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-21"&gt;&lt;/a&gt;&lt;span class="go"&gt;    "type": "FeatureCollection"&lt;/span&gt;
&lt;a id="rest_code_3647e1f4b50642f6973cd31d9f7f401d-22" name="rest_code_3647e1f4b50642f6973cd31d9f7f401d-22" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_3647e1f4b50642f6973cd31d9f7f401d-22"&gt;&lt;/a&gt;&lt;span class="go"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Does it look like I've simply reinvented ogr2ogr? The difference is that with
fio-cat and fio-load there's space in between for programs that process
features.  The programs could be written in any language. They might use
Shapely, they might use Turf. The only requirement is that they read and write
sequences of GeoJSON features using stdin and stdout. A nice property of
programs like these is that you can sometimes parallelize them cheaply using
&lt;a class="reference external" href="http://www.gnu.org/software/parallel/parallel_tutorial.html#pipe"&gt;GNU parallel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The fio-buffer program (&lt;a class="reference external" href="https://github.com/Toblerity/Fiona/blob/sequence-processing/fiona/fio/ops.py"&gt;unreleased&lt;/a&gt;)
in the example below uses Shapely to calculate a 100 km buffer around features
(in Web Mercator, I know!). Parallel doesn't help in this example because the
sequence of features from fio-cat is fairly small, but I want to show you how
to tell parallel to watch for RS as a record separator.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code console"&gt;&lt;a id="rest_code_fae77df74f83476b8a9498dee728ae5e-1" name="rest_code_fae77df74f83476b8a9498dee728ae5e-1" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_fae77df74f83476b8a9498dee728ae5e-1"&gt;&lt;/a&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;fio cat docs/data/test_uk.shp --dst_crs EPSG:3857 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_fae77df74f83476b8a9498dee728ae5e-2" name="rest_code_fae77df74f83476b8a9498dee728ae5e-2" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_fae77df74f83476b8a9498dee728ae5e-2"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; parallel --pipe --recstart &lt;span class="s1"&gt;'\x1E'&lt;/span&gt; fio buffer 1E+5 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_fae77df74f83476b8a9498dee728ae5e-3" name="rest_code_fae77df74f83476b8a9498dee728ae5e-3" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_fae77df74f83476b8a9498dee728ae5e-3"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; fio collect --src_crs EPSG:3857 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_fae77df74f83476b8a9498dee728ae5e-4" name="rest_code_fae77df74f83476b8a9498dee728ae5e-4" href="https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html#rest_code_fae77df74f83476b8a9498dee728ae5e-4"&gt;&lt;/a&gt;&lt;span class="gp"&gt;&amp;gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt; geojsonio
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here's the result. Unix pipelines, still awesome at the age of &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Pipeline_(Unix)#History"&gt;41&lt;/a&gt;!&lt;/p&gt;
&lt;script src="https://gist.github.com/sgillies/25dbd9a22269446fa40a.js"&gt;
&lt;/script&gt;&lt;p&gt;The other point of this post is that, with the &lt;a class="reference external" href="https://datatracker.ietf.org/doc/draft-ietf-json-text-sequence/"&gt;JSON Text Sequence&lt;/a&gt; draft
apparently going to publication, sequences of GeoJSON features not collected
into a GeoJSON feature collection are very close to being a real thing that
developers should be supporting.&lt;/p&gt;</description><category>etl</category><category>features</category><category>fiona</category><category>geojson</category><category>json</category><category>parallel</category><category>pipes</category><category>unix</category><category>work</category><guid>https://sgillies.net/2014/10/05/unix-style-spatial-etl-with-fio-cat-collect-and-load.html</guid><pubDate>Sun, 05 Oct 2014 06:00:00 GMT</pubDate></item></channel></rss>