Skip to content

Commit

Permalink
small update Austin on jq
Browse files Browse the repository at this point in the history
  • Loading branch information
defuneste committed Aug 8, 2024
1 parent 69a55cb commit b167bb5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ <h3 class="no-anchor listing-title">
</a>
</div>
</div>
<div class="quarto-post image-right" data-index="4" data-categories="cli,code,geojson,json,spatial data" data-listing-date-sort="1710046800000" data-listing-file-modified-sort="1718032829661" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="5" data-listing-word-count-sort="986">
<div class="quarto-post image-right" data-index="4" data-categories="cli,code,geojson,json,spatial data" data-listing-date-sort="1710046800000" data-listing-file-modified-sort="1723129180185" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="5" data-listing-word-count-sort="983">
<div class="thumbnail">
<p><a href="./posts/awesomejq/index.html" class="no-external"></a></p><a href="./posts/awesomejq/index.html" class="no-external">
<p><img src="./posts/awesomejq/thumbnail.png" class="thumbnail-image"></p>
Expand All @@ -325,7 +325,7 @@ <h3 class="no-anchor listing-title">
<a href="./posts/awesomejq/index.html" class="no-external"></a>
</div>
<div class="listing-description">
<a href="./posts/awesomejq/index.html" class="no-external">If you are manipulating a lot of <code>GeoJSON</code> features/objects and want a quick CLI tool to filter and slice them, you should give <code>jq</code> a try! Since there are not many tutorials…<code></code><code></code></a>
<a href="./posts/awesomejq/index.html" class="no-external">If you are manipulating a lot of <code>GeoJSON</code> eatures/objects and want a quick CLI tool to filter and slice them, you should give jq a try! Since there are not many tutorials…</a>
</div>
</div>
<div class="metadata">
Expand Down
8 changes: 4 additions & 4 deletions docs/posts/awesomejq/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h2 id="toc-title">On this page</h2>



