Python– tag –
-
フィールド演算の実行
[vb title="VBA / VB6"] Public Sub FieldCalculator() Dim pMxDocument As IMxDocument Set pMxDocument = ThisDocument Dim pFeatureLayer As IFeatureLayer Set pFeatureLayer = pMxDocument.FocusMap.Layer(0) Dim pTable As ITable Set pTable = pFeatureLayer.FeatureClass 'フィールド... -
フィールド演算による日付の出力
[python title="Python"] def GetDDMMSS(field): tdatetime = datetime.datetime.strptime(field, '%Y/%m/%d %H:%M:%S') return tdatetime.strftime('%Y/%m/%d') [/python] -
フィールド演算でコードのインポート
[python title="Python"] yosoro.py #coding:cp932 def call(a): return "ヨーソロー " * a ----------------------------------- 1.上記ファイルを C:\Python26\ArcGIS10.0\Lib に置く 2.フィールド演算に以下を記述 import yosoro yosoro.call(5) [/python] -
ループによるピラミッドの作成
ループのお勉強です。 [python title="Python"] #片方ピラミッドの作成 for c in range(10): print "*" * c #ちゃんとしたピラミッドの作成 max = 10 for c in range(1, max, 2): print (max - c - 1)/2 * " " + "*" * c [/python] -
2 点間の角度
[python title="Python"] import math radian = math.atan((Y2-Y1)/(X2-X1)) degrees = radian * 180 / math.pi [/python] -
Decimal 型の操作
[python title="Python"] import numpy import decimal x = 198576 / 1000.0 x = numpy.float64(x) y = decimal.Decimal(x).quantize(decimal.Decimal('.000'), rounding=decimal.ROUND_HALF_UP) z = decimal.Decimal(x) print type(y),y print type(z),z [/python] -
VARCHAR 型の日付を変換
日付と時刻の表記も国際規格があり、ISO 8601で決められている。最新版は 2004年の ISO 8601:2004。 https://ja.wikipedia.org/wiki/ISO_8601 これを Python のモジュールで変換するには以下のように記述する [python title="Python"] import dateutil.parser dt = dateutil.parser.parse("YYYY-MM-DDTHH:MM:SSZ") [/python] ただ... -
環境変数の取得
[python title="Python"] os.environ['USERPROFILE'] os.environ['TEMP'] [/python] -
カンマ区切りしたテキストフィールドからカラムを取得
[python title="Python"] def GetNumber(field, column): try: theText = field.split(',') theResult = int(theText[column]) return theResult except: return -999 __esri_field_calculator_splitter__ GetNumber( !TEXT!, 1) [/python] -
極角と方位角の相互変換
極角(polar angle)から方位角(azimuth angle)、もしくはその逆を計算する方法です。極角と方位角は 1つの式で求めることができます。 元の値を負にして90を加算し、さらに360を加算 その値を360で除算した剰余が極角/方位角を相互変換した値 この方法で角度が0度未満や360度より大でも 0 =< result < 360 の値を返すことができま...
