<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://blog.geothings.ch/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https://blog.geothings.ch</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>
            This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader. Visit About Feeds to learn more and get started. It's free.
        </tabi:about_feeds>
        <tabi:visit_the_site>
            Visit website
        </tabi:visit_the_site>
        <tabi:recent_posts>
            Recent posts
        </tabi:recent_posts>
        <tabi:last_updated_on>
            Updated on $DATE
        </tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>fme</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://blog.geothings.ch/skins/mint.css?h=504215cf6bc10586b487" /><title>geothings - fme</title>
        <subtitle>spatial data | open source | oversharing</subtitle>
    <link href="https://blog.geothings.ch/tags/fme/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://blog.geothings.ch/tags/fme/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2024-08-16T00:00:00+00:00</updated><id>https://blog.geothings.ch/tags/fme/atom.xml</id><entry xml:lang="en">
        <title>FME is getting expensive? Stop using it</title>
        <published>2024-08-16T00:00:00+00:00</published>
        <updated>2024-08-16T00:00:00+00:00</updated>
        <author>
            <name>jujube</name>
        </author>
        <link rel="alternate" href="https://blog.geothings.ch/blog/stop-using-fme/" type="text/html"/>
        <id>https://blog.geothings.ch/blog/stop-using-fme/</id>
        
            <content type="html">&lt;p&gt;I have trouble finding what happened at Safe Software at the beginning of 2024, but it seems that part of the company has been &lt;a rel=&quot;external&quot; href=&quot;https://betakit.com/us-based-jmi-equity-buys-out-safe-software-co-founder-in-strategic-investment/&quot;&gt;sold to an equity firm&lt;/a&gt;. No comment on that, but since then licenses prices seem to have taken a hit and customers are.. Well not very happy, especially regarding the communication around this increase:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://community.safe.com/integration-8/views-on-recent-fme-price-changes-34403&quot;&gt;Views on recent FME price changes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://www.reddit.com/r/fme/comments/1e1bijf/safe_is_an_unreliable_partner/&quot;&gt;Safe is an unreliable partner&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://www.reddit.com/r/fme/comments/13jl6dj/is_a_small_services_consultancy_using_fme_still/&quot;&gt;Is a small services consultancy using FME still viable? Sensible?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://www.reddit.com/r/gis/comments/12trnzg/i_am_hearing_rumors_of_an_extreme_price_jump_for/&quot;&gt;[…]rumors of an extreme price jump[]…&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Costs become unbearable for some companies and the look for alternatives is now a necessity. What can we do about it?&lt;/p&gt;
