<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Geoffroy Gobert on Medium]]></title>
        <description><![CDATA[Stories by Geoffroy Gobert on Medium]]></description>
        <link>https://medium.com/@gobert?source=rss-cd6a71fd3ad7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yLomO5na-ewt2bbjj3Gc8Q.jpeg</url>
            <title>Stories by Geoffroy Gobert on Medium</title>
            <link>https://medium.com/@gobert?source=rss-cd6a71fd3ad7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:02:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gobert/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Kubernetes architecture for machine learning web-application deployments]]></title>
            <link>https://medium.com/data-science/a-kubernetes-architecture-for-machine-learning-web-application-deployments-632f7765ef29?source=rss-cd6a71fd3ad7------2</link>
            <guid isPermaLink="false">https://medium.com/p/632f7765ef29</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[making-sense-of-big-data]]></category>
            <dc:creator><![CDATA[Geoffroy Gobert]]></dc:creator>
            <pubDate>Mon, 01 Mar 2021 14:00:58 GMT</pubDate>
            <atom:updated>2021-03-03T21:30:14.264Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://towardsdatascience.com/tagged/making-sense-of-big-data">Making Sense of Big Data</a></h4><h4>Use Kubernetes to reduce machine learning infrastructure costs and scale resources with ease.</h4><figure><img alt="Photo in public domain from wikipedia" src="https://cdn-images-1.medium.com/max/1024/1*Qbu1b6mL-7qF3LQ1pI50cw.jpeg" /><figcaption>Photo in the public domain from <a href="https://commons.wikimedia.org/wiki/File:Operation_Deep_Freeze_2006,_MV_American_Tern,_Krasin_200601.jpg">wikipedia</a></figcaption></figure><p>Kubernetes became the reference for container orchestration. Container orchestration means starting containers, shutting them down, scaling them vertically (quantity of memory and CPU attributed), and scaling them horizontally (number of containers running in parallel).</p><p>Does Kubernetes add value to machine learning? Machine Learning needs a lot of resources for training a model, but a little resource for serving prediction. Kubernetes adapts the resources automatically! Machine learning usually implies a long training duration, that can be shortened by distributing the task over several computers. Kubernetes shines in adapting the number of computers necessary. In general, Kubernetes reduces infrastructure costs by requiring only the necessary resources over time.</p><p>This article describes a Kubernetes architecture for machine-learning web-application. The term “Kubernetes architecture” answers the question “how is the application deployed into Kubernetes?”. This article answers this question in 4 parts that:</p><ol><li>Define a machine learning web-application.</li><li>Analyze the requirements for deploying the machine learning web-application to production.</li><li>Suggest a Kubernetes architecture for deploying machine learning web-application.</li><li>Adapt the architecture for distributed training.</li></ol><p>If you are interested in this article, you might also be interested in:</p><p><a href="https://towardsdatascience.com/how-to-scale-the-training-of-several-models-64180480ca3d">How to scale the training of several models?</a></p><h3>Definition of a machine learning web-application</h3><p>On a high level, a machine learning application is responsible for two things:</p><ol><li>training a model: based on a training dataset, it trains an estimator</li><li>serving predictions: based on the trained estimator and new data, it predicts new values</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*p8leHCpyBNY0Rm8xHEAEDA.png" /><figcaption><em>Image by author</em></figcaption></figure><p><strong>One example: demand-forecaster</strong></p><p>Imagine an application that forecasts the demand of scooters in an area of a city. Its inputs and outputs are in red. In the next step, each input and output will be mapped to its Kubernetes component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*It3pwg_W8vm9WHw1ejnAng.png" /><figcaption><em>Image by author</em></figcaption></figure><ul><li>Input: It reads the historical demand from a database.</li><li>Output: It serves the predictions with a REST API. Uvicorn is the webserver.</li><li>Serialization: It writes and reads the trained estimator on the hard drive. This is the output of the training phase, and it is the input of the prediction phase.</li></ul><h3>Requirements for deploying machine learning web-applications</h3><p>Requirements for deploying machine learning web-applications:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*NpjlgpOw6vMLo2bijhyawA.png" /><figcaption><em>Image by author</em></figcaption></figure><ol><li><strong>Ensure consistency between the code and the estimator</strong>. Changing the estimator library (e.g. version of sklearn, xgboost, tensorflow) might require re-training the model. Adding a feature, updating a feature, or deleting a feature also requires re-training the model. And because a web-application is constantly serving prediction, discrepancies between the deployed code and the estimator must be avoided.</li><li><strong>Avoid model drift</strong>. A model trained yesterday will be less accurate tomorrow. This is called model drift. It matters more in some areas than in others. In forecasting, the latest observation matters, so the model is drifting fast. On the opposite, in computer vision, if the task is about to classify different types of cars, the model drifts when new models of cars are available. In order to be more accurate, model drift must be avoided.</li><li><strong>Scaling vertically</strong>. Training a model requires a lot of memory. To avoid out-of-memory errors, a sufficient quantity of memory must be provided.</li><li><strong>Scaling horizontally</strong>. Training machine learning models can be very long. Distributing the training over several computers helps. A sufficient number of computers must be provided.</li><li><strong>Share trained estimator.</strong> The model’s estimator is trained on a computer and predictions are served on another. The predictions can also be served by several computers. The serialized estimator must be shared between all the computers.</li></ol><h3>A Kubernetes architecture for a machine learning web-application</h3><p>Deploying a machine learning web-application on production adds new requirements. This section presents how they can be solved with Kubernetes.</p><p><strong>Kubernetes terminology</strong></p><p>Previously, this article spoke about “computers”, in Kubernetes it translates to “pods”.</p><blockquote><em>Pods are the smallest, most basic deployable objects in Kubernetes. A Pod represents a single instance of a running process in your cluster. Pods contain one or more containers, such as Docker containers.</em></blockquote><p>Kubernetes Engine Documentation</p><p>But to make things simpler: in this article, each pod will always have one container. This article speaks also about Kubernetes services:</p><blockquote><em>A Kubernetes service is a logical abstraction for a deployed group of pods in a cluster (which all perform the same function). Since pods are ephemeral, a service enables a group of pods, which provide specific functions (web services, image processing, etc.) to be assigned a name and unique IP address (clusterIP).</em></blockquote><p>In this example, Kubernetes will have one service. This service is responsible for forecasting the demand. It will do 2 things: training a machine learning model and serving predictions.</p><p><strong>A Kubernetes architecture for machine learning web-applications</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*zqn1chfBZUOGE5YvLRamug.png" /><figcaption><em>Image by author</em></figcaption></figure><p><strong>Kubernetes job</strong> (aka pod-init)</p><p>A Kubernetes job is a pod that is executed before the actual deployment, before that the pod of the web server starts. Kubernetes jobs can be used to train the model. So, the consistency between the code and the estimator can be ensured.</p><p><strong>Kubernetes cronJob</strong></p><p>A Kubernetes cronJob is a pod scheduled for being executed on a regular basis. It can be used to retrain the model on a regular basis (e.g. every day) with the latest data. So, the drift of the model can be avoided.</p><p><strong>Kubernetes shared volume</strong></p><p>A Kubernetes shared volume shares files between pods. So, the trained estimator can be shared between the pods.</p><p>On the schema above, the serialized models are actually saved on AWS S3, but a pure Kubernetes approach is to use shared volumes.</p><p><strong>Kubernetes vertical pod autoscaler</strong></p><p>A Kubernetes vertical pod autoscaler allocates the required memory and CPU to the pods dynamically over time. So, out-of-memory errors can be avoided and vertical scaling can be ensured.</p><p><strong>Horionztal scaling</strong></p><p>This requirement is met by 2 components. The number of deployment pods is controlled by <strong>Kubernetes horizontal pod autoscaler.</strong> It starts and stops pods in order to satisfy the number of simultaneous HTTP-requests. Besides, Kubernetes jobs have a parameter “<strong>parallelism</strong>” to control how many pods run in parallel. Jobs are used for training the model, and beyond Kubernetes, training a machine learning model in a distributed way requires some adaptation. This is the focus of the next section.</p><h3>Adaptation for a distributed training</h3><p>Training the model during deployment makes deployment easier. Contributors don’t need to think: How this new feature will impact the legacy estimator? How will the new normalization of the data impact the legacy estimator? How will the update of the library impact the legacy estimator?</p><p>Nonetheless, it has one downside: training the model during deployment (in the pod-initialization step) might last for a long time and make the deployment workflow (CI/CD) inefficient. A slow deployment pipeline is breaking the CI/CD best practices.</p><p>In this case, distributing the training over several pods helps. Some libraries are designed to distribute the training of one model: for example MLlib or Tensorflow. This is not the focus of this article.</p><p>In other cases, the training is fitting several models, not only one. In this case, <a href="https://towardsdatascience.com/how-to-scale-the-training-of-several-models-64180480ca3d">it’s easy to distribute the training with a master/worker pattern</a>. Assuming the entry points are bin/master.py and bin/worker.sh, this is a representation of the pods that are orchestrated by Kubernetes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*9nrOty40IHbtGUuyLFVnBA.png" /><figcaption><em>Image by author</em></figcaption></figure><p>The light green boxes show the kind of Kubernetes object that is manipulated: they group pod definitions by type. The middle green boxes are the definition of the pod i.e. the YAML like below. The dark green boxes show actual instances of the definition.</p><pre>apiVersion: batch/v1beta1<br>kind: CronJob<br>spec:<br>  schedule: &quot;40 2 * * *&quot;</pre><p>In a distributed world, Kubernetes orchestrates multiple instances of the pods.</p><p>For jobs and cronJobs, first, the pod named “master” is executed: it creates the task in the database (redis, outside of Kubernetes). Then, the workers are starting: they perform the task. The worker processes need to be terminated so that Kubernetes stop the pods and then starts the deployment pods. With celery, the following pseudo-code helped:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82ed4cefb702ee87813c80446b6e91b2/href">https://medium.com/media/82ed4cefb702ee87813c80446b6e91b2/href</a></iframe><h3>Conclusion</h3><p>Deploying a machine learning web-service adds new requirements like ensuring the consistency between the code and the estimator, scalability, sharing the models between all computers, and avoid model-drift. This article shows one way of solving these requirements with Kubernetes. Besides, it adds great value for reducing infrastructure costs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=632f7765ef29" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-kubernetes-architecture-for-machine-learning-web-application-deployments-632f7765ef29">A Kubernetes architecture for machine learning web-application deployments</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to scale the training of several models?]]></title>
            <link>https://medium.com/data-science/how-to-scale-the-training-of-several-models-64180480ca3d?source=rss-cd6a71fd3ad7------2</link>
            <guid isPermaLink="false">https://medium.com/p/64180480ca3d</guid>
            <category><![CDATA[model-training]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[ml-model-deployment]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Geoffroy Gobert]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 17:53:17 GMT</pubDate>
            <atom:updated>2021-01-06T19:36:01.345Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to scale the training of several models</h3><h4>A simple solution based on python and celery</h4><h3>Motivation</h3><p>Let’s consider the following task: predicting the demand for something in several cities. This is a time series forecasting problem. Forecasting differentiates between local models and global models. With local models, you train a model for each city. With global models, you train one model for all the cities. All to say: it’s sometimes necessary to train multiple similar models.</p><p>The naive solution consists in training the models sequentially: one model after another. Imagine you need 10 minutes to train the model of a city, and you have 100 cities. You need 1 000 minutes to train all the models (16 hours). This is a productivity-killer. And as fitting a model is part of the deployment, it would violate the principles of continuous integration and continuous development.</p><p>To finish the training within the same duration, independently of the number of models, the solution is to distribute the training among n computers (also known as workers). This article will describe a solution in python. The solution is based on the famous library celery. A prototype is <a href="https://github.com/gobert/medium/tree/master/distributed-training-celery">available on github</a>.</p><h3>Overview of the solution</h3><p>This problem is commonly solved with a task queue manager. In python, the most famous task queue manager is celery. We will have:</p><ul><li>1 master, that creates the tasks</li><li>n workers, each of them fitting one model</li></ul><figure><img alt="Image by Author" src="https://cdn-images-1.medium.com/max/591/1*DCh766yeCMAMu6Eq-OEq3w.png" /><figcaption>Image by Author</figcaption></figure><p>For training models, there are 2 more important requirements:</p><ul><li>Metric: We want to know the average metrics across all models.</li><li>Cost: the workers must shut down once the training is done.</li></ul><figure><img alt="Image by Author" src="https://cdn-images-1.medium.com/max/591/1*DInrWjLwZJbZ98mvPjv3zw.png" /><figcaption>Image by Author</figcaption></figure><h3>Implementation</h3><p>The implementation is available on g<a href="https://github.com/gobert/medium/tree/master/distributed-training-celery">ithub</a>.</p><p><strong>Step 1 — first celery usage &amp; prototype skeleton</strong></p><p>Prerequisites: install the celery package; install and start redis; and understand <a href="https://docs.celeryproject.org/en/stable/getting-started/first-steps-with-celery.html">the celery first steps</a>.</p><p>First, define a celery task called“fit”. It will be executed by the workers. It’s the code that is executed to fit a model, and it returns the accuracy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75a1088923a040fc7d8732b6ea17b322/href">https://medium.com/media/75a1088923a040fc7d8732b6ea17b322/href</a></iframe><p>Then, the master delegates the computation to the worker. Add this code, for example in bin/master.py.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6e7f661e907d5fdcd8b0f7469151fc8/href">https://medium.com/media/d6e7f661e907d5fdcd8b0f7469151fc8/href</a></iframe><p>Finally, execute the prototype like:</p><pre># start a worker<br>celery -A tasks worker</pre><pre># start the leader<br>python bin/master.py</pre><p>N.B. On github, a file (bin/worker.sh) has been created for starting a worker.</p><p><strong>Step 2 — Waiting for the tasks to be processed</strong></p><p>The master might have to wait that the tasks are processed. This happens likely in a deployment pipeline. This is the responsibility of the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9288c22db964f06390ae5d512670332a/href">https://medium.com/media/9288c22db964f06390ae5d512670332a/href</a></iframe><p><strong>Step 3 — Getting the average accuracy of each training</strong></p><p>To better understand and track the accuracy, the master can print the average accuracy across each city. The following code demonstrates how the master can read the results of its workers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b18713bb69b6d99a0df4a521a1178e0d/href">https://medium.com/media/b18713bb69b6d99a0df4a521a1178e0d/href</a></iframe><p><strong>Step 4 — Stopping the worker</strong></p><p>Define a task “shutdown” in src/tasks.py. A single execution by one worker will shut down all the workers. But the workers will first finish the execution of their current task.cal</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82d08206e238c2c5bcf92dde5e52f467/href">https://medium.com/media/82d08206e238c2c5bcf92dde5e52f467/href</a></iframe><p>The master delegates the task “shutdown” to the workers (in bin/master.py):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ec3adac9f117fb1d246d4bb7aaae558/href">https://medium.com/media/6ec3adac9f117fb1d246d4bb7aaae558/href</a></iframe><p><strong>Step 5 — Run everything!</strong></p><p>Starting 3 processes (1 master and 2 workers) in one tab:</p><figure><img alt="Image by Author" src="https://cdn-images-1.medium.com/max/1024/1*UDOlbsvlwdUACvcYBMtI5Q.gif" /><figcaption>Image by Author</figcaption></figure><h3>Other possibilities</h3><ul><li><strong>RabbitMQ</strong>: and all the other message queues that implement the AMQP protocol.</li><li>Not <strong>Kafka</strong>: it’s difficult and sub-optimal to solve this problem with Kafka. Kafka is not a good tool for this problem, because of its design. It doesn’t allow you to connect several consumers to the same partition.</li></ul><h3><strong>Conclusion</strong></h3><p>This article shows that celery is a simple solution for distributing the training of several models. Celery is the most famous python library for task processing. The knowledge and the skills that you will win with celery, are transferable to other problems. Out of the box, Celery comes with great features like “shut down all the workers” or “return a value from the worker to the master”. Nonetheless, other task queue managers can solve the same problem. You can develop a solution directly using a database (e.g. Redis) or a AMQP message broker (e.g. RabbitMQ). Even if this looks like writing your own task queue manager, it can be a more cost-efficient solution.</p><p>Let me know with a comment if you are interested in more details!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64180480ca3d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-to-scale-the-training-of-several-models-64180480ca3d">How to scale the training of several models?</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comment lire et utiliser le GeoJSON]]></title>
            <link>https://gobert.medium.com/comment-lire-et-utiliser-le-geojson-d1cab29892b2?source=rss-cd6a71fd3ad7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1cab29892b2</guid>
            <dc:creator><![CDATA[Geoffroy Gobert]]></dc:creator>
            <pubDate>Tue, 10 Nov 2020 14:32:18 GMT</pubDate>
            <atom:updated>2021-01-04T13:58:35.708Z</atom:updated>
            <content:encoded><![CDATA[<h3>Comment lire et utiliser le GeoJSON?</h3><p>Comment représenter des formes géographiques ? Le format GeoJSON est un standard conçu pour cela. Il peut représenter aussi des attributs non spatiaux. Cet article présente le GeoJSON, donne des outils pour travailler efficacement avec le GeoJSON et vous présente les pièges à éviter.</p><p>Prérequis : être confortable avec le format JSON.</p><h3>Le point - la base du GeoJSON</h3><pre>+-------------+--------+-------------------------------------------+<br>|     Clé     |  Type  |                  Valeur                   |<br>+-------------+--------+-------------------------------------------+<br>| type        | String | Point, LineString, Polygon,               |<br>|             |        | MultiPoint, MultiLineString, MultiPolygon |<br>+-------------+--------+------------------------------------------ + | coordinates | array  | Coordonnées [longitude, latitude]         |<br>+-------------+--------+-------------------------------------------+</pre><p><strong>Exemple</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/249eb4d171f7bb079678593a183692da/href">https://medium.com/media/249eb4d171f7bb079678593a183692da/href</a></iframe><h3><strong>La Feature - enrichir une géométrie d’attributs non spatiaux</strong></h3><p>Les attributs non-spatiaux sont appelés “properties”.</p><pre>+------------+--------+------------------------------------+<br>|    Clé     |  Type  |           Valeur                   |<br>+------------+--------+------------------------------------+<br>| type       | String | Feature, FeatureCollection         |<br>| geometry   | JSON   | cf $ Le point - la base du GeoJSON |<br>| properties | JSON   | Toute clé/valeur désirée           |<br>+------------+--------+------------------------------------+</pre><p><strong>Exemple</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9bcc69d00b4f9b031f6d4ecf7f1a284/href">https://medium.com/media/c9bcc69d00b4f9b031f6d4ecf7f1a284/href</a></iframe><h3>Le Polygone — la géométrie la plus utilisée</h3><pre>+-------------+--------+-------------------------------------------+<br>|     Clé     |  Type  |                  Valeur                   |<br>+-------------+--------+-------------------------------------------+<br>| type        | String | Polygon                                   |<br>+-------------+--------+------------------------------------------ + | coordinates | array  | Tableau 3 dimensions de coordonnées       |<br>|             |        | [longitude, latitude]                     |<br>+-------------+--------+-------------------------------------------+</pre><p><strong>Exemple</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/524a83d72544baef1bb45daf9b95b1ac/href">https://medium.com/media/524a83d72544baef1bb45daf9b95b1ac/href</a></iframe><p>N.B</p><ul><li>Le premier point est répété à la fin.</li><li>L’ordre des coordonnées : longitude, latitude.</li><li>Les coordonnées d’un polygone sont un tableau à 3 dimensions. Un polygone est une liste (1 dimension) de surfaces et de trous, chacun (1 dimension) ayant une latitude et une longitude (1 dimension).</li><li>Il y à 2 ordres pour lister les points du polygone : le sens anti-horaire (inverse des aiguilles d’une montre) pour une surface ; le sens horaire (sens des aiguilles d’une montre) pour un trou.</li></ul><p><strong>Exemple de polygones à trous</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b863f5485286cbb8277c54dcce396d66/href">https://medium.com/media/b863f5485286cbb8277c54dcce396d66/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*7EMufrrd7Y8hRjwJnbgXyw.png" /><figcaption>Visualisation du polygône troué</figcaption></figure><h3>Les outils pour être efficace avec le GeoJSON</h3><ul><li><a href="https://geojsonlint.com/">Valider le GeoJSON : https://geojsonlint.com/</a></li><li>Valider le JSON : <a href="https://jsonformatter.curiousconcept.com/">https://jsonformatter.curiousconcept.com/</a></li><li>Visualiser un fichier GeoJSON : <a href="https://kepler.gl/">https://kepler.gl/</a></li></ul><h3>Voire aussi</h3><ul><li>Pour aller plus loin, vous pouvez aussi étudier les lignes (types : Line et LineString), et les géométries multiples (types : MultiPoint, MultiLineString, MulitPolygon, FeatureCollection).</li><li>La RFC du GeoJSON <a href="https://tools.ietf.org/html/rfc7946">https://tools.ietf.org/html/rfc7946</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1cab29892b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutoriel H3 : géocodage en python]]></title>
            <link>https://gobert.medium.com/tutoriel-h3-g%C3%A9ocodage-en-python-a98afd4fda68?source=rss-cd6a71fd3ad7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a98afd4fda68</guid>
            <category><![CDATA[h3]]></category>
            <category><![CDATA[spatial-analysis]]></category>
            <category><![CDATA[geocoding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gis]]></category>
            <dc:creator><![CDATA[Geoffroy Gobert]]></dc:creator>
            <pubDate>Fri, 06 Nov 2020 10:28:05 GMT</pubDate>
            <atom:updated>2021-01-11T14:50:48.564Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tutoriel H3 : géocodage en python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DON41N5uM9IgK-5U3jjAtg.png" /></figure><p>Le géocodage est une partie importante de la préparation des données spatiale (spatial data preprocessing). Il s’agit d’attribuer une clé à toute paire latitude, longitude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*jVAJawL9JYPMEtl2q4eHEw.png" /></figure><p>La librairie H3 résout ce problème. Ses avantages ?</p><ul><li>Facile à utiliser : H3 à une API en python</li><li>Exécution rapide : les calculs s’effectuent en C (très rapide)</li><li>Bien maintenue : Uber maintient H3</li><li>Bon marché : H3 est open-source</li></ul><p>Ce tutoriel explique :</p><ul><li>comment convertir une latitude longitude vers une clé H3</li><li>comment convertir une clé H3 vers les 6 coordonnées d’un hexagone</li><li>comment trouver tous les hexagones dans un polygone</li><li>comment déterminer la précision optimale</li></ul><p><strong>Prérequis </strong>:</p><ul><li>Ce tutoriel a été réalisé avec python 3.9 et H3 3.7.0. Le code est <a href="https://github.com/gobert/medium/tree/master/h3">sur github</a>.</li><li>Une <a href="https://gobert.medium.com/comment-lire-et-utiliser-le-geojson-d1cab29892b2">connaissance du format GeoJSON</a> facilite la lecture de certaines parties</li></ul><h3>Convertir une paire latitude/longitude vers une clé H3</h3><pre>h3.geo_to_h3(lat, lng, resolution)</pre><pre>+------------+----------------------------------+<br>| Paramètre  |           Description            |<br>+------------+----------------------------------+<br>| lat        | latitude du point                |<br>| lng        | longitude du point               |<br>| resolution | taille desirée de l&#39;hexagone     |<br>+------------+----------------------------------+</pre><p><strong>Exemple</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3edb37c20ece7710561dd5e4afd8d3f/href">https://medium.com/media/b3edb37c20ece7710561dd5e4afd8d3f/href</a></iframe><h3>Convertir une clé H3 vers les 6 coordonnées d’un hexagone</h3><pre>h3.h3_to_geo_boundary(h, geo_json)</pre><pre>+-----------+----------------------+<br>| Paramètre |     Description      |<br>+-----------+----------------------+<br>| h         | clé de l&#39;hexagone h3 |<br>| geo_json  | retourne [[lng,lat]] |<br>+-----------+----------------------+</pre><p><strong>Exemple</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f5a0bfaab4c327e418a33d45cb278ec/href">https://medium.com/media/0f5a0bfaab4c327e418a33d45cb278ec/href</a></iframe><p>Le format retourné n’est pas commun. On peut le transformer en un standard comme le GeoJSON de la façon suivante :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8174fd2681bcefd7d353a89d7b6a13a/href">https://medium.com/media/c8174fd2681bcefd7d353a89d7b6a13a/href</a></iframe><h3>Trouver tous les hexagones dans un polygone</h3><pre>h3.polyfill(geojson, res, geo_json_conformant)<br><br><br>+---------------------+------------------------------------+<br>|      Paramètre      |            Description             |<br>+---------------------+------------------------------------+<br>| geojson             | Dictionnaire GeoJSON qui décrit... |<br>| .                   | ... le polygone à remplir          |<br>| res                 | Résolution des hexagones qui vont  |<br>| .                   | ... remplir le polygone            |<br>| geo_json_conformant | Inclure ou exclure la borne        |<br>+---------------------+------------------------------------+</pre><p><strong>Exemple</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbe9bd730e5026b20a0c976ea851d0e8/href">https://medium.com/media/dbe9bd730e5026b20a0c976ea851d0e8/href</a></iframe><h3>Alternatives</h3><ul><li>Geohash (avantages) : plus simple à comprendre</li><li>Geohash (désavantages) : plus long. Ne passe pas à l’échelle (scale). La forme d’un geohash est rectangulaire, un rectangle modélise moins bien un phénomène géographique qu’un hexagone (qui est l’approximation d’un cercle).</li><li>Code postale (avantage) : possiblement dans les données</li><li>Code postale (désavantage) : certaines des fonctionnalités ci-dessus peuvent manquer. En France, un code postal ne décrit pas une zone géographique contigüe (par exemple 91800). Peu de résolutions différentes.</li></ul><h3>Voire aussi</h3><ul><li>Documentation officielle : https://eng.uber.com/h3/</li><li>Github :<strong> </strong>https://github.com/uber/h3-py</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a98afd4fda68" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>