【问题标题】:ArcGIS Field Calculator strip words after spacesArcGIS 字段计算器去除空格后的单词
【发布时间】:2014-12-09 18:53:23
【问题描述】:

我有一个包含 40,000 个邮寄地址的要素类。每个地址都包含街道地址、城市、州和邮政编码,以空格分隔。

示例 1:123 Northwest Johnson St Cleveland Ohio 12345 示例 2:邮政信箱 3 Pine Springs Ohio 12345

我只想提取街道地址。怎么说:从第 3 个或第 4 个空格开始剪掉字符串?

谢谢。任何帮助,将不胜感激。我正在尝试拆分、修剪等的组合,但无法做到正确。

【问题讨论】:

    标签: python gis arcgis


    【解决方案1】:

    这就是你在纯 Python 中可以做到的方式,我不确定使用 ArcGIS 时的差异:

    ad1 = "123 Northwest Johnson St Cleveland Ohio 12345"
    ad2 = "PO Box 3 Pine Springs Ohio 12345"
    ad1split = ad1.split(" ")
    ad2split = ad2.split(" ")
    print ' '.join( ad1split[: len(ad1split)-3 ] ) # 123 Northwest Johnson
    print ' '.join( ad2split[: len(ad1split)-3 ] ) # PO Box 3
    

    这仅适用于所有地址具有相同格式的情况。

    【讨论】:

    • 感谢尝试,但是地址的格式不一样,所以我只想把每个地址的最后三个部分剪掉。
    • 我编辑了我的答案,它现在删除了每一行的最后三个单词
    猜你喜欢
    • 1970-01-01
    • 2014-11-11
    • 2013-07-22
    • 1970-01-01
    • 2016-06-28
    • 1970-01-01
    • 2016-03-31
    • 2020-06-24
    • 2018-03-04
    相关资源
    最近更新 更多