&lt;h2 id=&quot;about-fme-and-safe&quot;&gt;About FME and Safe&lt;/h2&gt;
&lt;p&gt;In itself I don’t have anything against FME, it does its job and if it allows more people to work with spatial data and create workflows then it’s cool. But there are things that I find, if not unacceptable, at least not very wise, and it’s not always Safe responsibility.&lt;/p&gt;
&lt;h3 id=&quot;safe-as-a-company&quot;&gt;Safe as a company&lt;/h3&gt;
&lt;p&gt;I never had to negotiate any license or contract with Safe, but people around me always seemed happy about their relation with their resellers and the flexibility that was allowed with their licenses. There was no problem having a home/student license for free if you wanted to fiddle around with FME and prices were rather stable.&lt;/p&gt;
&lt;p&gt;The rebranding and the sell at the beginning of 2024 has changed things, and some of the trust seems to be lost. The big problem is the way the company communicated the changes, which was apparently by giving no clear information. Increasing prices (reasonably) could hardly be considered a problem, that’s the world we’ve chosen, but at least having some transparency about it maintains the relation between seller and buyer. If you receive a x3 bill with a “go f“ck yourself if not happy”, this is at best disrespectful, at worst belittling, especially if you can’t act against this. And to me, &lt;strong&gt;the best answer to give is to gain independence and stop buying&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;fme-as-a-software&quot;&gt;FME as a software&lt;/h3&gt;
&lt;p&gt;As I said, I don’t have anything against FME itself. It makes workflows easy to create and push to production, (spatial) data processing accessible to a broader audience and gives you time to focus on something else if you have a GIS role in your company (see &lt;a rel=&quot;external&quot; href=&quot;https://www.geothings.ch/posts/on-gis/&quot;&gt;On GIS and their integration&lt;/a&gt; for that part of the problem). But making yourself totally dependant on a proprietary solution, with a near monopoly on the field, &lt;strong&gt;IS&lt;/strong&gt; a big problem, and honestly felt like a matter of time before it would happen. The situation is so problematic that some high level administrations (country level) are now negotiating terms with Safe because they are so dependant on FME that they can’t move easily from it, and will have no choice but to take the price hit if they don’t act. And maybe it’s common practice, I wouldn’t say I have enough experience to understand those kinds of negotiations, but it feels wrong.&lt;/p&gt;
&lt;p&gt;That’s were &lt;strong&gt;digital sovereignty&lt;/strong&gt; enter the game, regaining control over our processes, data, and costs. Some links :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://access.archive-ouverte.unige.ch/access/metadata/bbf62d17-891e-46e4-bde8-5666dda99237/download&quot;&gt;Digital Sovereignty in Switzerland : the laboratory of federalism&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://framasoft.org/en/&quot;&gt;Framasoft&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you work extensively with FME, I’d advise to take a step back and and have a look at what you need and how you could achieve this any other way, because most of the time, there are options, but we just don’t see them anymore. FME has become such an automatism that everything else is a blur, and worst, we lose skills and control.&lt;/p&gt;
&lt;h2 id=&quot;what-alternatives-are-there&quot;&gt;What alternatives are there?&lt;/h2&gt;
&lt;p&gt;The first step is to have a look at what you need to achieve. Let’s see how FME defines itself from their website:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Expansive Data Solutions → well it doesn’t mean anything so next.&lt;/li&gt;
&lt;li&gt;Data Transformation → Ok noted&lt;/li&gt;
&lt;li&gt;Entreprise Automation → Ok noted&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So we get data transformation and automation. Good.&lt;/p&gt;
&lt;h3 id=&quot;read-write-and-data-transformation&quot;&gt;Read, Write and Data transformation&lt;/h3&gt;
&lt;p&gt;Let’s start with the main reason for all of this. We read, transform and write data to solve problems and answer questions. Data need to be shaped into different models and linked with other data to bring additional knowledge. But how do we do that?&lt;/p&gt;
&lt;h4 id=&quot;transform-with-sql&quot;&gt;Transform with SQL&lt;/h4&gt;
&lt;p&gt;If you’re working with databases (PostgreSQL, MariaDB or even Oracle), you’re probably aware of their spatial capabilities. To me, SQL is a major skill, you can do &lt;strong&gt;a lot&lt;/strong&gt; with a single SQL query. There is even a chance that your FME workspace can be entirely replaced by a single SQL query.&lt;/p&gt;
&lt;p&gt;Now we want to Extract, Transform and Load data. Hum but wait, who said you can’t “transform” your data before even reading it? SQL allows you to do that; write your query, save it as a &lt;em&gt;view&lt;/em&gt; if you wish, and you have your result ready to be read, in sync with your tables.&lt;/p&gt;
&lt;p&gt;Let’s say you have &lt;em&gt;regions&lt;/em&gt; (polygons), &lt;em&gt;roads&lt;/em&gt; (lines) and &lt;em&gt;bus stops&lt;/em&gt; (points), and you want:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;road&lt;/em&gt; cut into portions by &lt;em&gt;region&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;road&lt;/em&gt; portions length&lt;/li&gt;
&lt;li&gt;to count &lt;em&gt;bus stops&lt;/em&gt; on each &lt;em&gt;road&lt;/em&gt; portion
&lt;ul&gt;
&lt;li&gt;if a &lt;em&gt;road&lt;/em&gt; has no &lt;em&gt;bus stop&lt;/em&gt; you want to have “No bus stop” instead of 0&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;an attribute that says “Hopp Schwiiz !” if the &lt;em&gt;road&lt;/em&gt; portion is located in a &lt;em&gt;region&lt;/em&gt; where attribute &lt;em&gt;name&lt;/em&gt; is equal to “Switzerland”, else “Oh, no Hopp Schwiitz…”.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You could have a FME workspace chaining writers, a clipper, a length calculator, aggregators, attributes managers etc. Or a single SQL query in the following manner (optimization not included):&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;SELECT&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    portion.name,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;    CASE&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; COUNT&lt;/span&gt;&lt;span&gt;(b.id) &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        WHEN&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; THEN&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;#39;No bus stop&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        ELSE&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; COUNT&lt;/span&gt;&lt;span&gt;(b.id)::&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;    END AS&lt;/span&gt;&lt;span&gt; n_bus_stop,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;    CASE&lt;/span&gt;&lt;span&gt; portion.name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        WHEN&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;#39;Switzerland&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; THEN&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;#39;Hopp Schwiiz !&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        ELSE&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;#39;Oh, no Hopp Schwiitz...&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;    END AS&lt;/span&gt;&lt;span&gt; hop_suisse,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    St_Length(portion.geom) &lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;AS&lt;/span&gt;&lt;span&gt; portion_length,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    portion.geom&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;FROM&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;SELECT&lt;/span&gt;&lt;span&gt; r.name, St_Intersection(l.geom, r.geom) &lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;AS&lt;/span&gt;&lt;span&gt; geom&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        FROM&lt;/span&gt;&lt;span&gt; road l&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;        JOIN&lt;/span&gt;&lt;span&gt; region r &lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;ON&lt;/span&gt;&lt;span&gt; St_Intersects(l.geom, r.geom)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ) portion&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;LEFT JOIN&lt;/span&gt;&lt;span&gt; bus_stop b &lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt;ON&lt;/span&gt;&lt;span&gt; St_Intersects(portion.geom, b.geom)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;GROUP BY&lt;/span&gt;&lt;span&gt; portion.name, portion.geom&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that’s it, you can read this data, export it, do whatever you want with it. Everything done within the query is visible at once, and if it takes some time to get used to the syntax and be comfortable with it, it becomes much easier to understand what happens in a well written SQL query than in the tidiest FME workspace (personal opinion included).&lt;/p&gt;
&lt;p&gt;Another huge advantage of working with SQL is that you’re closer to a standard &lt;strong&gt;interoperable&lt;/strong&gt; format (with a grain of salt since we use Postgis here, which is Postgres specific). If you ever need to change your system, the required effort to make the conversion will be minimal compared to translating a FME workspace.&lt;/p&gt;
&lt;p&gt;You can import other data into your database to use it in your query, or use &lt;a rel=&quot;external&quot; href=&quot;https://www.postgresql.org/docs/current/postgres-fdw.html&quot;&gt;Foreign Data Wrappers&lt;/a&gt; (FDW) to read data from another database. You can combine your queries with tools such as &lt;a rel=&quot;external&quot; href=&quot;https://docs.getdbt.com/&quot;&gt;dbt&lt;/a&gt; (Core) to have a more complete environment, or build your own processes, with GDAL or using the programming language of your choice.&lt;/p&gt;
&lt;h4 id=&quot;read-and-write-with-gdal&quot;&gt;Read and write with GDAL&lt;/h4&gt;
&lt;p&gt;Back at it with &lt;a rel=&quot;external&quot; href=&quot;https://www.geothings.ch/posts/gdal-appreciation/&quot;&gt;GDAL&lt;/a&gt;, but it’s so versatile that it has to be in your toolkit. Your can read and write basically any format, and apply transformations on the fly.&lt;/p&gt;
&lt;p&gt;The series of command line tools that come with GDAL/OGR make it very complete and easy to use with raster or vector data.&lt;/p&gt;
&lt;p&gt;You could reuse your previous SQL query with GDAL to extract your data and save it in GeoPackage for example. I could just save my query into a file named &lt;code&gt;query_file.sql&lt;/code&gt; and run the following command:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogr2ogr&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -f GPKG -sql @query_file.sql output.gpkg &amp;quot;PG:service=input_db&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remember &lt;strong&gt;interoperability&lt;/strong&gt;? Well that’s a nice example, have one standard way of solving a problem and you can connect it with other without changing anything. &lt;strong&gt;You have many possibilities&lt;/strong&gt;.&lt;/p&gt;
&lt;h4 id=&quot;do-everything-with-python-libraries&quot;&gt;Do everything with (Python) libraries&lt;/h4&gt;
&lt;p&gt;There are a bunch of libraries allowing you to read, transform and write data, using Python but not only. GDAL (omfg again) is also available in many languages through its bindings. If we focus on Python, a list (non-exhaustive of course) of libraries for working with spatial data:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://shapely.readthedocs.io/en/stable/manual.html&quot;&gt;Shapely&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://geopandas.org/en/stable/index.html&quot;&gt;geopandas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://fiona.readthedocs.io/en/latest/index.html&quot;&gt;Fiona&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://xarray-spatial.readthedocs.io/en/latest/#&quot;&gt;xarray-spatial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://rasterio.readthedocs.io/en/latest/index.html#&quot;&gt;rasterio&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let’s try somethings with &lt;code&gt;geopandas&lt;/code&gt;. If we consider that we are working with a single PostgreSQL database, we could reuse our earlier query to read the data and save it as a GeoPackage:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;import&lt;/span&gt;&lt;span&gt; geopandas&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; as&lt;/span&gt;&lt;span&gt; gpd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;from&lt;/span&gt;&lt;span&gt; sqlalchemy&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; import&lt;/span&gt;&lt;span&gt; create_engine&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; run&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;():&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Connection&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    db_connection_url&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;postgresql://username:password@localhost/dbname&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    con&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; create_engine&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;db_connection_url&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Open query file, apply and save&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;    with&lt;/span&gt;&lt;span class=&quot;z-14 z-i&quot;&gt; open&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;query.sql&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; as&lt;/span&gt;&lt;span&gt; f&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        query&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;f&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;readlines&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        df&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; gpd&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;read_postgis&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;query&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span&gt; con&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        df&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;to_file&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;my_analysis.gpkg&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; layer&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;result&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; driver&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;GPKG&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;        # Print the head for good measure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-14 z-i&quot;&gt;        print&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;df&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span&gt;head&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;if&lt;/span&gt;&lt;span&gt; __name__&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;__main__&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;    run&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Will create a new file with your result saved in the &lt;code&gt;result&lt;/code&gt; layer. It should also print something like:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0       France            2  Oh, no Hopp Schwiitz...      823.126128  LINESTRING (2537525.502 1152634.769, 2537254.4...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1       France            1  Oh, no Hopp Schwiitz...      118.753415  LINESTRING (2537290.714 1152264.433, 2537281.7...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;2        Italy  No bus stop  Oh, no Hopp Schwiitz...      686.494161  LINESTRING (2538145.102 1151496.452, 2538283.1...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;3  Switzerland  No bus stop           Hopp Schwiiz !      123.440260  LINESTRING (2536930.949 1152095.427, 2536884.0...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;4  Switzerland            1           Hopp Schwiiz !     1102.779141  LINESTRING (2537281.727 1152146.02, 2537249.56...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;5  Switzerland            1           Hopp Schwiiz !      206.632320  LINESTRING (2538019.283 1151332.542, 2538145.1...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;6  Switzerland  No bus stop           Hopp Schwiiz !     1207.518986  LINESTRING (2537677.993 1151998.178, 2537874.0...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That was easy enough but we didn’t bring much since everything is done with SQL again. Let’s do the same thing but only using &lt;code&gt;geopandas&lt;/code&gt; capabilities:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;import&lt;/span&gt;&lt;span&gt; geopandas&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; as&lt;/span&gt;&lt;span&gt; gpd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;from&lt;/span&gt;&lt;span&gt; sqlalchemy&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; import&lt;/span&gt;&lt;span&gt; create_engine&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; run&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;():&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Connection&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    db_connection_url&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;postgresql://username:password@localhost/dbname&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    con&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; create_engine&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;db_connection_url&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Read roads, regions and bus_stops&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    roads&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; gpd&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;read_postgis&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;road&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span&gt; con&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    regions&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; gpd&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;read_postgis&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;region&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span&gt; con&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    bus_stops&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; gpd&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;read_postgis&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;bus_stop&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span&gt; con&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Intersection&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    intersection&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; roads&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;overlay&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;regions&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; how&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;intersection&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Intersect bus stops&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    intersect&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; intersection&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;sjoin&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;bus_stops&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; how&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;left&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; predicate&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;intersects&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Group by&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    groupby&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; intersect&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;groupby&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;geometry&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;]).&lt;/span&gt;&lt;span&gt;id&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    output&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; groupby&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;reset_index&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;n_bus_stop&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Hop Suisse&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12 z-i&quot;&gt;    output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;hop_suisse&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;Hopp Schwiiz !&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; !=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;Switzerland&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;hop_suisse&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-7&quot;&gt;        &amp;quot;Oh, no Hopp Schwiitz...&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # No bus stop&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;n_bus_stop&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-14 z-i&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;hop_suisse&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;No bus stop&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Lost the Geo from GeoDataFrame at some point &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    output&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span&gt; gpd&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;GeoDataFrame&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span&gt;output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; geometry&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;geometry&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;    # Length&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12 z-i&quot;&gt;    output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;portion_length&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7 z-i&quot;&gt;geometry&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;].&lt;/span&gt;&lt;span&gt;length&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    output&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;to_file&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;my_analysis.gpkg&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; layer&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;result_only_gpd&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-12 z-i&quot;&gt; driver&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;&amp;quot;GPKG&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-9&quot;&gt;if&lt;/span&gt;&lt;span&gt; __name__&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; ==&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;__main__&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;    run&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Doesn’t take much more. &lt;code&gt;Roads&lt;/code&gt;, &lt;code&gt;regions&lt;/code&gt; and &lt;code&gt;bus_stops&lt;/code&gt; could have been data from anywhere: another database, a csv file, a cloud hosted file, etc.&lt;/p&gt;
&lt;p&gt;Working with a programming language allows you to easily read multiple data sources and combine them using your custom “transformers”, which will basically be functions that you would have written and tailored to your need.&lt;/p&gt;
&lt;p&gt;But now let’s see what you can do to automate your process.&lt;/p&gt;
&lt;h3 id=&quot;automation&quot;&gt;Automation&lt;/h3&gt;
&lt;p&gt;Not sure about what is so incredible about giving scheduling capabilities within FME when &lt;a rel=&quot;external&quot; href=&quot;https://en.wikipedia.org/wiki/Cron&quot;&gt;&lt;code&gt;cron&lt;/code&gt;&lt;/a&gt; is available by default in many Linux distributions. If you’re working on Windows you can also schedule things with the &lt;code&gt;Task Scheduler&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I feel like I’m oversimplifying things but I can’t see where. If you’re on Linux, you can schedule your data export task by adding such lines into your &lt;code&gt;crontab&lt;/code&gt; (&lt;code&gt;crontab -e&lt;/code&gt; to edit it):&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-4 z-i&quot;&gt;# Everyday at 05:00&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;00&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 5&lt;/span&gt;&lt;span&gt; * * *&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;  ogr2ogr -f GPKG -sql @query_file.sql output.gpkg &amp;quot;PG:service=input_db&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run the task and send an email if it failed?&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;00&lt;/span&gt;&lt;span class=&quot;z-14&quot;&gt; 5&lt;/span&gt;&lt;span&gt; * * *&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;  if ! ogr2ogr -f GPKG -sql @query_file.sql output.gpkg &amp;quot;PG:service=input_db&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; then&lt;/span&gt;&lt;span class=&quot;z-11 z-i&quot;&gt; echo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; &amp;quot;your export failed&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-1&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-3 z-i&quot;&gt; mail&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -s &amp;quot;failing process&amp;quot; address@mail.me&lt;/span&gt;&lt;span class=&quot;z-4&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;z-9&quot;&gt; fi&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that’s it. I doubt that FME brings so much on the table when it comes to scheduling tasks.&lt;/p&gt;
&lt;h3 id=&quot;and-that-s-it&quot;&gt;And that’s it?&lt;/h3&gt;
&lt;p&gt;I guess not, but I don’t think we will find many operations that are totally unfeasible without FME. If I’m missing something, please don’t hesitate to correct me.&lt;/p&gt;
&lt;h2 id=&quot;limitations&quot;&gt;Limitations&lt;/h2&gt;
&lt;p&gt;Unfortunately, there are some things that I don’t know how to do without FME, well at least one that I have no idea how to solve.&lt;/p&gt;
&lt;h3 id=&quot;dwg-and-the-closed-formats-problem&quot;&gt;DWG and the closed formats problem&lt;/h3&gt;
&lt;p&gt;DWGs are ***** everywhere when your have people doing CAD around you. They could use DXF, which is an open source equivalent, but no, AutoCAD then DWG (which is no data btw, it’s just lines ffs). And I have no clue how to tackle that, except through a long process of mentality change around the tools used.&lt;/p&gt;
&lt;p&gt;Earlier we saw that using standard formats can start a virtuous cycle, where you keep open the door for many solution to solve your problems. Well here we have the opposite, closed formats reduce the interoperability by making a handful of solutions your only options, and keep you from trying other things. If you need to have DWGs, then to my knowledge, FME becomes the only tool you can use to produce them programmatically from other data (even GDAL can’t all hope is lost). So from one license, you need “automatically” two.&lt;/p&gt;
&lt;p&gt;And then one company decide to increase there prices, and there is nothing you can do about it.&lt;/p&gt;
&lt;p&gt;In this case, the problem is to use a closed data format. To change that is to change deeply the habits of people using the tool creating this format, because, like with FME, there is a real addiction to the software. The skill becomes the software; not the technic, not the knowledge around the field, but just the software.&lt;/p&gt;
&lt;h3 id=&quot;and-that-s-it-for-now&quot;&gt;And that’s it for now&lt;/h3&gt;
&lt;p&gt;Fortunately, FME is not that essential. Maybe you won’t need to pay for the license for long… But I’m curious to read about what makes it a must-have for you. &lt;strong&gt;What can FME do that other tools cannot? Why is it necessary to you?&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Feels good to rant a bit. To summarize:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn SQL&lt;/li&gt;
&lt;li&gt;Don’t be afraid of command lines and programming languages&lt;/li&gt;
&lt;li&gt;Have interoperability in mind&lt;/li&gt;
&lt;li&gt;Get away from closed data formats&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you want to talk about all of this or if you need help converting some processes from FME to more open solutions, hit me up on &lt;a rel=&quot;external&quot; href=&quot;https://tooting.ch/@jln_brnt&quot;&gt;Mastodon&lt;/a&gt;.&lt;/p&gt;
</content>
        <summary type="html">Do you really need it in the first place? I really don&#39;t think so.</summary>
        </entry><entry xml:lang="en">
        <title>A little bit of GDAL/OGR appreciation</title>
        <published>2024-01-19T00:00:00+00:00</published>
        <updated>2024-01-19T00:00:00+00:00</updated>
        <author>
            <name>jujube</name>
        </author>
        <link rel="alternate" href="https://blog.geothings.ch/blog/gdal-appreciation/" type="text/html"/>
        <id>https://blog.geothings.ch/blog/gdal-appreciation/</id>
        
            <content type="html">&lt;p&gt;If there had to be one single tool to work with spatial data, I think GDAL/OGR would be the first name to come to mind. Its usages range from raster to vector, it can be used as command line, imported as a library in many languages through bindings developed by the community, many applications provide UI to parameterize and run GDAL etc. Its versatility makes it an amazing tool to work with spatial data in a lot of different contexts, but it’s sometimes underestimated or even misunderstood.&lt;/p&gt;
&lt;p&gt;We will quickly introduce GDAL/OGR, then give some examples of usage to help for some quick starts.&lt;/p&gt;
&lt;h2 id=&quot;what-is-gdal-ogr&quot;&gt;What is GDAL/OGR?&lt;/h2&gt;
&lt;p&gt;GDAL/OGR (&lt;strong&gt;G&lt;/strong&gt;eospatial &lt;strong&gt;D&lt;/strong&gt;ata &lt;strong&gt;A&lt;/strong&gt;bstraction &lt;strong&gt;L&lt;/strong&gt;ibrary/&lt;strong&gt;O&lt;/strong&gt;pen&lt;strong&gt;G&lt;/strong&gt;IS Simple Features &lt;strong&gt;R&lt;/strong&gt;eference Implementation) is a library for working with raster and vector geospatial data formats, coded mainly in C++, C and Python. The first release dates from 2000, and the project has now more than &lt;a rel=&quot;external&quot; href=&quot;https://github.com/OSGeo/gdal/graphs/contributors&quot;&gt;450 contributors&lt;/a&gt; at the time of writing. This is a very active project with regular releases.&lt;/p&gt;
&lt;p&gt;The project is composed of two parts: the raster processing library GDAL and the feature processing library OGR, both merged during the release of GDAL 2.0. When working with raster data you will use programs prefixed with &lt;em&gt;gdal&lt;/em&gt; (gdal_translate, gdalwarp etc.) while vector data will use &lt;em&gt;ogr&lt;/em&gt; prefixed scripts (ogrinfo, ogr2ogr etc.). When talking aboutt &lt;em&gt;GDAL&lt;/em&gt;, both libraries are included, and we’ll do the same from here.&lt;/p&gt;
&lt;p&gt;As its name suggests, GDAL abstracts data in order to standardize its way of interacting with it. The driver creates the interface between the data source and the tools, allowing to focus on the logic of the process rather than how to read or write the data. This makes it a very extensible project; including a new format of data source requires to write a new driver, nothing more. You could see that the list of supported formats is quite something, either &lt;a rel=&quot;external&quot; href=&quot;https://gdal.org/drivers/raster/index.html#&quot;&gt;raster&lt;/a&gt; or &lt;a rel=&quot;external&quot; href=&quot;https://gdal.org/drivers/vector/index.html&quot;&gt;vector&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;GDAL describes itself as a translator, meaning that data come from a source and goes to its destination. Translations can occur at different moment during the process, during reading or by the script called. These translations can occur on multiple axis as well, we could for example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Extract a subset of source data depending on a region of interest.&lt;/li&gt;
&lt;li&gt;Extract a subset of source data based on an attribute.&lt;/li&gt;
&lt;li&gt;Reproject data into a different coordinate system.&lt;/li&gt;
&lt;li&gt;Merge a series of data files into a single one.&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.geothings.ch/blog/gdal-appreciation/gdal.jpeg&quot; alt=&quot;gdal-appreciation&quot; /&gt;
&lt;em&gt;Source unknown, if it’s your image and you want to be cited please leave a comment&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;As an open source project with a permissive MIT license, GDAL is used by many projects, open source or proprietary, to process geospatial data. If you’ve used QGIS, ArcGIS, FME or PostGIS, you’ve used GDAL under the hood.&lt;/p&gt;
&lt;h2 id=&quot;why-would-i-use-it&quot;&gt;Why would I use it?&lt;/h2&gt;
&lt;p&gt;Weirdly, even though GDAL is basically everywhere there is geospatial data to be moved, it’s not so much acknowledged by GIS people, or at least it’s not really used on its own. If you read this, you definitely use GDAL, but maybe without noticing.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Ok but why would I complicate my life with some command lines when the same tool is being used by a software that provides me a user interface easier to use?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;While it’s much intuitive to explore geospatial data through a user interface such as QGIS, where you can interactively load your data, chose the process you want to apply, its parameters, and visualize the results, things get a bit more complicated once you’ve done the exploratory part and want to reapply your newly defined process to new data. Repeating operations becomes quickly tedious and error-prone. You could use a tool such as the &lt;a rel=&quot;external&quot; href=&quot;https://docs.qgis.org/3.28/en/docs/user_manual/processing/modeler.html&quot;&gt;Model Designer&lt;/a&gt; from QGIS (amazing little tool, check it if you repeat a lot of operations in QGIS), but how do you schedule your process to be started when you’re not able to launch it manually?&lt;/p&gt;
&lt;p&gt;If you use a heavy client ETL such as FME, try once to compare the difference in speed between a simple table transfer done by launching a FME workspace (using a command line) and a simple &lt;em&gt;ogr2ogr&lt;/em&gt; command, there is at least an order of magnitude of difference.&lt;/p&gt;
&lt;p&gt;It’s about using a tool designed for a purpose as efficiently as possible.&lt;/p&gt;
&lt;h2 id=&quot;how-to-install&quot;&gt;How to install?&lt;/h2&gt;
&lt;p&gt;We’ll assume you have no installation of GDAL yet, but just to make sure you can try:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;gdalinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --version&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which gives:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;GDAL 3.4.1, released 2021/12/27&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If it’s not installed you can refer to the installation instructions from &lt;a rel=&quot;external&quot; href=&quot;https://gdal.org/download.html#&quot;&gt;GDAL website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, I’m working on Ubuntu 22.04, for which the GDAL package is the &lt;a rel=&quot;external&quot; href=&quot;https://launchpad.net/ubuntu/+source/gdal&quot;&gt;3.4.1&lt;/a&gt;. The latest version can be installed by downloading the latest release, but I usually stick with the provided version for my platform, unless I need a specific update.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; install gdal-bin&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you should be good!&lt;/p&gt;
&lt;div class=&quot;admonition warning&quot;&gt;
&lt;div class=&quot;admonition-icon admonition-icon-warning&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;admonition-content&quot;&gt;
&lt;strong class=&quot;admonition-title&quot;&gt;WARNING&lt;/strong&gt;
&lt;p&gt;You might already have GDAL installed through another software like QGIS, be careful during the installation, multiple installations might interfere and create warnings or errors. On Windows you can use the &lt;em&gt;OSGeo Shell&lt;/em&gt; to access any tool from the OSGeo ecosystem.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&quot;and-how-do-we-use-it&quot;&gt;And how do we use it?&lt;/h2&gt;
&lt;p&gt;It’s easy, you just need to be comfortable with command lines. If you’ve mostly worked with user interfaces it might look scary, but it really is not complicated.&lt;/p&gt;
&lt;h3 id=&quot;access-metadata&quot;&gt;Access metadata&lt;/h3&gt;
&lt;p&gt;The first thing we usually do with data is to have some information about it. Let’s try to see the metadata of a random .jpeg:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;gdalinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; gdal.jpeg&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Driver: JPEG/JPEG JFIF&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Files: gdal.jpeg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Size is 711, 882&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Metadata:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  EXIF_Orientation=1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Image Structure Metadata:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  COMPRESSION=JPEG&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  INTERLEAVE=PIXEL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SOURCE_COLOR_SPACE=YCbCr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Corner Coordinates:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Upper Left  (    0.0,    0.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Lower Left  (    0.0,  882.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Upper Right (  711.0,    0.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Lower Right (  711.0,  882.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Center      (  355.5,  441.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Band 1 Block=711x1 Type=Byte, ColorInterp=Red&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Overviews: 356x441, 178x221&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Image Structure Metadata:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    COMPRESSION=JPEG&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Band 2 Block=711x1 Type=Byte, ColorInterp=Green&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Overviews: 356x441, 178x221&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Image Structure Metadata:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    COMPRESSION=JPEG&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Band 3 Block=711x1 Type=Byte, ColorInterp=Blue&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Overviews: 356x441, 178x221&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Image Structure Metadata:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    COMPRESSION=JPEG&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Easy right? And it’s not even georeferenced, it’s a .jpeg, a driver exists, it opens.&lt;/p&gt;
&lt;p&gt;We can try the same with some vector data. We’ll have a look at what is going on in one of the PostgreSQL database hosted on my computer.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogrinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -ro PG:dbname=osm_suisse&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;INFO: Open of `PG:dbname=osm_suisse&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      using driver `PostgreSQL&amp;#39; successful.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1: planet_osm_line (Line String)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;2: planet_osm_polygon&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;3: planet_osm_roads (Line String)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;4: planet_osm_point (Point)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;5: natural_polygons&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And as we can see I have 5 layers in my database. Notice how we used the &lt;em&gt;ogrinfo&lt;/em&gt; command for questioning vector data. Here &lt;em&gt;ogrinfo&lt;/em&gt; (like &lt;em&gt;gdalinfo&lt;/em&gt;) requires a dataset source as input, the syntax will depend on each driver, make sure to have a look at the &lt;a rel=&quot;external&quot; href=&quot;https://gdal.org/drivers/vector/index.html&quot;&gt;documentation&lt;/a&gt;. For a PostgreSQL connection, the line could have looked like:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogrinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -ro PG:&amp;quot;dbname=&amp;#39;osm_suisse&amp;#39; host=&amp;#39;localhost&amp;#39; port=&amp;#39;5432&amp;#39; user=&amp;#39;x&amp;#39; password=&amp;#39;y&amp;#39;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can extend the information that we want to see for each layer by adding the &lt;code&gt;-al&lt;/code&gt; flag to the line. The option &lt;code&gt;-so&lt;/code&gt; will summarize the output.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogrinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -ro -so -al PG:dbname=osm_suisse&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;INFO: Open of `PG:dbname=osm_suisse&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      using driver `PostgreSQL&amp;#39; successful.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer name: planet_osm_line&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Geometry: Line String&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Feature Count: 2137192&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Extent: (626211.331305, 5706647.213604) - (1253686.695428, 6117386.570796)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer SRS WKT:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;PROJCRS[&amp;quot;WGS 84 / Pseudo-Mercator&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    BASEGEOGCRS[&amp;quot;WGS 84&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ENSEMBLE[&amp;quot;World Geodetic System 1984 ensemble&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (Transit)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G730)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G873)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G1150)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G1674)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G1762)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G2139)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ELLIPSOID[&amp;quot;WGS 84&amp;quot;,6378137,298.257223563,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                LENGTHUNIT[&amp;quot;metre&amp;quot;,1]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ENSEMBLEACCURACY[2.0]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        PRIMEM[&amp;quot;Greenwich&amp;quot;,0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ANGLEUNIT[&amp;quot;degree&amp;quot;,0.0174532925199433]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ID[&amp;quot;EPSG&amp;quot;,4326]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    CONVERSION[&amp;quot;Popular Visualisation Pseudo-Mercator&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        METHOD[&amp;quot;Popular Visualisation Pseudo Mercator&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ID[&amp;quot;EPSG&amp;quot;,1024]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        PARAMETER[&amp;quot;Latitude of natural origin&amp;quot;,0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ANGLEUNIT[&amp;quot;degree&amp;quot;,0.0174532925199433],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ID[&amp;quot;EPSG&amp;quot;,8801]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        PARAMETER[&amp;quot;Longitude of natural origin&amp;quot;,0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ANGLEUNIT[&amp;quot;degree&amp;quot;,0.0174532925199433],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ID[&amp;quot;EPSG&amp;quot;,8802]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        PARAMETER[&amp;quot;False easting&amp;quot;,0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            LENGTHUNIT[&amp;quot;metre&amp;quot;,1],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ID[&amp;quot;EPSG&amp;quot;,8806]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        PARAMETER[&amp;quot;False northing&amp;quot;,0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            LENGTHUNIT[&amp;quot;metre&amp;quot;,1],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ID[&amp;quot;EPSG&amp;quot;,8807]]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    CS[Cartesian,2],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        AXIS[&amp;quot;easting (X)&amp;quot;,east,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ORDER[1],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            LENGTHUNIT[&amp;quot;metre&amp;quot;,1]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        AXIS[&amp;quot;northing (Y)&amp;quot;,north,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            ORDER[2],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            LENGTHUNIT[&amp;quot;metre&amp;quot;,1]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    USAGE[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        SCOPE[&amp;quot;Web mapping and visualisation.&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        AREA[&amp;quot;World between 85.06°S and 85.06°N.&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        BBOX[-85.06,-180,85.06,180]],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ID[&amp;quot;EPSG&amp;quot;,3857]]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Data axis to CRS axis mapping: 1,2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Geometry Column = way&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;osm_id: Integer64 (0.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;access: String (0.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;addr:housename: String (0.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;addr:housenumber: String (0.0)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[...]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now we have the full detail of our layers; name, type, feature count, etc.&lt;/p&gt;
&lt;h3 id=&quot;basic-translations&quot;&gt;Basic translations&lt;/h3&gt;
&lt;p&gt;Now that we know what were working, with we can try to move some things around. Let’s start by exporting our vector data into a geopackage.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogr2ogr&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -f GPKG exported_data.gpkg &amp;quot;PG:dbname=osm_suisse tables=planet_osm_point&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we’re exporting the table &lt;em&gt;planet_osm_point&lt;/em&gt; into the &lt;em&gt;exported_data.gpkg&lt;/em&gt; geopackage. The format can be recognized by the extension of the output file, but it’s safer to ensure the format by passing the argument &lt;code&gt;-f&lt;/code&gt;. Again, each driver documentation will have its driver name to be used.&lt;/p&gt;
&lt;h3 id=&quot;add-a-filter&quot;&gt;Add a filter&lt;/h3&gt;
&lt;p&gt;We can export a subset of our data, based on an attribute for example. Let’s say we want to export the points where the attribute &lt;em&gt;addr:housenumber&lt;/em&gt; is not null, and we want to save it in another table in our newly created geopackage. We’d do something like:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogr2ogr&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -update -f GPKG -where &amp;#39;&amp;quot;addr:housenumber&amp;quot; is not null&amp;#39; -nln only_housenumbers exported_data.gpkg &amp;quot;PG:dbname=osm_suisse tables=planet_osm_point&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We want to update our dataset (our geopackage) and not create a new one, so we use the &lt;code&gt;-update&lt;/code&gt; option. The syntax of the &lt;code&gt;-where&lt;/code&gt; parameter is a bit convoluted here since there is a special character in the column name, but with a simple name you’d just need a pair of quotes &lt;code&gt;-where &quot;housenumber&quot; is not null&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Let’s have a look at our geopackage:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogrinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -ro -al -so exported_data.gpkg&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;INFO: Open of `exported_data.gpkg&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      using driver `GPKG&amp;#39; successful.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer name: planet_osm_point&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Geometry: Point&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Feature Count: 2146246&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Extent: (626415.435591, 5736097.599850) - (1189428.532375, 6117386.570796)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer SRS WKT:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;PROJCRS[&amp;quot;WGS 84 / Pseudo-Mercator&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    BASEGEOGCRS[&amp;quot;WGS 84&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ENSEMBLE[&amp;quot;World Geodetic System 1984 ensemble&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (Transit)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G730)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G873)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G1150)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[...]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer name: only_housenumbers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Geometry: Point&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Feature Count: 366561&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Extent: (663719.309401, 5751784.044673) - (1167785.106794, 6072459.331387)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer SRS WKT:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;PROJCRS[&amp;quot;WGS 84 / Pseudo-Mercator&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    BASEGEOGCRS[&amp;quot;WGS 84&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ENSEMBLE[&amp;quot;World Geodetic System 1984 ensemble&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (Transit)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G730)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G873)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G1150)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            MEMBER[&amp;quot;World Geodetic System 1984 (G1674)&amp;quot;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[...]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The new layer has been added to the geopackage. Has the query been respected?&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogrinfo&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -ro -al -so -sql &amp;#39;select * from only_housenumbers where &amp;quot;addr:housenumber&amp;quot; is null&amp;#39; exported_data.gpkg&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;INFO: Open of `exported_data.gpkg&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      using driver `GPKG&amp;#39; successful.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer name: SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Geometry: Point&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Feature Count: 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Layer SRS WKT:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;PROJCRS[&amp;quot;WGS 84 / Pseudo-Mercator&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[...]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yes! No data without &lt;em&gt;addr:housenumber&lt;/em&gt;.&lt;/p&gt;
&lt;div class=&quot;admonition tip&quot;&gt;
&lt;div class=&quot;admonition-icon admonition-icon-tip&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;admonition-content&quot;&gt;
&lt;strong class=&quot;admonition-title&quot;&gt;TIP&lt;/strong&gt;
&lt;p&gt;The &lt;code&gt;-sql&lt;/code&gt; option is another way of filtering data, it allows you to pass a sql query in any of the sql flavor supported by the driver, you can even save your queries in a text file and pass the file to the &lt;code&gt;-sql&lt;/code&gt; parameter as &lt;code&gt;-sql @path/to/my_file&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;geometric-operations&quot;&gt;Geometric operations?&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;-sql&lt;/code&gt; parameter can also be used to apply transformations to the data. We’ll request the same points, but this time we’ll create a buffer around them.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogr2ogr&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -update -f GPKG -sql &amp;#39;select ST_Buffer(way, 50) from planet_osm_point where &amp;quot;addr:housenumber&amp;quot; is not null&amp;#39; -nln buffered_only_housenumbers exported_data.gpkg &amp;quot;PG:dbname=osm_suisse tables=planet_osm_point&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that’s it, we have our buffer around the points of interest. Here GDAL makes use of the internal capabilities of PostgreSQL and PostGIS by passing directly the request to the database, but the same command using the &lt;em&gt;only_housenumbers&lt;/em&gt; layer from our geopackage would also be valid.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3 z-i&quot;&gt;ogr2ogr&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -update -f GPKG -sql &amp;quot;select ST_Buffer(way, 50) from only_housenumbers&amp;quot; -nln buffered_only_housenumbers exported_data.gpkg exported_data.gpkg&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;admonition tip&quot;&gt;
&lt;div class=&quot;admonition-icon admonition-icon-tip&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;admonition-content&quot;&gt;
&lt;strong class=&quot;admonition-title&quot;&gt;TIP&lt;/strong&gt;
&lt;p&gt;In the case of PostgreSQL/PostGIS you can write the &lt;code&gt;-sql&lt;/code&gt; parameter like you would write your queries directly into the database. They are passed directly to the database by GDAL.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This should give you a small idea of the things you can do with GDAL and how to start experimenting.&lt;/p&gt;
&lt;h2 id=&quot;final-words&quot;&gt;Final words&lt;/h2&gt;
&lt;p&gt;Well that was a lot more than expected. But GDAL really is a very strong and important tool. Diving into the details of all the available options, both for the command AND the drivers, is not a small task, but understanding how to navigate around and find the information that you need to process your data as you wish can go a long way. Manual and repeated tasks can be replaced to help to focus on more pertinent work, process time can be (by experience) reduced drastically depending on the tools you’re initially using. And if you’re working on data hosted on a server without graphic interface, well you have a tool to get the info you need!&lt;/p&gt;
&lt;p&gt;Obviously GDAL alone can’t do everything and has its imperfections; I’ve really struggled with installations in the past (Python binding might have bested me at some point), and the number of parameters is a bit overwhelming. But once you have it working it does the job, and really well.&lt;/p&gt;
&lt;p&gt;If you can, use GDAL.&lt;/p&gt;
</content>
        <summary type="html">To one of the OGs of geographical information, it&#39;s everywhere and you should knwo about it.</summary>
        </entry>
</feed>
