Groups
Groups
Sign in
Groups
Groups
QGIS初心者質問グループ
Conversations
About
Send feedback
Help
オートインクリメントによる一意IDの付与について
587 views
Skip to first unread message
D K
unread,
Sep 11, 2020, 2:38:36 AM
9/11/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
先日はありがとうございました。
度々恐縮ですが、質問させていただきます。
QGISにおける Auto increment( 自動採番 )について調べた結果、様々な方法が見つかりましたが、どの方法で実装しても地物を追加・削除する度に値が更新されてしまいます(場合によりますが)。これはおそらく行番号や
Maximumを参照しているからだと思います。
例えば下の図1-1から地物Cを削除し、新たに地物Dを追加した場合、
図1-2のように
地物DのmyIDは2になりますが、私が欲しい結果は 図2のように、これまで一度も使用されていない新たなIDです。
一度付与したら変化しないIDを自動採番したいのですが、どのようにすればよいのでしょうか。どうかご教示ねがいます。
◎図1-1
地物A(myID=0)
地物B (myID=1)
地物C (myID=2)
◎図1-2(欲しくない結果)
地物A(myID=0)
地物B (myID=1)
地物D (myID=2)←以前使用したID(地物C)が振られてしまう
◎図2(欲しい結果)
地物A(myID=0)
地物B (myID=1)
地物D (myID=3)
※特に情報が多かったサイト
https://gis.stackexchange.com/questions/132346/is-there-a-way-of-auto-increment-for-the-id-column-in-qgis
※環境:
QGIS Desktop 3.14.15 with GRASS 7.8.3
Windows10 64bit
ありた
unread,
Sep 11, 2020, 10:09:23 AM
9/11/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
こんにちは
GeoPackage や SpatiaLite は、削除済みの地物も含め、
fid
の最大値を記録しており
オートインクリメントで付番されます。
数値のオートインクリメントにこだわらず、ほぼ厳密に一意な値がほしい場合は、
uuid などを利用する方法もあります。
uuid()
で生成することができるので
レイヤプロパティの属性フォームよりデフォルト値の設定で
uuid()
を設定すると
よいでしょう。
D K
unread,
Sep 22, 2020, 7:52:27 PM
9/22/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
ありた様
ご返信ありがとうございます。
返信が遅くなり申し訳ございませんでした。
uuidは文字列が長いので躊躇しております。
今後はGeoPackageへの移行も視野にいれ、検討していこうと思います。
ご教示いただき、ありがとうございました。
2020年9月11日金曜日 23:09:23 UTC+9 ありた:
Reply all
Reply to author
Forward
0 new messages