<?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 Karanrat Rattanawichai on Medium]]></title>
        <description><![CDATA[Stories by Karanrat Rattanawichai on Medium]]></description>
        <link>https://medium.com/@karanrat.rattanawichai?source=rss-a9b1a03b24a2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zBcqilfIn7TZCHuHRLJ04Q.jpeg</url>
            <title>Stories by Karanrat Rattanawichai on Medium</title>
            <link>https://medium.com/@karanrat.rattanawichai?source=rss-a9b1a03b24a2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 13:47:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karanrat.rattanawichai/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[Hands-on: BigQuery Data Encryption and Key Rotation]]></title>
            <link>https://medium.com/myorder/hands-on-bigquery-data-encryption-and-key-rotation-a2e06f29aa02?source=rss-a9b1a03b24a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2e06f29aa02</guid>
            <category><![CDATA[data-encryption]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Karanrat Rattanawichai]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 19:02:15 GMT</pubDate>
            <atom:updated>2026-02-01T00:41:21.115Z</atom:updated>
            <content:encoded><![CDATA[<p>This article provides a step-by-step walkthrough for protecting sensitive data in BigQuery tables using data encryption, along with key rotation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FgvsclwBtNHTnMfB_nT6ew.png" /><figcaption>Image AI generated with Google’s Nano Banana</figcaption></figure><h4>Encryption at rest</h4><p>Encryption at rest is the practice of protecting data that is stored on a device, such as a hard drive or a smartphone. By default, the moment your data touches a Google disk, it is broken into chunks and turned into unreadable code. Even if a thief walked into a Google data center and stole a physical hard drive, the data would be completely unusable to them.</p><p>Normally, Google handles key management and rotation for you. However, you can manage these steps yourself by enabling <a href="https://docs.cloud.google.com/bigquery/docs/encryption-at-rest"><strong>Customer-Managed Encryption Keys (CMEK / Autokey)</strong></a>, which lets you to decide where to store your keys and how frequent your key rotation is.</p><h4>Column-level encryption</h4><p>Column-level encryption is another layer of encryption used to protect sensitive data in BigQuery tables. BigQuery supports both <strong>non-deterministic encryption</strong>, which prevents joining, and <strong>deterministic encryption</strong>, which allows you to still join encrypted data.</p><h4>Steps (<strong>non-deterministic encryption</strong>):</h4><ol><li>Open key management service in google cloud console, create a <a href="https://docs.cloud.google.com/kms/docs/create-key-ring">key ring</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aoXwlgprCdmHRvcpIOycRQ.png" /><figcaption>Create a key ring</figcaption></figure><p>2. Create a <a href="https://docs.cloud.google.com/kms/docs/create-key">key</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u8R79Jpbi9SpGw_GbhfBZQ.png" /><figcaption>Create a key</figcaption></figure><p>Choose your key rotation frequency here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*LAx81grNHNg-iMWPdiKGiw.png" /><figcaption>key rotation frequency</figcaption></figure><p>3. Create <strong>NEW_WRAPPED_KEYSET</strong> that wrapped by your KMS key.</p><pre>SELECT <br>  &#39;prod_key_01&#39; AS key_id,<br>  KEYS.NEW_WRAPPED_KEYSET(<br>    &#39;gcp-kms://projects/{project-name}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{key}&#39;,<br>    &#39;AEAD_AES_GCM_256&#39;<br>  ) AS wrapped_keyset;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*RjDRgSn5X2TCtT_8SpgBRQ.png" /><figcaption>Wrapped keyset result</figcaption></figure><p>4. Decode wrapped keyset to raw binary format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rEXyQaBlq5bikP4J2cJwwg.png" /><figcaption>Raw binary format example</figcaption></figure><p>5. Create UDF for data encryption, you can also create this UDF in separate dataset to isolate access control.</p><pre>CREATE OR REPLACE FUNCTION kms_column_encryption.encrypt_user_email(plaintext STRING, user_id INT64) AS (<br>  AEAD.ENCRYPT(<br>    KEYS.KEYSET_CHAIN(<br>      &#39;gcp-kms://projects/myorder-data-platform-develop/locations/asia-southeast1/keyRings/tcolumn_level_encryption/cryptoKeys/customer_id&#39;,<br>      b&#39;\x0a$\x00\x88\x0c&quot;\x8fFB\x0bp\x17\xd0\xf5\xe6\xd36\x8e&lt;\xd1\xacgA\xbb@\xd9\x0b1[9\xb4[\x84\xb8W\x14\xe6\xc9\x12\x95\x01\x00\x90\xc0\x1e.\xdb\xbbE\x09-\x15o\xc0\xf5e.\x8d_\xfd\xf6\xf1\xbf\x84\xc2\xca\xa8\x81\xa0=f\x03\x8c\x96:\xeb\x85_\xe8\\\x0e\x02(\xceW\x03\x9c\x80(\xa9\x1f\xe2\x8e\x8c\xdf;r\x8c\xce\xaa\xa5\x9c\xb8f\xeb=\x80\xa2\x11\xee\x7f\xa1)2\xb9\xde\xb4\xce\x0d\x93\xc9\x1dN%$.\x9a\xe9\x8b\x9cF\xd7o\xf3\xc4\xb9\xf6\xc7=[\xbf\xaf-E\xcdU\xae\x16\xb1l#f\xe0\x8f\x16)\x84O[Jf\x83\x18h\xaa9\xdaf\xd7\xc8V\xfa\xf3\x06v\xc9\xc7\x9dR*\x8b\x80W\x1bG+\xaf\xd1\xc0\x19&#39;<br>    ),<br>    plaintext,<br>    CAST(user_id AS STRING)<br>  )<br>);</pre><p>6. Encrypt the data.</p><pre>CREATE OR REPLACE TABLE kms_column_encryption.encrypted_users AS<br>SELECT <br>  user_id,<br>  kms_column_encryption.encrypt_user_email(email, user_id) AS encrypted_email<br>FROM (<br>  SELECT 101 AS user_id, &#39;alice@example.com&#39; AS email UNION ALL<br>  SELECT 102, &#39;bob@example.com&#39; UNION ALL<br>  SELECT 103, &#39;charlie@example.com&#39;<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*hRwe6NcPhCCaOlWfLZ1vug.png" /><figcaption>Encrypted result</figcaption></figure><p>7. Next, lets decrypt them. Create UDF for data decryption.</p><pre>CREATE OR REPLACE FUNCTION kms_column_encryption.decrypt_user_email(encrypted_email BYTES, user_id INT64) AS (<br>  AEAD.DECRYPT_STRING(<br>    KEYS.KEYSET_CHAIN(<br>      &#39;gcp-kms://projects/myorder-data-platform-develop/locations/asia-southeast1/keyRings/tcolumn_level_encryption/cryptoKeys/customer_id&#39;,<br>     b&#39;\x0a$\x00\x88\x0c&quot;\x8fFB\x0bp\x17\xd0\xf5\xe6\xd36\x8e&lt;\xd1\xacgA\xbb@\xd9\x0b1[9\xb4[\x84\xb8W\x14\xe6\xc9\x12\x95\x01\x00\x90\xc0\x1e.\xdb\xbbE\x09-\x15o\xc0\xf5e.\x8d_\xfd\xf6\xf1\xbf\x84\xc2\xca\xa8\x81\xa0=f\x03\x8c\x96:\xeb\x85_\xe8\\\x0e\x02(\xceW\x03\x9c\x80(\xa9\x1f\xe2\x8e\x8c\xdf;r\x8c\xce\xaa\xa5\x9c\xb8f\xeb=\x80\xa2\x11\xee\x7f\xa1)2\xb9\xde\xb4\xce\x0d\x93\xc9\x1dN%$.\x9a\xe9\x8b\x9cF\xd7o\xf3\xc4\xb9\xf6\xc7=[\xbf\xaf-E\xcdU\xae\x16\xb1l#f\xe0\x8f\x16)\x84O[Jf\x83\x18h\xaa9\xdaf\xd7\xc8V\xfa\xf3\x06v\xc9\xc7\x9dR*\x8b\x80W\x1bG+\xaf\xd1\xc0\x19&#39;<br>    ),<br>    encrypted_email,<br>    CAST(user_id AS STRING)<br>  )<br>);</pre><p>8. Decrypt the data.</p><pre>SELECT <br>  user_id,<br>  kms_column_encryption.decrypt_user_email(encrypted_email, user_id) AS original_email<br>FROM kms_column_encryption.encrypted_users;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*UBQopj5AdhoRAfLfIuspJg.png" /><figcaption>Decrypted result</figcaption></figure><p><strong>Deterministic encryption</strong></p><p>For <strong>Encryption</strong>, update UDF: kms_column_encryption.encrypt_user_email</p><blockquote>Update AEAD.ENCRYPT() to DETERMINISTIC_ENCRYPT()</blockquote><pre>CREATE OR REPLACE FUNCTION kms_column_encryption.encrypt_user_email(plaintext STRING, user_id INT64) AS (<br>  DETERMINISTIC_ENCRYPT(<br>    KEYS.KEYSET_CHAIN(<br>      &#39;gcp-kms://projects/myorder-data-platform-develop/locations/asia-southeast1/keyRings/tcolumn_level_encryption/cryptoKeys/customer_id&#39;,<br>      b&#39;\x0a$\x00\x88\x0c&quot;\x8fFB\x0bp\x17\xd0\xf5\xe6\xd36\x8e&lt;\xd1\xacgA\xbb@\xd9\x0b1[9\xb4[\x84\xb8W\x14\xe6\xc9\x12\x95\x01\x00\x90\xc0\x1e.\xdb\xbbE\x09-\x15o\xc0\xf5e.\x8d_\xfd\xf6\xf1\xbf\x84\xc2\xca\xa8\x81\xa0=f\x03\x8c\x96:\xeb\x85_\xe8\\\x0e\x02(\xceW\x03\x9c\x80(\xa9\x1f\xe2\x8e\x8c\xdf;r\x8c\xce\xaa\xa5\x9c\xb8f\xeb=\x80\xa2\x11\xee\x7f\xa1)2\xb9\xde\xb4\xce\x0d\x93\xc9\x1dN%$.\x9a\xe9\x8b\x9cF\xd7o\xf3\xc4\xb9\xf6\xc7=[\xbf\xaf-E\xcdU\xae\x16\xb1l#f\xe0\x8f\x16)\x84O[Jf\x83\x18h\xaa9\xdaf\xd7\xc8V\xfa\xf3\x06v\xc9\xc7\x9dR*\x8b\x80W\x1bG+\xaf\xd1\xc0\x19&#39;<br>    ),<br>    plaintext,<br>    CAST(user_id AS STRING)<br>  )<br>);</pre><p>For <strong>Decryption</strong>, update UDF: kms_column_encryption.decrypt_user_email</p><blockquote>Update AEAD.DECRYPT_STRING() to DETERMINISTIC_DECRYPT_STRING()</blockquote><pre>CREATE OR REPLACE FUNCTION kms_column_encryption.decrypt_user_email(encrypted_email BYTES, user_id INT64) AS (<br>  DETERMINISTIC_DECRYPT_STRING(<br>    KEYS.KEYSET_CHAIN(<br>      &#39;gcp-kms://projects/myorder-data-platform-develop/locations/asia-southeast1/keyRings/tcolumn_level_encryption/cryptoKeys/customer_id&#39;,<br>     b&#39;\x0a$\x00\x88\x0c&quot;\x8fFB\x0bp\x17\xd0\xf5\xe6\xd36\x8e&lt;\xd1\xacgA\xbb@\xd9\x0b1[9\xb4[\x84\xb8W\x14\xe6\xc9\x12\x95\x01\x00\x90\xc0\x1e.\xdb\xbbE\x09-\x15o\xc0\xf5e.\x8d_\xfd\xf6\xf1\xbf\x84\xc2\xca\xa8\x81\xa0=f\x03\x8c\x96:\xeb\x85_\xe8\\\x0e\x02(\xceW\x03\x9c\x80(\xa9\x1f\xe2\x8e\x8c\xdf;r\x8c\xce\xaa\xa5\x9c\xb8f\xeb=\x80\xa2\x11\xee\x7f\xa1)2\xb9\xde\xb4\xce\x0d\x93\xc9\x1dN%$.\x9a\xe9\x8b\x9cF\xd7o\xf3\xc4\xb9\xf6\xc7=[\xbf\xaf-E\xcdU\xae\x16\xb1l#f\xe0\x8f\x16)\x84O[Jf\x83\x18h\xaa9\xdaf\xd7\xc8V\xfa\xf3\x06v\xc9\xc7\x9dR*\x8b\x80W\x1bG+\xaf\xd1\xc0\x19&#39;<br>    ),<br>    encrypted_email,<br>    CAST(user_id AS STRING)<br>  )<br>);</pre><h4>Rotate a wrapped keyset</h4><p>A wrapped keyset is different from your KMS key, which rotates automatically after a set period (90 days by default). In contrast, rotating a wrapped keyset is a separate process that you can perform whenever you are ready.</p><p>Here is how to rotate a wrapped keyset.</p><pre>SELECT KEYS.ROTATE_WRAPPED_KEYSET(<br>  KMS_KEY,<br>  WRAPPED_KEYSET_DECODED,<br>  &#39;AEAD_AES_GCM_256&#39;)</pre><p>After rotating a wrapped keyset, you will receive a new one and must update your UDF to use it.</p><p>The old keyset <strong>cannot decrypt</strong> new data, but the new keyset <strong>can still decrypt</strong> the old data.</p><h4>References:</h4><ul><li><a href="https://docs.cloud.google.com/kms/docs/create-key-ring">https://docs.cloud.google.com/kms/docs/create-key-ring</a></li><li><a href="https://docs.cloud.google.com/kms/docs/create-key">https://docs.cloud.google.com/kms/docs/create-key</a></li><li><a href="https://docs.cloud.google.com/bigquery/docs/column-key-encrypt">https://docs.cloud.google.com/bigquery/docs/column-key-encrypt</a></li><li><a href="https://docs.cloud.google.com/bigquery/docs/encryption-at-rest">https://docs.cloud.google.com/bigquery/docs/encryption-at-rest</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2e06f29aa02" width="1" height="1" alt=""><hr><p><a href="https://medium.com/myorder/hands-on-bigquery-data-encryption-and-key-rotation-a2e06f29aa02">Hands-on: BigQuery Data Encryption and Key Rotation</a> was originally published in <a href="https://medium.com/myorder">myorder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you shouldn’t streaming update to BigQuery]]></title>
            <link>https://medium.com/myorder/why-you-shouldnt-streaming-update-to-bigquery-4cac20c441e0?source=rss-a9b1a03b24a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cac20c441e0</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[data-streaming]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Karanrat Rattanawichai]]></dc:creator>
            <pubDate>Sat, 27 Sep 2025 10:36:26 GMT</pubDate>
            <atom:updated>2025-11-24T05:58:01.235Z</atom:updated>
            <content:encoded><![CDATA[<p>TLDR: Because it will cost you enormously!!!</p><p>What I mean by “<strong>streaming update</strong>” is when you have to update data <strong>row by row</strong> every time a new change comes in. There are two main reasons why you shouldn’t do this in BigQuery:</p><ol><li>BigQuery <strong>isn’t built for row-level updates.</strong></li><li>There’s a <strong>baseline cost for each job</strong>: small operations become inefficient, and you end up paying for more resources than you actually use.</li></ol><h4>First Reason: BigQuery <strong>isn’t built for row-level updates.</strong></h4><p>BigQuery’s columnar storage format, like that of other columnar databases, <a href="https://estuary.dev/blog/columnar-database/#:~:text=Limitations%20and%20Considerations">isn’t great for row-level operations</a>, especially updates and deletes. Because the data is stored in large, compressed blocks, modifying a single row often forces the system to <strong>decompress, change, and re-compress/rewrite</strong> the entire affected block for that column.</p><ul><li>Below is a SELECT operation that return a single row and a single column.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*an-92xwZ7TJNM3NHZkllLw.png" /><figcaption>SELECT operation processed 667.36 MB of Data</figcaption></figure><ul><li>Next is a UPDATE operation that update a single row and a single column.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNnjeKwm_vwj_kKCV69ToQ.png" /><figcaption>SELECT operation processed 31.71 GB of Data</figcaption></figure><p>As a result, the <strong>Bytes processed is for UPDATE operation is much more than a SELECT operation</strong>, even though we only target a single row and a single column with both queries.</p><p>Note: You can reduce Bytes processed for SELECT operation with partitioning, clustering and index search, but for UPDATE operation you can only use partitioning and clustering.</p><h4>Second Reason: The <strong>baseline cost for each job.</strong></h4><p>So, BigQuery offers two pricing models for computing costs.</p><p>1. <strong>On-Demand Pricing</strong>: You pay for the amount of data processed by your queries.</p><p>2. <strong>Capacity Pricing:</strong> You pay for query processing capacity, measured in slots (virtual CPUs) over time.</p><p>— —</p><p>For<strong> On-Demand Pricing, </strong>when your query processes less than 10MB of data, BigQuery will still charge you at the rate of 10MB. This means even if you optimize your UPDATE operation with partitioning and clustering, you will still <strong>be charged</strong> <strong>10MB each time a streamed update comes in</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qqg7P9AKWE_YH7GqIvYmcw.png" /><figcaption>BigQuery <strong>charged 10MB of data scanned</strong> when the actual job scanned only 6.1KB</figcaption></figure><p>For <strong>Capacity Pricing</strong>, a similar rule applies: you are billed per slot-second but with a 1-minute minimum charge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rhy7ayqzC-eZDlvhixmaVg.png" /><figcaption>BigQuery<strong> charged 1 minute of slot usage</strong> when the actual job only take 21 milliseconds</figcaption></figure><h4>How to handle updates stream in BigQuery?</h4><p>BigQuery has a<strong> </strong><a href="https://cloud.google.com/bigquery/docs/write-api"><strong>Storage Write API</strong></a><strong>, </strong>which can handle both streaming and batch inserts with really high performance. To handle update streams, you can <strong>insert-append</strong> the updated data as new row. After that, you can either create a view or a query with a window function to ignore the duplicated rows, or run a batch pipeline to deduplicate the data and load it into a new table.</p><p>Below is an example of a window function used to SELECT only the last updated row.</p><pre>WITH ranked_messages AS (<br>  SELECT<br>    *,<br>    ROW_NUMBER() OVER (PARTITION BY messageId ORDER BY updatedAt DESC) AS rank<br>  FROM<br>    `project-id`.`dimension`.`dimmessage` AS dimmessage<br>  -- Apply date partition here<br>  WHERE TIMESTAMP_TRUNC(createdAt, DAY) &gt;= TIMESTAMP(&quot;9999-01-01&quot;) <br><br>),<br>current_dimmessage AS (SELECT<br>  *<br>FROM<br>  ranked_messages<br>WHERE<br>  rank = 1)<br><br>-- Your query here<br>SELECT * FROM current_dimmessage</pre><p>Source:</p><ul><li><a href="https://estuary.dev/blog/columnar-database/#:~:text=Limitations%20and%20Considerations">What is a Columnar Database? How It Works + Best Use Cases and Examples</a></li><li><a href="https://cloud.google.com/bigquery/docs/write-api">Introduction to the BigQuery Storage Write API | Google Cloud</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJKN0nbxcNjGvj0pLRHzPw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cac20c441e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/myorder/why-you-shouldnt-streaming-update-to-bigquery-4cac20c441e0">Why you shouldn’t streaming update to BigQuery</a> was originally published in <a href="https://medium.com/myorder">myorder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Least privilege principle แบบเข้าใจง่าย]]></title>
            <link>https://medium.com/myorder/least-privilege-principle-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B9%80%E0%B8%82%E0%B9%89%E0%B8%B2%E0%B9%83%E0%B8%88%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2-58d011cbf411?source=rss-a9b1a03b24a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/58d011cbf411</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[least-privilege]]></category>
            <category><![CDATA[bigquery]]></category>
            <dc:creator><![CDATA[Karanrat Rattanawichai]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 14:38:51 GMT</pubDate>
            <atom:updated>2025-01-10T07:27:47.098Z</atom:updated>
            <content:encoded><![CDATA[<p>วิธีทำให้โปรเจคของคุณ Secure มากขึ้นด้วยหลักการ “Least privilege principle”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*0ZgMWSwdearVTtg-l3b6qg.png" /></figure><h3>Least privilege principle คืออะไร?</h3><p><strong>Least Privilege</strong> P<strong>rinciple</strong> เป็นหลักการที่กำหนดให้ผู้ใช้หรือโปรแกรมได้รับสิทธิ์ในการเข้าถึงทรัพยากรที่จำเป็นเท่านั้น รวมทั้งจำกัดการ Action ให้น้อยที่สุด เท่าที่เพียงพอต่อการใช้งาน</p><p>ยกตัวอย่างเช่น เพื่อนคุณมาขอลอกการบ้านวิชาภาษาอังกฤษ คุณก็ควรจะให้แค่วิชาภาษาอังกฤษวิชาเดียวถูกต้องไหมล่ะ แล้วทีนี้เนี่ยเราควรจะห้ามเพื่อนไว้ด้วยว่า อย่าไปลบหรือเขียนอะไรเพิ่ม ให้ดูได้อย่างเดียวนะ</p><h3>Least privilege principle ควรใช้ตอนไหน?</h3><p>หลักการนี้ใช้ได้และควรใช้กับทุกโปรเจคที่มีเรื่องสิทธิ์การใช้งานต่างๆ ไม่ว่าจะเป็น Application, Web application, Software, Cloud project, Storage, Database etc.</p><p>ซึ่งในระหว่าง Development จริงๆ เราก็ควรทำตาม Least privilege principle แต่อาจไม่ต้องเคร่งมากก็ได้ เอาที่พอเหมาะและไม่ทำให้การทำงานล่าช้า แต่พอขึ้น production แล้วเนี่ย คุณควรเป็นอย่างยิ่งที่ต้องจำกัดสิทธิ์ให้มากที่สุด เพราะถ้ามี account ที่มีสิทธิ์เยอะมากๆ หลุดไปเนี่ยจะเป็นเรื่องได้</p><h3>ตัวอย่างการใช้งานจริงบน Google Cloud Project</h3><p>Resources บน Google Cloud Project (GCP) นั้นจะถูก access ได้เฉพาะ User หรือ Service Account ที่มีสิทธิ์ใช้งาน</p><p><strong>ตัวอย่างที่ไม่ดี:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8bqENJDbJbJUs_VqI1DgPw.png" /><figcaption>Service Account Name: medium-blog</figcaption></figure><p>Service account ตัวนี้ มีอยู่ 2 Role คือ</p><ol><li>BigQuery Data Editor</li><li>BigQuery Job User</li></ol><p>การทำแบบนี้จะทำให้ Service Account ตัวนี้ ดูและแก้ไขข้อมูลได้ทุก Dataset และ Table ซึ่งไม่ควรทำเป็นอย่างยิ่ง</p><p><strong>ตัวอย่างที่ตรงตามหลัก Least privilege principle:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kl00u308FB_yWnfYDPkd9w.png" /></figure><p>Service account ตัวนี้มี Role เดียวคือ BigQuery Job User ซึ่งจำเป็นเพื่อใช้ในการ Query ข้อมูล</p><p>ไปที่ BigQuery และเลือก Table ที่ต้องการให้ Access</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xh8jD11SaYeLFIIpVGjFmg.png" /></figure><p>กดไปที่ “ADD PRINCIPAL”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXuwp6ORDlNZuZnAaCmU6Q.png" /></figure><p>เพิ่ม Role “BigQuery Data Editor”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*cr0r1xBIGinWum_mYxgdhQ.png" /></figure><p>เรียบร้อย!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-I7L3IRHoI8a8mE1sjkvw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58d011cbf411" width="1" height="1" alt=""><hr><p><a href="https://medium.com/myorder/least-privilege-principle-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B9%80%E0%B8%82%E0%B9%89%E0%B8%B2%E0%B9%83%E0%B8%88%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2-58d011cbf411">Least privilege principle แบบเข้าใจง่าย</a> was originally published in <a href="https://medium.com/myorder">myorder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dataform vs Serverless DBT (on GCP)]]></title>
            <link>https://medium.com/myorder/dataform-vs-serverless-dbt-on-gcp-596e51a81747?source=rss-a9b1a03b24a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/596e51a81747</guid>
            <category><![CDATA[dataform]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Karanrat Rattanawichai]]></dc:creator>
            <pubDate>Wed, 04 Dec 2024 13:08:15 GMT</pubDate>
            <atom:updated>2024-12-04T16:08:21.176Z</atom:updated>
            <content:encoded><![CDATA[<p>เพื่อนๆ ที่ทำงานสาย Data น่าจะเคยได้ยิน Tool ที่ชื่อว่า DBT (Data build tool) กันมาบ้างแล้ว ซึ่ง DBT นั้นเป็นน้องใหม่ที่มาแรงมากๆๆ ในต่างชาตินี่ยกให้เป็น “The New Standard of Data Transformation” กันเลยทีเดียว</p><blockquote>ถ้าใครอยากรู้จัก DBT เพิ่มเติมสามารถอ่านได้ที่ <a href="https://datarockie.com/blog/dbt/">Blog</a> นี้เลยครับ</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NrHBb9HRa89_hkH0.png" /><figcaption><a href="https://docs.getdbt.com/docs/introduction">https://docs.getdbt.com/docs/introduction</a></figcaption></figure><p>แล้วเพื่อนๆ รู้ไหมว่าบน Google Cloud Platform มี Tool ตัวหนึ่งที่ทำหน้าที่เหมือน DBT ด้วยนะ Tool ตัวนั้นมีชื่อว่า Dataform ซึ่งเป็น Serverless Service ที่สามารถใช้กับ BigQuery โดยไม่เสียค่าใช้จ่ายเพิ่มเลย (แต่ยังเสียค่า Operation ใน BigQuery อยู่ดีนะ)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cCcBcWRlLzNjl6H7.png" /><figcaption><a href="https://cloud.google.com/dataform/docs/overview">https://cloud.google.com/dataform/docs/overview</a></figcaption></figure><p>วันนี้ผมจะมาแชร์ประสบการณ์การได้ลองใช้ทั้ง Dataform และ Serverless DBT ในการทำ Data Transformation โปรเจคเล็กๆ บน BigQuery ครับ</p><p><strong>⚠️ Disclaimer:</strong> ต้องบอกไว้ก่อนว่าทั้ง DBT และ Dataform นั้นมี features ให้เลือกใช้เยอะมากๆ จึงไม่สามารถทดลองใช้ได้ทั้งหมด หากตกหล่นประเด็นไหนที่สำคัญไปก็ขออภัยมา ณ ที่นี้ด้วยครับ เพื่อนๆ ช่วยแนะนำกันมาได้เลยครับ</p><h4>Table of Contents</h4><ol><li><a href="#cb4a">Introduction</a><br>- <a href="#e617">Why Serverless DBT?</a><br>- <a href="#2978">How to make Serverless DBT?</a></li><li><a href="#e5f8">Comparison</a><br>- <a href="#9fe2">Google Trend<br></a>- <a href="#c0f5">Ease of use</a><br>- <a href="#5460">Features</a><br>- <a href="#cbdc">Governance</a><br>- <a href="#bb97">Cost</a></li><li><a href="#ace5">Conclusion</a></li></ol><h3><strong>Introduction</strong></h3><p>ในบทความนี้จะเปรียบเทียบ Serverless DBT กับ Dataform ขอย้ำว่าเป็น “<strong>Serverless DBT</strong>” ซึ่ง concept นี้จะทำให้บาง Features ของ DBT นั้นไม่สามารถใช้งานได้อย่างเต็มประสิทธิภาพ เช่น dbt docs เป็นต้น</p><p><strong>Why Serverless DBT?</strong></p><p>บน Google Cloud Platform นั้นมี Tools อย่าง Dataplex ซึ่งเป็น Metadata Platform ที่ช่วยทำเรื่อง Documentation ของข้อมูล อีกทั้ง BigQuery ก็มี Features Data Quality, Data lineage, Data dictionary เข้ามาช่วยในการพัฒนาด้วย</p><p>ทำให้สิ่งที่ทีมต้องการตอนนี้มีแค่ Core หลักของ DBT นั้นก็คือ Data Transformation ดังนั้นทีมเลยหาทางที่จะทำให้ DBT เป็น Serverless Service ที่สามารถ Trigger การ Transform ข้อมูลตาม Schedule ได้</p><p>ในเมื่อ Dataform เป็น Serverless และเปิดให้ใช้ได้ฟรี ดังนั้นคู่แข่งก็ต้องเหมาะสมกันหน่อย ถ้าตั้งเครื่อง DBT ไว้ แต่ได้ใช้แค่ไม่กี่ชั่วโมงต่อวันก็เสียดายเงินอยู่ใช่ไหมล่า</p><p><strong>How to make Serverless DBT?</strong></p><p>วิธีการทำ Serverless DBT นั้นจะใช้ Service บน Google Cloud Platform ที่ชื่อว่า Cloud run jobs ซึ่ง Cloud run นั้นเป็น Serverless ในตัวมันเองอยู่แล้ว สิ่งที่เราต้องทำก็แค่สร้าง DBT Project ไว้ใน Cloud run และสร้างฟังก์ชันสำหรับ Trigger Cloud run และ Overwrite คำสั่งที่เราต้องการสั่งให้กับ DBT Core เช่น ถ้าต้องการ debug ก็ Overwrite คำสั่งเป็น “dbt” “debug” ได้เลย</p><blockquote>หากใครสนใจเรื่อง DBT Core บน Cloud run jobs สามารถดูเพิ่มเติมได้ที่นี่เลยครับ <a href="https://www.youtube.com/watch?v=OGRNIXZQhd0">https://www.youtube.com/watch?v=OGRNIXZQhd0</a></blockquote><h3>Comparison</h3><p><strong>Google Trend</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSbkgziKlODSet5snoTAGw.png" /><figcaption><a href="https://trends.google.co.th/trends/">https://trends.google.co.th/trends/</a></figcaption></figure><p>สัดส่วนของ Trend ในภาพนั้นคิดเป็น 91.4 : 8.6 โดยผู้นำคือ DBT</p><p>เรื่องของ Community นั้น ณ ปัจจุบัน DBT นั้นใหญ่กว่า Dataform ราวๆ 10 เท่า แต่ก็เข้าใจได้เพราะ Dataform นั้นเป็นน้องใหม่กว่า DBT และยังเป็น Tool ที่อยู่บน GCP อีก ทำให้ Dataform อาจจะไม่เข้าตาคนที่ใช้ On-Premise data stack หรือ Cloud Platform อื่นๆ</p><p>แต่ยังไงก็ตาม “DBT take the cake on this one!”</p><p><strong>Ease of use</strong></p><p>1. การติดตั้ง และ Deploy</p><p><strong>DBT:</strong> การติดตั้งของ DBT นั้นง่ายมากๆ สิ่งที่ต้องทำก็มีสร้าง venv ติดตั้ง DBT Core และ DBT Adapter ก็สามารถใช้งานได้แล้ว</p><p>ส่วนการ Deploy ขึ้น GCP ก็ทำได้ไม่ยาก โดย Step จะมี<br>1. Build Docker Image<br>2. Push ขึ้น Artifact Registry<br>3. Deploy เป็น Cloud run jobs</p><p>—</p><p><strong>Dataform: </strong>ส่วน Dataform นั้น ไม่ต้องติดตั้งอะไรเลย…. เข้าไปที่เมนู Dataform ใน BigQuery แล้วสามารถสร้างโมเดล รันโมเดลได้เลย มี UI พร้อม เขียนโค้ดบน UI ได้ เขียนโค้ดเสร็จแล้ว Run ได้เลยไม่ต้อง Deploy</p><p>ถ้าใช้งานบน GCP Console (UI) เป็นหลักก็มี Git ให้ใช้ด้วยและทำได้ไม่ยาก สามารถเชื่อมได้ทั้ง GitLab และ GitHub ถ้าอยากใช้งานบน Local ก็มี Cli ให้ใช้ด้วยนะ</p><p>2. การ Execute</p><p><strong>DBT: </strong>การ Execute Serverless DBT บน Cloud run สามารถทำบน UI โดยไปที่ Cloud run job และเลือก Execute with overrides</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dw9j-B6s4XxfqqarxoJMow.png" /></figure><p><strong>Dataform: </strong>ในการ Execute บน Cloud Dataform นั้นสามารถ Execute ที่ UI ได้เลย และมี Option ให้เลือกหลายอยาก ทั้ง Execute tag ที่เลือก, Execute action + dependencies/dependents</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*CS_O1RJ2D5hVV_n1r_DHSA.png" /></figure><p>3. การ Schedule</p><p>ในส่วนนี้ทั้งสองนั้นสามารถทำได้ด้วยวิธีเดียวกัน แค่สลับจากการ Trigger cloud run เป็น Trigger Dataform หรือจะเอาทั้ง 2 มาใช้ร่วมกันก็ยังได้</p><p><strong>ในส่วนของ Ease of use</strong> ผมให้ Dataform เป็นผู้ชนะเนื่องจากการติดตั้ง / Deploy ที่ง่ายกว่า และการ Execute มี UI ที่ตอบโจทย์มากกว่าไปใช้ Cloud run ที่ต้อง Overwrite คำสั่ง</p><p><strong>Features</strong></p><p>สำหรับ Features นั้น DBT Core นั้นทำได้ทุกอย่างที่ Dataform Core ทำได้ Dataform Core มี Mandatory Features อย่าง Model Materialization, UDF (macros in DBT), Assertion, Model config, Dependencies config ครบและพร้อมใช้งาน</p><p>แต่ DBT มี 2 Features ที่ Dataform ไม่มี และทำให้ผมรู้สึกว่า Developing Experiences บน DBT นั้นดีกว่า นั่นก็คือ Unit test และ Snapshot</p><p>Dataform มี feature unit test อยู่ แต่ว่าไม่มี document ที่บอกวิธีการใช้ และมี Error ที่ออกมาไม่สมเหตุสมผลทำให้ Debug ยาก และในตอนนี้ unit test ไม่สามารถใช้กับ incremental model ได้ด้วย ส่วน snapshot อันนี้ผมไม่เห็นใน Dataform (แต่น่าจะใช้ snapshot ของ BigQuery ได้ ใครเคยใช้มาแนะนำกันได้นะครับ)</p><p><strong>ในส่วนของ Features:</strong> DBT นั้นมี Features ที่เยอะและหลากหลายกว่า Dataform</p><p><strong>Governance</strong></p><p>Testing: ทั้งสองสามารถทำ Assertion test ได้ดี แต่เรื่องของ Unit test DBT นั้นทำได้ดีกว่ามากๆ</p><p>Logging &amp; alerts: ทั้งสองสามารถทำได้ด้วย <a href="https://cloud.google.com/logging/docs?authuser=1">Cloud Logging</a>.</p><p>Documentation &amp; Data lineage: เนื่องจาก DBT เป็นแบบ Serverless ทำให้ไม่สามารถทำ Realtime Documentation และ Data lineage, Dataform จึงสะดวกกว่าในเรื่องนี้</p><p><strong>ในส่วนของ Governance: </strong>ทั้งสองเสมอกันครับ</p><p><strong>Cost</strong></p><p><strong>DBT: </strong>ถึงจะเป็น Serverless แต่ก็ยังมีค่าใช้จ่ายอยู่เล็กน้อยในเวลาที่ Job run ในเคสนี้ผมจะคำนวณโดยกำหนดว่าจะรัน job ทุกวันวันละ 1 ชั่วโมง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fD1pDm04bdtc_UWFz3OuVg.png" /></figure><p>คิดเป็น 2.46 Dollars ต่อเดือน</p><p><strong>Dataform: </strong>ไม่เสียค่าใช้จ่าย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_SF2sxzb-vUd57ff7LT4A.png" /></figure><p><strong>ในส่วนของ Cost: </strong>Dataform นั้นถูกกว่า แต่โดยรวมแล้วทั้งสองมี Cost ที่ Neglectable ได้ครับ</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*Cj9yWlMq_s3ZI4uwMePwYw.png" /></figure><p>นี่ก็จะเป็นบทสรุปที่ผมได้ลองใช้ Tools ทั้งสองตัวนี้มาครับ หวังว่าจะเป็นประโยชน์กับเพื่อนๆ นะครับ</p><h3>References</h3><ul><li><a href="https://datarockie.com/blog/dbt/">https://datarockie.com/blog/dbt/</a></li><li><a href="https://medium.com/refined-and-refactored/dbt-vs-dataform-which-one-should-you-choose-213386ff69dd">https://medium.com/refined-and-refactored/dbt-vs-dataform-which-one-should-you-choose-213386ff69dd</a></li><li><a href="https://www.youtube.com/watch?v=OGRNIXZQhd0">https://www.youtube.com/watch?v=OGRNIXZQhd0</a></li><li><a href="https://github.com/richardhe-fundamenta/dbt-on-cloud-run">https://github.com/richardhe-fundamenta/dbt-on-cloud-run</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M0M4cs26HLvQMhh4CrGQNg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=596e51a81747" width="1" height="1" alt=""><hr><p><a href="https://medium.com/myorder/dataform-vs-serverless-dbt-on-gcp-596e51a81747">Dataform vs Serverless DBT (on GCP)</a> was originally published in <a href="https://medium.com/myorder">myorder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เปรียบเทียบ Geocoding ทั้งหมด 8 เจ้า (หาพิกัดจาก Address)]]></title>
            <link>https://medium.com/myorder/%E0%B9%80%E0%B8%9B%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%9A%E0%B9%80%E0%B8%97%E0%B8%B5%E0%B8%A2%E0%B8%9A-geocoding-%E0%B8%97%E0%B8%B1%E0%B9%89%E0%B8%87%E0%B8%AB%E0%B8%A1%E0%B8%94-8-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2-%E0%B8%AB%E0%B8%B2%E0%B8%9E%E0%B8%B4%E0%B8%81%E0%B8%B1%E0%B8%94%E0%B8%88%E0%B8%B2%E0%B8%81-address-2a13d45461bc?source=rss-a9b1a03b24a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a13d45461bc</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[address]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[geocoding]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Karanrat Rattanawichai]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 16:05:42 GMT</pubDate>
            <atom:updated>2024-12-04T06:41:14.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P1ZnO0_WEFoWOzzE" /></figure><p>ในบทความนี้ผมจะเล่าถึง Research เล็กๆ ที่ผมทำ เพื่อเลือก Geocoding API ที่แม่นยำที่สุดมาใช้ครับ ประเด็นที่จะพูดถึงจะมีเรื่อง กระบวนการที่ใช้ ทริคเล็กๆ น้อยๆ และผลลัพธ์ที่ได้ครับ หวังว่าเพื่อนจะได้ประโยชน์ไม่มากก็น้อยจากบทความนี้ครับ</p><h3>Goals</h3><p>เป้าหมายของผมคือการทำแผนที่ระบุตำแหน่งของสถานที่จำนวนหนึ่ง แต่ข้อมูลที่มีนั้นอยู่ในรูปแบบ Text address ยกตัวอย่าง เช่น</p><p>“จังหวัดชลบุรี อำเภอศรีราชา ตำบลหนองขาม 20230 หมู่บ้าน บลูเลอวาร์ด บ้านเลขที่ xx/xxx ซอย x หมู่ที่ x”</p><p>หรืออีกตัวอย่างที่ข้อมูลไม่ละเอียดมากนัก</p><p>“จังหวัดภูเก็ต อำเภอเมืองภูเก็ต ตำบลวิชิต 83000 xx/xxx”</p><p>ซึ่งการจะแปลงที่อยู่ดังกล่าวให้เป็นพิกัดได้มีอยู่หลายวิธี อย่างเช่น Geocoding API, Text search API, Place Autocomplete + Place details API ในวันนี้ผมจะมาพูดถึง Geocoding API นะครับ</p><h3>Process</h3><p>ผมได้เตรียม Text address พร้อมพิกัดที่ถูกต้องมาจำนวน 1000 records จากนั้นจะใช้ Python ในการส่ง request ไปยัง Geocoding API ของแต่ละเจ้า และเก็บ response มาเป็นรูปแบบ CSV และ JSON</p><p>CSV นั้นจะนำมาเปรียบเทียบความแม่นยำ โดยการหาระยะทางที่คลาดเคลื่อนไปจากพิกัดที่ถูกต้อง ส่วน JSON จะใช้วิเคราะห์ในส่วนความน่าใช้งาน ซึ่งจะดูจากฟิลด์ต่างๆ ที่ API response กลับมา เพราะบางเจ้าก็มี response ที่ละเอียด มี Query score/Confident score บางเจ้า response structure ไม่ดี อาจจะนำมาใช้ต่อได้ยาก</p><p>โดย Geocoding API ที่ผมเลือกมามีดังนี้</p><ol><li><a href="#20b8">Google</a></li><li><a href="#2275">Awesome Table</a></li><li><a href="#c24e">Longdo</a></li><li><a href="#e6ff">Mapbox</a></li><li><a href="#f29c">Here</a></li><li><a href="#19ab">Pinpoint</a></li><li><a href="#6821">OpenCage</a></li><li><a href="#0e7e">Geoapify</a></li><li><strong>Google</strong></li></ol><p>มาเริ่มที่เจ้าตลาดกันก่อนเลย มาดูกันว่าจะมีใครล้ม Google ได้ไหม</p><p><strong>Request</strong></p><p>Geocoding API ของ Google จะใช้ Method GET มีพารามิเตอร์ที่น่าใช้ก็จะเป็นตัว “components” สามารถป้อน ประเทศ จังหวัด ตำบล รหัสไปรษณีย์ ได้เลย ผมแนะนำว่าให้ใส่แค่ประเทศกับรหัสไปรษณีย์ เพราะชื่อจังหวัด อำเภอ ตำบล มีโอกาสเขียนไม่เหมือนกัน อาจจะทำให้ผลลัพธ์คลาดเคลื่อน</p><p>ตอนส่ง request อย่าลืม replace ช่องว่างเป็น “+” ด้วยนะ</p><pre>https://maps.googleapis.com/maps/api/geocode/json?address=999/999+หมู่ที่+9+ต.นาป่า+อ.เมืองชลบุรี+จ.ชลบุรี&amp;components=country:TH|postal_code:20000&amp;key={insert_your_key}&amp;language=TH</pre><p><strong>Response</strong></p><pre>{<br>    &quot;results&quot;: [<br>        {<br>            &quot;address_components&quot;: [<br>                {<br>                    &quot;long_name&quot;: &quot;X&quot;,<br>                    &quot;short_name&quot;: &quot;X&quot;,<br>                    &quot;types&quot;: [<br>                        &quot;premise&quot;<br>                    ]<br>                },<br>                {<br>                    &quot;long_name&quot;: &quot;ตำบล นาป่า&quot;,<br>                    &quot;short_name&quot;: &quot;ต.นาป่า&quot;,<br>                    &quot;types&quot;: [<br>                        &quot;locality&quot;,<br>                        &quot;political&quot;<br>                    ]<br>                },<br>                {<br>                    &quot;long_name&quot;: &quot;อำเภอเมืองชลบุรี&quot;,<br>                    &quot;short_name&quot;: &quot;อำเภอเมืองชลบุรี&quot;,<br>                    &quot;types&quot;: [<br>                        &quot;administrative_area_level_2&quot;,<br>                        &quot;political&quot;<br>                    ]<br>                },<br>                {<br>                    &quot;long_name&quot;: &quot;ชลบุรี&quot;,<br>                    &quot;short_name&quot;: &quot;จ.ชลบุรี&quot;,<br>                    &quot;types&quot;: [<br>                        &quot;administrative_area_level_1&quot;,<br>                        &quot;political&quot;<br>                    ]<br>                },<br>                {<br>                    &quot;long_name&quot;: &quot;ประเทศไทย&quot;,<br>                    &quot;short_name&quot;: &quot;TH&quot;,<br>                    &quot;types&quot;: [<br>                        &quot;country&quot;,<br>                        &quot;political&quot;<br>                    ]<br>                },<br>                {<br>                    &quot;long_name&quot;: &quot;20000&quot;,<br>                    &quot;short_name&quot;: &quot;20000&quot;,<br>                    &quot;types&quot;: [<br>                        &quot;postal_code&quot;<br>                    ]<br>                }<br>            ],<br>            &quot;formatted_address&quot;: &quot;X ตำบล นาป่า อำเภอเมืองชลบุรี ชลบุรี 20000 ประเทศไทย&quot;,<br>            &quot;geometry&quot;: {<br>                &quot;location&quot;: {<br>                    &quot;lat&quot;: 13.368738,<br>                    &quot;lng&quot;: 101.0466489<br>                },<br>                &quot;location_type&quot;: &quot;ROOFTOP&quot;,<br>                &quot;viewport&quot;: {<br>                    &quot;northeast&quot;: {<br>                        &quot;lat&quot;: 13.3700213802915,<br>                        &quot;lng&quot;: 101.0479380302915<br>                    },<br>                    &quot;southwest&quot;: {<br>                        &quot;lat&quot;: 13.3673234197085,<br>                        &quot;lng&quot;: 101.0452400697085<br>                    }<br>                }<br>            },<br>            &quot;partial_match&quot;: true,<br>            &quot;place_id&quot;: &quot;ChIJrYizaUA0HTERreCS0kgn7kQ&quot;,<br>            &quot;types&quot;: [<br>                &quot;premise&quot;<br>            ]<br>        }<br>    ],<br>    &quot;status&quot;: &quot;OK&quot;<br>}</pre><p>Response ถือว่าโอเคเลย มีทั้ง address แบบเต็ม แบบแยก และที่สำคัญคือมี “location_type” บอกว่าเป็น result ชนิดอะไร อย่างตัวอย่าง ROOFTOP ก็คือเป็นตัวบ้านเลย</p><p><strong>Result</strong></p><p>ผมจะแบ่งผลลัพธ์ออกเป็น 5 หมวดหมู่ ได้แก่ ผลลัพธ์ที่คลาดเคลื่อนเพียงแค่ 0–10 เมตร ผลลัพธ์ที่คลาดเคลื่อน 11–100 เมตร ผลลัพธ์ที่คลาดเคลื่อน 101–1000 เมตร และอื่นๆ ดังแผนภูมิด้านล่าง ซึ่งผลลัพธ์ที่ผมสนใจจะเป็นพิกัดที่คลาดเคลื่อนไม่เกิน 100 เมตร</p><p>***Not found หมายถึง ไม่มีข้อมูล return กลับมา หรือ มีความคลาดเคลื่อนมากกว่า 10,000 เมตร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Hhwgmb6NPY9--Qr5zCHyg.png" /><figcaption>Google API’s accuracy result</figcaption></figure><p>ความคลาดเคลื่อนเฉลี่ย : 802.9719664357046 เมตร</p><p>2. <strong>Awesome Table</strong></p><p>Geocoding ของ Awesome Table จะไม่ได้มาเป็นรูปแบบของ API แต่จะเป็นส่วนขยายใน Google Sheet ซึ่งใช้ง่ายมากๆ แค่ต้องเตรียมข้อมูล address ไว้ในคอลัมน์หนึ่ง จากนั้นเลือกคอลัมน์ที่จะใช้ในการเจน Lat, Lng ก็เรียบร้อยแล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sG4tWov2ecBWquQ0wbMrHQ.png" /></figure><p><strong>Result</strong></p><p>ผลลัพธ์คล้ายกับ Google มากๆ มีหลาย record เลยที่ result เหมือนกันเป๊ะ ถ้าใครมองหา Google alternative ก็ลองอันนี้กันได้นะ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WvRwj4JaxkeA7NIs4KziOg.png" /><figcaption>Awesome Table API’s accuracy result</figcaption></figure><p>ความคลาดเคลื่อนเฉลี่ย : 998.6603692888319 เมตร</p><p>3. <strong>Longdo</strong></p><p><strong>Request</strong></p><p>Longdo ไม่ค่อยมีลูกเล่นใน request ซักเท่าไหร่ เพราะงั้นจะใช้แบบธรรมดาๆ ไปเลย</p><p>ตอนส่ง request ต้อง replace ช่องว่างเป็น “%20” และลูกน้ำ(,) เป็น “%2C” ด้วย</p><pre>https://search.longdo.com/addresslookup/api/addr/geocoding?text=999/999%20หมู่ที่%209%20ต.นาป่า%20อ.เมืองชลบุรี%20จ.ชลบุรี&amp;key={LongdoAPIKey}</pre><p><strong>Response</strong></p><p>1000 request ใช้เวลา 46 นาที ถือว่าค่อนข้างนานเลย (เนื่องจากแพกเกจฟรีมีการตั้ง Limit เอาไว้) เทียบกับ Google ที่ใช้เวลาไม่เกิน 2 นาที</p><pre>[<br>    {<br>        &quot;data&quot;: [<br>            {<br>                &quot;confidence&quot;: 0.6620879,<br>                &quot;location&quot;: {<br>                    &quot;zipcode&quot;: &quot;10250&quot;,<br>                    &quot;province&quot;: {<br>                        &quot;distance&quot;: 1,<br>                        &quot;prefix&quot;: false,<br>                        &quot;name&quot;: &quot;กรุงเทพมหานคร&quot;<br>                    },<br>                    &quot;road&quot;: {<br>                        &quot;distance&quot;: null,<br>                        &quot;prefix&quot;: null,<br>                        &quot;name&quot;: &quot;&quot;<br>                    },<br>                    &quot;subdistrict&quot;: {<br>                        &quot;distance&quot;: 1,<br>                        &quot;prefix&quot;: false,<br>                        &quot;name&quot;: &quot;อ่อนนุช&quot;<br>                    },<br>                    &quot;district&quot;: {<br>                        &quot;distance&quot;: 1,<br>                        &quot;prefix&quot;: false,<br>                        &quot;name&quot;: &quot;สวนหลวง&quot;<br>                    },<br>                    &quot;condominium&quot;: {<br>                        &quot;distance&quot;: null,<br>                        &quot;prefix&quot;: null,<br>                        &quot;name&quot;: &quot;&quot;<br>                    },<br>                    &quot;houseno&quot;: &quot;1419&quot;,<br>                    &quot;village_official&quot;: {<br>                        &quot;distance&quot;: null,<br>                        &quot;prefix&quot;: null,<br>                        &quot;name&quot;: &quot;&quot;<br>                    },<br>                    &quot;moo&quot;: &quot;&quot;,<br>                    &quot;village&quot;: {<br>                        &quot;distance&quot;: null,<br>                        &quot;prefix&quot;: null,<br>                        &quot;name&quot;: &quot;&quot;<br>                    },<br>                    &quot;alley&quot;: {<br>                        &quot;distance&quot;: null,<br>                        &quot;prefix&quot;: null,<br>                        &quot;name&quot;: &quot;&quot;<br>                    },<br>                    &quot;point&quot;: {<br>                        &quot;distance&quot;: null,<br>                        &quot;prefix&quot;: null,<br>                        &quot;name&quot;: &quot;&quot;<br>                    }<br>                },<br>                &quot;point&quot;: [<br>                    {<br>                        &quot;lon&quot;: 100.62645622455278,<br>                        &quot;lat&quot;: 13.709640223964701<br>                    },<br>                    {<br>                        &quot;lon&quot;: 100.62413518307635,<br>                        &quot;lat&quot;: 13.7097815249114<br>                    }<br>                ]<br>            }<br>        ],<br>        &quot;meta&quot;: &quot;xxxx อ่อนนุช, อ่อนนุช, สวนหลวง, กรุงเทพมหานคร, 10250 ประเทศไทย&quot;<br>    }<br>]</pre><p>ไม่มี full address (meta คือข้อมูล input) ไม่มี result type และ lat, lng บางทีมี 2 ค่า ไม่มีรายละเอียดบอกว่าทั้งสองต่างกันยังไง</p><p><strong>Result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1f7Gl9hMa0YGYsSr8ybyiA.png" /><figcaption>Longdo API’s accuracy result</figcaption></figure><p>ความคลาดเคลื่อนเฉลี่ย : 16985.010446836284 เมตร</p><p>4. <strong>Mapbox</strong></p><p><strong>Request</strong></p><p>ของ Mapbox จะมี Optional parameter ชื่อ country ให้เราฟิลเตอร์ประเทศที่ต้องการได้</p><pre>https://api.mapbox.com/search/geocode/v6/forward?q=999/999%20หมู่ที่%209%20ต.นาป่า%20อ.เมืองชลบุรี%20จ.ชลบุรี&amp;access_token={mapbox_token}&amp;country=TH&amp;language=th</pre><p><strong>Response</strong></p><p>ไม่มี Confident score มาให้ แต่โดยรวมแล้วถือว่าใช้ได้เลย</p><pre>{<br>    &quot;type&quot;: &quot;Feature&quot;,<br>    &quot;id&quot;: &quot;address.3940607886919088&quot;,<br>    &quot;geometry&quot;: {<br>        &quot;type&quot;: &quot;Point&quot;,<br>        &quot;coordinates&quot;: [<br>            101.228954,<br>            12.702878<br>        ]<br>    },<br>    &quot;properties&quot;: {<br>        &quot;mapbox_id&quot;: &quot;address.3940607886919088&quot;,<br>        &quot;feature_type&quot;: &quot;street&quot;,<br>        &quot;full_address&quot;: &quot;ซอย 4, 21000, อำเภอเมืองระยอง, จังหวัดระยอง, ประเทศไทย&quot;,<br>        &quot;name&quot;: &quot;ซอย 4&quot;,<br>        &quot;name_preferred&quot;: &quot;ซอย 4&quot;,<br>        &quot;coordinates&quot;: {<br>            &quot;longitude&quot;: 101.228954,<br>            &quot;latitude&quot;: 12.702878<br>        },<br>        &quot;place_formatted&quot;: &quot;21000, อำเภอเมืองระยอง, จังหวัดระยอง, ประเทศไทย&quot;,<br>        &quot;context&quot;: {<br>            &quot;street&quot;: {<br>                &quot;mapbox_id&quot;: &quot;address.3940607886919088&quot;,<br>                &quot;name&quot;: &quot;ซอย 4&quot;<br>            },<br>            &quot;postcode&quot;: {<br>                &quot;mapbox_id&quot;: &quot;dXJuOm1ieHBsYzpFUTdk&quot;,<br>                &quot;name&quot;: &quot;21000&quot;<br>            },<br>            &quot;place&quot;: {<br>                &quot;mapbox_id&quot;: &quot;dXJuOm1ieHBsYzpOQ2pk&quot;,<br>                &quot;name&quot;: &quot;อำเภอเมืองระยอง&quot;,<br>                &quot;wikidata_id&quot;: &quot;Q476074&quot;,<br>                &quot;translations&quot;: {<br>                    &quot;th&quot;: {<br>                        &quot;language&quot;: &quot;th&quot;,<br>                        &quot;name&quot;: &quot;อำเภอเมืองระยอง&quot;<br>                    }<br>                }<br>            },<br>            &quot;region&quot;: {<br>                &quot;mapbox_id&quot;: &quot;dXJuOm1ieHBsYzpCeVRk&quot;,<br>                &quot;name&quot;: &quot;จังหวัดระยอง&quot;,<br>                &quot;wikidata_id&quot;: &quot;Q335221&quot;,<br>                &quot;region_code&quot;: &quot;21&quot;,<br>                &quot;region_code_full&quot;: &quot;TH-21&quot;,<br>                &quot;translations&quot;: {<br>                    &quot;th&quot;: {<br>                        &quot;language&quot;: &quot;th&quot;,<br>                        &quot;name&quot;: &quot;จังหวัดระยอง&quot;<br>                    }<br>                }<br>            },<br>            &quot;country&quot;: {<br>                &quot;mapbox_id&quot;: &quot;dXJuOm1ieHBsYzpJdDA&quot;,<br>                &quot;name&quot;: &quot;ประเทศไทย&quot;,<br>                &quot;wikidata_id&quot;: &quot;Q869&quot;,<br>                &quot;country_code&quot;: &quot;TH&quot;,<br>                &quot;country_code_alpha_3&quot;: &quot;THA&quot;,<br>                &quot;translations&quot;: {<br>                    &quot;th&quot;: {<br>                        &quot;language&quot;: &quot;th&quot;,<br>                        &quot;name&quot;: &quot;ประเทศไทย&quot;<br>                    }<br>                }<br>            }<br>        }<br>    }<br>}</pre><p><strong>Result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5jvlnUUCYTu3CXtbLfdvIg.png" /><figcaption>Mapbox API’s accuracy result</figcaption></figure><p>ความคลาดเคลื่อนเฉลี่ย : 35588.548093202575 เมตร</p><p>5. <strong>Here</strong></p><p><strong>Request</strong></p><p>มี Optional parameter ชื่อ qq สามารถเซ็ต Bias ประเทศ/จังหวัด/อำเภอ/ตำบล/รหัสไปรษณีย์ได้ครับ</p><pre>https://geocode.search.hereapi.com/v1/geocode?qq=country=Thailand;postalCode={zipcode}&amp;q=999/999%20หมู่ที่%209%20ต.นาป่า%20อ.เมืองชลบุรี%20จ.ชลบุรี&amp;limit=10&amp;apiKey={HereAPIKey}</pre><p><strong>Response</strong></p><p>โครงสร้างถือว่าดีเลยครับ ข้อมูลครบ เข้าใจง่าย นำไปใช้ต่อได้ง่าย</p><pre>{<br>        &quot;items&quot;: [<br>            {<br>                &quot;title&quot;: &quot;x พระราม 2 ซอย 28, จอมทอง, กรุงเทพมหานคร, 10150 ประเทศไทย&quot;,<br>                &quot;id&quot;: &quot;here:af:streetsection:hHIoOjJzVZUYszbqDnpYfB:CggIBCCqqZuRAxABGgE1&quot;,<br>                &quot;resultType&quot;: &quot;houseNumber&quot;,<br>                &quot;houseNumberType&quot;: &quot;PA&quot;,<br>                &quot;address&quot;: {<br>                    &quot;label&quot;: &quot;x พระราม 2 ซอย 28, จอมทอง, กรุงเทพมหานคร, 10150 ประเทศไทย&quot;,<br>                    &quot;countryCode&quot;: &quot;THA&quot;,<br>                    &quot;countryName&quot;: &quot;ประเทศไทย&quot;,<br>                    &quot;county&quot;: &quot;กรุงเทพมหานคร&quot;,<br>                    &quot;city&quot;: &quot;จอมทอง&quot;,<br>                    &quot;district&quot;: &quot;จอมทอง&quot;,<br>                    &quot;street&quot;: &quot;พระราม 2 ซอย 28&quot;,<br>                    &quot;postalCode&quot;: &quot;10150&quot;,<br>                    &quot;houseNumber&quot;: &quot;x&quot;<br>                },<br>                &quot;position&quot;: {<br>                    &quot;lat&quot;: 13.69063,<br>                    &quot;lng&quot;: 100.46375<br>                },<br>                &quot;access&quot;: [<br>                    {<br>                        &quot;lat&quot;: 13.69059,<br>                        &quot;lng&quot;: 100.46389<br>                    }<br>                ],<br>                &quot;mapView&quot;: {<br>                    &quot;west&quot;: 100.46282,<br>                    &quot;south&quot;: 13.68973,<br>                    &quot;east&quot;: 100.46468,<br>                    &quot;north&quot;: 13.69153<br>                },<br>                &quot;scoring&quot;: {<br>                    &quot;queryScore&quot;: 0.68,<br>                    &quot;fieldScore&quot;: {<br>                        &quot;country&quot;: 1.0,<br>                        &quot;county&quot;: 1.0,<br>                        &quot;city&quot;: 0.95,<br>                        &quot;district&quot;: 0.95,<br>                        &quot;streets&quot;: [<br>                            1.0<br>                        ],<br>                        &quot;houseNumber&quot;: 1.0,<br>                        &quot;postalCode&quot;: 1.0<br>                    }<br>                }<br>            }<br>        ]<br>    }</pre><p><strong>Result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EpINyPBh5hkLOY3R16rYng.png" /><figcaption>Here API’s accuracy result</figcaption></figure><p>ความคลาดเคลื่อนเฉลี่ย : 854.8552139538585 เมตร</p><p>6. <strong>Pinpoint</strong></p><p>ของ Pinpoint จะมี Geocoding แบบที่เป็น batch ซึ่งต้องเสียเงินถึงจะใช้ได้ ผมเลยใช้ Autocomplete API ร่วมกับ Location Details API แทน</p><p><strong>Request</strong></p><p>Request ของ Pinpoint ไม่ได้มี Optional parameter ให้ใช้เพราะงั้นก็ส่งเป็น full address ไปเลย</p><pre>$.post(&quot;https://pin-point.co/g/search/autocomplete&quot;,<br>  {<br>    keyword: &quot;999/999 หมู่ที่ 9 ต.นาป่า อ.เมืองชลบุรี จ.ชลบุรี&quot;,<br>    key: &quot;your-access-token&quot;,<br>    maxResult: 10<br>  }, function (res) {<br>  }, &quot;json&quot;);</pre><p><strong>Response</strong></p><p>ไม่มี Result type กับ Confident score ก็จะใช้ต่อยากหน่อย</p><pre>{<br>        &quot;data&quot;: {<br>            &quot;LocationID&quot;: &quot;1a2bfd26-2fcd-4837-b7f2-de2f6030e298&quot;,<br>            &quot;BusinessName&quot;: null,<br>            &quot;HouseNumber&quot;: &quot;xx/xxx&quot;,<br>            &quot;PremiseName&quot;: &quot;หมู่บ้านพระราม 2 (ซอยพระราม 2 ซอย 76)&quot;,<br>            &quot;PremiseLaneName&quot;: null,<br>            &quot;Moo&quot;: null,<br>            &quot;StreetLeadingType&quot;: null,<br>            &quot;StreetName&quot;: null,<br>            &quot;StreetTrailingType&quot;: null,<br>            &quot;SubStreetLeadingType&quot;: &quot;ซอย&quot;,<br>            &quot;SubStreetName&quot;: &quot;พระรามที่ 2 ซอย 78&quot;,<br>            &quot;SubStreetTrailingType&quot;: null,<br>            &quot;StreetFullName&quot;: &quot;ซอยพระรามที่ 2 ซอย 78 &quot;,<br>            &quot;SubDistrictPrefix&quot;: &quot;แขวง&quot;,<br>            &quot;SubDistrict&quot;: &quot;แสมดำ&quot;,<br>            &quot;DistrictPrefix&quot;: &quot;เขต&quot;,<br>            &quot;District&quot;: &quot;บางขุนเทียน&quot;,<br>            &quot;ProvincePrefix&quot;: null,<br>            &quot;Province&quot;: &quot;กรุงเทพมหานคร&quot;,<br>            &quot;LanguageCode&quot;: &quot;THA&quot;,<br>            &quot;LAT_LON&quot;: &quot;13.63862656, 100.40482551&quot;,<br>            &quot;PostalCode&quot;: &quot;10150&quot;,<br>            &quot;FormattedAddress&quot;: &quot;xx/xxx หมู่บ้านพระราม 2 (ซอยพระราม 2 ซอย 76) ซอยพระรามที่ 2 ซอย 78  แขวงแสมดำ เขตบางขุนเทียน กรุงเทพมหานคร 10150&quot;<br>        },<br>        &quot;success&quot;: true<br>    },</pre><p><strong>Result</strong></p><p>ถ้าใช้ Geocoding batch query API อาจจะค้นเจอเยอะกว่านี้ ถ้าอยากลองก็ต้องจ่ายก่อนเลย 6,500 บาท ผมก็ขอผ่านก่อนแล้วกัน = =’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bSzqBzfl9qnTgXGxiYkWsQ.png" /><figcaption>Pinpoint API’s accuracy result</figcaption></figure><p>ความคลาดเคลื่อนเฉลี่ย : 15408.626802658597 เมตร</p><p>7. <strong>OpenCage</strong></p><p><strong>Request</strong></p><p>สามารถ Filter ประเทศที่ต้องการได้</p><pre>https://api.opencagedata.com/geocode/v1/json?q=999/999%20หมู่ที่%209%20ต.นาป่า%20อ.เมืองชลบุรี%20จ.ชลบุรี&amp;key={OpenCageAPIKey}&amp;pretty=1&amp;countrycode=th&amp;language=th</pre><p><strong>Response</strong></p><p>1000 request ใช้เวลา 25 นาที ถือว่านานอยู่พอสมควร</p><pre>{<br>        &quot;documentation&quot;: &quot;https://opencagedata.com/api&quot;,<br>        &quot;licenses&quot;: [<br>            {<br>                &quot;name&quot;: &quot;see attribution guide&quot;,<br>                &quot;url&quot;: &quot;https://opencagedata.com/credits&quot;<br>            }<br>        ],<br>        &quot;rate&quot;: {<br>            &quot;limit&quot;: 2500,<br>            &quot;remaining&quot;: 2499,<br>            &quot;reset&quot;: 1729036800<br>        },<br>        &quot;results&quot;: [<br>            {<br>                &quot;annotations&quot;: {<br>                    &quot;DMS&quot;: {<br>                        &quot;lat&quot;: &quot;7° 1&#39; 0.12000&#39;&#39; N&quot;,<br>                        &quot;lng&quot;: &quot;100° 39&#39; 42.84000&#39;&#39; E&quot;<br>                    },<br>                    &quot;MGRS&quot;: &quot;47NPH8357775920&quot;,<br>                    &quot;Maidenhead&quot;: &quot;OJ07ha94ka&quot;,<br>                    &quot;Mercator&quot;: {<br>                        &quot;x&quot;: 11205631.45,<br>                        &quot;y&quot;: 777839.181<br>                    },<br>                    &quot;OSM&quot;: {<br>                        &quot;note_url&quot;: &quot;https://www.openstreetmap.org/note/new#map=17/7.01670/100.66190&amp;layers=N&quot;,<br>                        &quot;url&quot;: &quot;https://www.openstreetmap.org/?mlat=7.01670&amp;mlon=100.66190#map=17/7.01670/100.66190&quot;<br>                    },<br>                    &quot;UN_M49&quot;: {<br>                        &quot;regions&quot;: {<br>                            &quot;ASIA&quot;: &quot;142&quot;,<br>                            &quot;SOUTHEAST_ASIA&quot;: &quot;035&quot;,<br>                            &quot;TH&quot;: &quot;764&quot;,<br>                            &quot;WORLD&quot;: &quot;001&quot;<br>                        },<br>                        &quot;statistical_groupings&quot;: [<br>                            &quot;LEDC&quot;<br>                        ]<br>                    },<br>                    &quot;callingcode&quot;: 66,<br>                    &quot;currency&quot;: {<br>                        &quot;alternate_symbols&quot;: [],<br>                        &quot;decimal_mark&quot;: &quot;.&quot;,<br>                        &quot;html_entity&quot;: &quot;&amp;#x0E3F;&quot;,<br>                        &quot;iso_code&quot;: &quot;THB&quot;,<br>                        &quot;iso_numeric&quot;: &quot;764&quot;,<br>                        &quot;name&quot;: &quot;Thai Baht&quot;,<br>                        &quot;smallest_denomination&quot;: 1,<br>                        &quot;subunit&quot;: &quot;Satang&quot;,<br>                        &quot;subunit_to_unit&quot;: 100,<br>                        &quot;symbol&quot;: &quot;฿&quot;,<br>                        &quot;symbol_first&quot;: 1,<br>                        &quot;thousands_separator&quot;: &quot;,&quot;<br>                    },<br>                    &quot;flag&quot;: &quot;🇹🇭&quot;,<br>                    &quot;geohash&quot;: &quot;w1pxft7g0r8vg7v40dcd&quot;,<br>                    &quot;qibla&quot;: 290.7,<br>                    &quot;roadinfo&quot;: {<br>                        &quot;drive_on&quot;: &quot;left&quot;,<br>                        &quot;speed_in&quot;: &quot;km/h&quot;<br>                    },<br>                    &quot;sun&quot;: {<br>                        &quot;rise&quot;: {<br>                            &quot;apparent&quot;: 1729033500,<br>                            &quot;astronomical&quot;: 1729029300,<br>                            &quot;civil&quot;: 1729032240,<br>                            &quot;nautical&quot;: 1729030800<br>                        },<br>                        &quot;set&quot;: {<br>                            &quot;apparent&quot;: 1728990060,<br>                            &quot;astronomical&quot;: 1728994260,<br>                            &quot;civil&quot;: 1728991320,<br>                            &quot;nautical&quot;: 1728992820<br>                        }<br>                    },<br>                    &quot;timezone&quot;: {<br>                        &quot;name&quot;: &quot;Asia/Bangkok&quot;,<br>                        &quot;now_in_dst&quot;: 0,<br>                        &quot;offset_sec&quot;: 25200,<br>                        &quot;offset_string&quot;: &quot;+0700&quot;,<br>                        &quot;short_name&quot;: &quot;+07&quot;<br>                    },<br>                    &quot;what3words&quot;: {<br>                        &quot;words&quot;: &quot;หมูสับ.มะค่า.ต่างหาก&quot;<br>                    }<br>                },<br>                &quot;components&quot;: {<br>                    &quot;ISO_3166-1_alpha-2&quot;: &quot;TH&quot;,<br>                    &quot;ISO_3166-1_alpha-3&quot;: &quot;THA&quot;,<br>                    &quot;_category&quot;: &quot;postcode&quot;,<br>                    &quot;_type&quot;: &quot;postcode&quot;,<br>                    &quot;continent&quot;: &quot;Asia&quot;,<br>                    &quot;country&quot;: &quot;ประเทศไทย&quot;,<br>                    &quot;country_code&quot;: &quot;th&quot;,<br>                    &quot;postcode&quot;: &quot;90000&quot;<br>                },<br>                &quot;confidence&quot;: 7,<br>                &quot;formatted&quot;: &quot;90000, ประเทศไทย&quot;,<br>                &quot;geometry&quot;: {<br>                    &quot;lat&quot;: 7.0167,<br>                    &quot;lng&quot;: 100.6619<br>                }<br>            }<br>        ],<br>        &quot;status&quot;: {<br>            &quot;code&quot;: 200,<br>            &quot;message&quot;: &quot;OK&quot;<br>        },<br>        &quot;stay_informed&quot;: {<br>            &quot;blog&quot;: &quot;https://blog.opencagedata.com&quot;,<br>            &quot;mastodon&quot;: &quot;https://en.osm.town/@opencage&quot;<br>        },<br>        &quot;thanks&quot;: &quot;For using an OpenCage API&quot;,<br>        &quot;timestamp&quot;: {<br>            &quot;created_http&quot;: &quot;Tue, 15 Oct 2024 18:53:32 GMT&quot;,<br>            &quot;created_unix&quot;: 1729018412<br>        },<br>        &quot;total_results&quot;: 1<br>    }</pre><p>โครงสร้างถือว่าครบเครื่องมากๆ เป็น response ที่ให้ข้อมูลมาหลากหลายที่สุดแล้ว</p><p><strong>Result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4W6jK4kuyHIqlDnuc8Q9LQ.png" /><figcaption>Opencage API’s accuracy result</figcaption></figure><p>ความคลาดเคลื่อนเฉลี่ย : 11888.155224536356 เมตร</p><p>8. <strong>Geoapify</strong></p><p><strong>Request</strong></p><p>มี Optional parameter “country” กับ “postcode” เช่นเดียวกับ google เลยครับ</p><pre>https://api.geoapify.com/v1/geocode/search?text=999/999%20หมู่ที่%209%20ต.นาป่า%20อ.เมืองชลบุรี%20จ.ชลบุรี&amp;country=Thailand&amp;postcode={zipcode}&amp;apiKey={GeopifyAPIKey}&amp;lang=th</pre><p><strong>Response</strong></p><p>ใช้เวลา 1 ชั่วโมง ถือว่านานที่สุดแล้วใน 8 เจ้านี้</p><pre>{<br>                &quot;type&quot;: &quot;Feature&quot;,<br>                &quot;geometry&quot;: {<br>                    &quot;type&quot;: &quot;Point&quot;,<br>                    &quot;coordinates&quot;: [<br>                        100.74833,<br>                        13.829568<br>                    ]<br>                },<br>                &quot;properties&quot;: {<br>                    &quot;country_code&quot;: &quot;th&quot;,<br>                    &quot;street&quot;: &quot;ซอย 27&quot;,<br>                    &quot;country&quot;: &quot;Thailand&quot;,<br>                    &quot;county&quot;: &quot;Sai Mai&quot;,<br>                    &quot;datasource&quot;: {<br>                        &quot;sourcename&quot;: &quot;openstreetmap&quot;,<br>                        &quot;attribution&quot;: &quot;© OpenStreetMap contributors&quot;,<br>                        &quot;license&quot;: &quot;Open Database License&quot;,<br>                        &quot;url&quot;: &quot;https://www.openstreetmap.org/copyright&quot;<br>                    },<br>                    &quot;state&quot;: &quot;Bangkok&quot;,<br>                    &quot;city&quot;: &quot;Bangkok&quot;,<br>                    &quot;lon&quot;: 100.74833,<br>                    &quot;lat&quot;: 13.829568,<br>                    &quot;housenumber&quot;: &quot;27&quot;,<br>                    &quot;result_type&quot;: &quot;building&quot;,<br>                    &quot;postcode&quot;: &quot;10510&quot;,<br>                    &quot;formatted&quot;: &quot;27, ซอย 27, Bangkok, Bangkok 10510, Thailand&quot;,<br>                    &quot;address_line1&quot;: &quot;27&quot;,<br>                    &quot;address_line2&quot;: &quot;ซอย 27, Bangkok, Bangkok 10510, Thailand&quot;,<br>                    &quot;timezone&quot;: {<br>                        &quot;name&quot;: &quot;Asia/Bangkok&quot;,<br>                        &quot;offset_STD&quot;: &quot;+07:00&quot;,<br>                        &quot;offset_STD_seconds&quot;: 25200,<br>                        &quot;offset_DST&quot;: &quot;+07:00&quot;,<br>                        &quot;offset_DST_seconds&quot;: 25200<br>                    },<br>                    &quot;plus_code&quot;: &quot;7P52RPHX+R8&quot;,<br>                    &quot;plus_code_short&quot;: &quot;RPHX+R8 Bangkok, Sai Mai, Thailand&quot;,<br>                    &quot;rank&quot;: {<br>                        &quot;popularity&quot;: 3.213479790251967,<br>                        &quot;confidence&quot;: 0,<br>                        &quot;confidence_city_level&quot;: 0,<br>                        &quot;confidence_street_level&quot;: 0,<br>                        &quot;confidence_building_level&quot;: 0,<br>                        &quot;match_type&quot;: &quot;full_match&quot;<br>                    },<br>                    &quot;place_id&quot;: &quot;51672783a3e42f594059c39d0b23bda82b40c00203e203266f70656e7374726565746d61703a7374726565743a706f6c796c696e653a3233333030303034&quot;<br>                },<br>                &quot;bbox&quot;: [<br>                    100.748202,<br>                    13.82948,<br>                    100.748458,<br>                    13.829656<br>                ]<br>            },</pre><p>โครงสร้างถือว่าดีเลย มี Result type, Confident score, มี address มาให้หลากหลาย format</p><p><strong>Result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atGhw1h6wdUUJBgeewn_Lw.png" /></figure><p>ความคลาดเคลื่อนเฉลี่ย : 7853.080451086199 เมตร</p><h3><strong>Summary</strong></h3><p>มาดูผู้ชนะเลิศ 3 อันดับแรกกันครับ</p><p><strong>Top 3 API ที่มี result อยู่ในช่วง 0-100 เมตรมากที่สุด</strong></p><ol><li>Awesome Table: 36.3%</li><li>Google: 34.9%</li><li>Here: 31%</li></ol><p><strong>Top 3 API ที่ความคลาดเคลื่อนเฉลี่ยต่ำที่สุด</strong></p><ol><li>Google: 802.9719664357046 เมตร</li><li>Here: 854.8552139538585 เมตร</li><li>Awesome Table: 998.6603692888319 เมตร</li></ol><p>รวมๆ แล้ว Google, Here, Awesome Table จะนำเจ้าอื่นๆ ค่อยข้างเยอะ แล้วผลลัพธ์ก็ไม่ได้ห่างกันมาก ถ้าใช้ข้อมูล Address ชุดอื่น ลำดับผลลัพธ์ก็อาจจะมีเปลี่ยนแปลง</p><p>สุดท้ายแล้ว Accuracy 30 กว่าเปอร์เซนต์ก็ยังนำไปใช้ต่อได้ยากอยู่ดีครับ ต้องมาเช็คว่า Address ไหนได้ Lat, Lng ถูกหรือไม่ถูกอีก ก็หวังว่าในอนาคตจะมีการพัฒนาเรื่อยๆ จนแม่นพอที่จะนำไปใช้กับธุรกิจต่างๆ ได้ แล้วสิ่งอำนวยความสะดวกจะเกินขึ้นอีกมากมายเลย</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a13d45461bc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/myorder/%E0%B9%80%E0%B8%9B%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%9A%E0%B9%80%E0%B8%97%E0%B8%B5%E0%B8%A2%E0%B8%9A-geocoding-%E0%B8%97%E0%B8%B1%E0%B9%89%E0%B8%87%E0%B8%AB%E0%B8%A1%E0%B8%94-8-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2-%E0%B8%AB%E0%B8%B2%E0%B8%9E%E0%B8%B4%E0%B8%81%E0%B8%B1%E0%B8%94%E0%B8%88%E0%B8%B2%E0%B8%81-address-2a13d45461bc">เปรียบเทียบ Geocoding ทั้งหมด 8 เจ้า (หาพิกัดจาก Address)</a> was originally published in <a href="https://medium.com/myorder">myorder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>