<p>If you are manipulating a lot of <a href="https://en.wikipedia.org/wiki/GeoJSON"><code>GeoJSON</code></a> features/objects and want a quick CLI tool to filter and slice them, you should give <code>jq</code> a try! Since there are not many tutorials that exist on using <code>jq</code> to manage objects in the <code>GeoJSON</code> family, we hope that these few tricks will help you on your leaning journey.</p>
<p>If you are manipulating a lot of <a href="https://en.wikipedia.org/wiki/GeoJSON"><code>GeoJSON</code></a> eatures/objects and want a quick CLI tool to filter and slice them, you should give jq a try! Since there are not many tutorials that exist on using jq to manage objects in the GeoJSON family, we hope that these few tricks will help you on your learning journey.</p>
<!-- You can find plenty of great guides online, but the [documentation](https://jqlang.github.io/jq/manual/) and the [playground](https://jqplay.org/) are always a good start. -->
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
Expand All @@ -211,15 +211,15 @@ <h2 id="toc-title">On this page</h2>
<p>We are using a UNIX shell to run commands (zsh). If you are using powershell, you will need to adapt the following examples accordingly.</p>
</div>
</div>
<p>In these examples, we are using a GeoJSON file of Vermont Census Blocks with attributes related to our work on broadband data. While it is not a deeply nested JSON, it is perfect to illustrate some common use cases.</p>
<p>In these examples, we are using a GeoJSON file of Vermont census blocks with attributes related to our work on broadband data. While it is not a deeply nested JSON, it is perfect to illustrate some common use cases.</p>
<p>A quick check lets us know that it is 94 MB. Not “that” big but still decent.</p>
<p>First, lets see how many features it has. Here’s how we can approximate that:</p>
<p>First, let’s see how many features it has. Here’s how we can approximate that:</p>
<!--
TODO: should we consider using a geojson from just census?
-->
<div class="sourceCode" id="cb1"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">wc</span> <span class="at">-l</span> data/vt-bb.geojson</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co"># 24618 data/vt-bb.geojson</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>This is a decent estimate, but we are counting some rows at the top and bottom of the file that are not features (try <code>head -n 5</code> and <code>tail</code> on it if you are curious).</p>
<p>This is a decent estimate, but we are counting some rows at the top and bottom of the file that are not features (try head -n 5 and tail on it if you are curious).</p>
<p>We can also use <code>jq</code>:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">jq</span> <span class="st">'.features | length'</span> data/vt-bb.geojson</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># 24611</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
Expand Down
2 changes: 1 addition & 1 deletion docs/posts/mapping_rural_tips/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ <h3 class="anchored" data-anchor-id="consider-non-map-alternatives">6. Consider
});
</script>
</div> <!-- /content -->
<script>var lightboxQuarto = GLightbox({"openEffect":"zoom","selector":".lightbox","closeEffect":"zoom","loop":false,"descPosition":"bottom"});
<script>var lightboxQuarto = GLightbox({"loop":false,"descPosition":"bottom","selector":".lightbox","openEffect":"zoom","closeEffect":"zoom"});
window.onload = () => {
lightboxQuarto.on('slide_before_load', (data) => {
const { slideIndex, slideNode, slideConfig, player, trigger } = data;
Expand Down
6 changes: 3 additions & 3 deletions docs/posts/micropolitan_formd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ <h1 class="title">The top 10 micropolitan areas for raising venture capital</h1>
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: flex-start;">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="images/top10_total_vc_micropolitans.png" class="lightbox" data-gallery="quarto-lightbox-gallery-1" data-glightbox="description: .lightbox-desc-1" title="Micro VC totals (click chart to enlarge)"><img src="images/top10_total_vc_micropolitans.png" class="img-fluid figure-img" alt="Micro VC totals (click chart to enlarge)"></a></p>
<p><a href="images/top10_total_vc_micropolitans.png" class="lightbox" data-glightbox="description: .lightbox-desc-1" data-gallery="quarto-lightbox-gallery-1" title="Micro VC totals (click chart to enlarge)"><img src="images/top10_total_vc_micropolitans.png" class="img-fluid figure-img" alt="Micro VC totals (click chart to enlarge)"></a></p>
<figcaption>Micro VC totals (click chart to enlarge)</figcaption>
</figure>
</div>
</div>
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: flex-start;">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><a href="images/top10_vc_micropolitans.png" class="lightbox" data-gallery="quarto-lightbox-gallery-2" data-glightbox="description: .lightbox-desc-2" title="Micro VC chart (click chart to enlarge)"><img src="images/top10_vc_micropolitans.png" class="img-fluid figure-img" alt="Micro VC chart (click chart to enlarge)"></a></p>
<p><a href="images/top10_vc_micropolitans.png" class="lightbox" data-glightbox="description: .lightbox-desc-2" data-gallery="quarto-lightbox-gallery-2" title="Micro VC chart (click chart to enlarge)"><img src="images/top10_vc_micropolitans.png" class="img-fluid figure-img" alt="Micro VC chart (click chart to enlarge)"></a></p>
<figcaption>Micro VC chart (click chart to enlarge)</figcaption>
</figure>
</div>
Expand Down Expand Up @@ -618,7 +618,7 @@ <h1 class="title">The top 10 micropolitan areas for raising venture capital</h1>
});
</script>
</div> <!-- /content -->
<script>var lightboxQuarto = GLightbox({"closeEffect":"zoom","selector":".lightbox","openEffect":"zoom","loop":false,"descPosition":"bottom"});
<script>var lightboxQuarto = GLightbox({"openEffect":"zoom","closeEffect":"zoom","loop":false,"selector":".lightbox","descPosition":"bottom"});
window.onload = () => {
lightboxQuarto.on('slide_before_load', (data) => {
const { slideIndex, slideNode, slideConfig, player, trigger } = data;
Expand Down
2 changes: 1 addition & 1 deletion docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"href": "posts/awesomejq/index.html",
"title": "Awesome jq and GeoJSON",
"section": "",
"text": "If you are manipulating a lot of GeoJSON features/objects and want a quick CLI tool to filter and slice them, you should give jq a try! Since there are not many tutorials that exist on using jq to manage objects in the GeoJSON family, we hope that these few tricks will help you on your leaning journey.\nIn these examples, we are using a GeoJSON file of Vermont Census Blocks with attributes related to our work on broadband data. While it is not a deeply nested JSON, it is perfect to illustrate some common use cases.\nA quick check lets us know that it is 94 MB. Not “that” big but still decent.\nFirst, lets see how many features it has. Here’s how we can approximate that:\nThis is a decent estimate, but we are counting some rows at the top and bottom of the file that are not features (try head -n 5 and tail on it if you are curious).\nWe can also use jq:\nThis is the correct number of blocks! How did that magic work? Let’s decompose our one-liner:"
"text": "If you are manipulating a lot of GeoJSON eatures/objects and want a quick CLI tool to filter and slice them, you should give jq a try! Since there are not many tutorials that exist on using jq to manage objects in the GeoJSON family, we hope that these few tricks will help you on your learning journey.\nIn these examples, we are using a GeoJSON file of Vermont census blocks with attributes related to our work on broadband data. While it is not a deeply nested JSON, it is perfect to illustrate some common use cases.\nA quick check lets us know that it is 94 MB. Not “that” big but still decent.\nFirst, let’s see how many features it has. Here’s how we can approximate that:\nThis is a decent estimate, but we are counting some rows at the top and bottom of the file that are not features (try head -n 5 and tail on it if you are curious).\nWe can also use jq:\nThis is the correct number of blocks! How did that magic work? Let’s decompose our one-liner:"
},
{
"objectID": "posts/awesomejq/index.html#jq-and-small-examples",
Expand Down
14 changes: 7 additions & 7 deletions posts/awesomejq/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ categories: [cli, code, geojson, json, spatial data]
image: thumbnail.png
---

If you are manipulating a lot of [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) features/objects and want a quick CLI tool to filter and slice them, you should give `jq` a try!
Since there are not many tutorials that exist on using `jq` to manage objects in the `GeoJSON` family, we hope that these few tricks will help you on your leaning journey.
If you are manipulating a lot of [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) eatures/objects and want a quick CLI tool to filter and slice them, you should give jq a try!
Since there are not many tutorials that exist on using jq to manage objects in the GeoJSON family, we hope that these few tricks will help you on your learning journey.

<!-- You can find plenty of great guides online, but the [documentation](https://jqlang.github.io/jq/manual/) and the [playground](https://jqplay.org/) are always a good start. -->

Expand All @@ -17,11 +17,11 @@ Since there are not many tutorials that exist on using `jq` to manage objects in
We are using a UNIX shell to run commands (zsh). If you are using powershell, you will need to adapt the following examples accordingly.
:::

In these examples, we are using a GeoJSON file of Vermont Census Blocks with attributes related to our work on broadband data. While it is not a deeply nested JSON, it is perfect to illustrate some common use cases.
In these examples, we are using a GeoJSON file of Vermont census blocks with attributes related to our work on broadband data. While it is not a deeply nested JSON, it is perfect to illustrate some common use cases.

A quick check lets us know that it is 94 MB. Not "that" big but still decent.
A quick check lets us know that it is 94 MB. Not that big but still decent.

First, lets see how many features it has. Here's how we can approximate that:
First, let's see how many features it has. Heres how we can approximate that:

<!--
TODO: should we consider using a geojson from just census?
Expand All @@ -32,7 +32,7 @@ wc -l data/vt-bb.geojson
# 24618 data/vt-bb.geojson
```

This is a decent estimate, but we are counting some rows at the top and bottom of the file that are not features (try `head -n 5` and `tail` on it if you are curious).
This is a decent estimate, but we are counting some rows at the top and bottom of the file that are not features (try head -n 5 and tail on it if you are curious).

We can also use `jq`:

Expand All @@ -41,7 +41,7 @@ jq '.features | length' data/vt-bb.geojson
# 24611
```

This is the correct number of blocks! How did that magic work? Let's decompose our one-liner:
This is the correct number of blocks! How did that magic work? Lets decompose our one-liner:

- `jq` here we are calling jq like any other CLI tool

Expand Down

0 comments on commit b167bb5

Please sign in to comment.