Sean Gillies (Posts about cli)https://sgillies.net/tags/cli.atom2023-12-31T01:26:24ZSean GilliesNikolaRasterio 0.15 and a cheat sheethttps://sgillies.net/2014/10/11/rasterio-0-15-and-a-cheat-sheet.html2014-10-11T00:00:00-06:002014-10-11T00:00:00-06:00Sean Gillies<p>Here is what's new in <a class="reference external" href="https://github.com/mapbox/rasterio/blob/master/CHANGES.txt#L4">Rasterio 0.15</a>. 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
<code class="docutils literal">output</code> keyword args are superceded by <code class="docutils literal">out</code> and we warn you about
future removal of <code class="docutils literal">output</code>. In the command line programs we're adding <code class="docutils literal"><span class="pre">-f</span></code> and
<code class="docutils literal"><span class="pre">--format</span></code> as preferred aliases for the older <code class="docutils literal"><span class="pre">--driver</span></code> option. We're closing
in on the programming and command line interfaces that will be finalized in 1.0.</p>
<p>Inspired by Derek Watkins, I've begun a <a class="reference external" href="https://github.com/sgillies/frs-cheat-sheet">Fiona/Rasterio/Shapely cheat sheet</a> 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 <a class="reference external" href="https://github.com/sgillies/frs-cheat-sheet#filter-a-vector-file-in-parallel">using fio and rio with GNU Parallel, jq, and geojsonio-cli</a>.</p>
<div class="code"><pre class="code console"><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"></a><span class="gp">$ </span>fio cat input.shp --x-json-seq-no-rs <span class="se">\</span>
<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"></a><span class="gp">> </span><span class="p">|</span> parallel --pipe <span class="s2">"jq -c 'select(.id==\"10\")'"</span> <span class="se">\</span>
<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"></a><span class="gp">> </span><span class="p">|</span> fio collect <span class="se">\</span>
<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"></a><span class="gp">> </span><span class="p">|</span> geojsonio
</pre></div>
<p>0.15 features in the cheat sheet include version inspection,</p>
<div class="code"><pre class="code console"><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"></a><span class="gp">$ </span>rio --version
<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"></a><span class="go">0.15</span>
</pre></div>
<p>format driver enumeration,</p>
<div class="code"><pre class="code console"><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"></a><span class="gp">$ </span>rio env --formats
<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"></a><span class="go">AAIGrid: Arc/Info ASCII Grid</span>
<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"></a><span class="go">ACE2: ACE2</span>
<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"></a><span class="go">ADRG: ARC Digitized Raster Graphics</span>
<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"></a><span class="go">AIG: Arc/Info Binary Grid</span>
<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"></a><span class="go">ARG: Azavea Raster Grid format</span>
<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"></a><span class="go">AirSAR: AirSAR Polarimetric Image</span>
<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"></a><span class="go">...</span>
<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"></a><span class="go">ZMap: ZMap Plus Grid</span>
</pre></div>
<p>and stacking raster bands to produce new multiband datasets.</p>
<div class="code"><pre class="code console"><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"></a><span class="gp">$ </span>rio stack tests/data/RGB.byte.tif --bidx <span class="m">1</span>..3 -o stacked.jpg -f JPEG
</pre></div>