APUtil


NameAPUtil JSON
Version 0.4.6 PyPI version JSON
download
home_pagehttps://github.com/moosetraveller/aputil
SummaryCollection of arcpy helper classes and functions
upload_time2023-09-01 00:21:57
maintainer
docs_urlNone
authorThomas Zuberbuehler
requires_python
licenseMIT
keywords arcpy util arcgis esri cursor gis arcgis-pro
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # APUtil

Utility classes and functions for arcpy. APUtil stands for **A**rc**P**y and **UTIL**ity.

## Install 

```shell
python -m pip install aputil
```

Note: Future releases are published on PyPi.

## Example

### `aputil.xcursor`

### Using `xcursor(cursor)`

```python
import arcpy, arcpy.da

from aputil import xcursor

feature_class = "points.shp"

with arcpy.da.SearchCursor(feature_class, ["FieldName"]) as cursor:

    for row in xcursor(cursor):
        
        print(row["FieldName"])  # instead of row[0]

        # other examples
        print(row.get("FieldName", "Default Value"))
        print(row.get_by_index(0, "Default Value"))
```

#### Using `to_row()`

See `test/xcursor_test.py` (test `test_to_row`) for an example.

### `aputil.tcursor`

### Using `tcursor(cursor)`

```python
import arcpy, arcpy.da

from aputil import tcursor

feature_class = "points.shp"

with arcpy.da.SearchCursor(feature_class, ["FieldName"]) as cursor:

    for row in tcursor(cursor):

        print(row.FieldName)  # instead of row[0]
```

### `aputil.fc`

#### Using `use_memory()`

```python
import arcpy, arcpy.management

from aputil import fc

arcpy.env.workspace = r"c:\data"

with fc.use_memory() as copied:

    print(arcpy.Exists(copied))  # false (not yet)
    arcpy.management.CopyFeatures("buildings.shp", copied)
    print(arcpy.Exists(copied))  # true

print(arcpy.Exists(copied))  # false
```

#### Using `count(fc)`

```python
import arcpy

from aputil import fc

record_count = fc.count(r"c:\data\buildings.shp")

print(record_count)
```

### `aputil.typings`

```python
import arcpy, arcpy.management

from aputil.typings import FeatureClassType

def create_feature_class() -> FeatureClassType:
    return arcpy.management.CreateFeatureclass(r"c:\temp", "test.shp")

print(create_feature_class())
```

## Run Unit Tests

```shell
cd c:\projects\aputil
[conda activate arcgispro-py3]
python test.py
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/moosetraveller/aputil",
    "name": "APUtil",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "arcpy,util,arcgis,esri,cursor,gis,arcgis-pro",
    "author": "Thomas Zuberbuehler",
    "author_email": "thomas.zuberbuehler@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/82/30/9a98f184be8b5c4b1ae3e92288132a0d45cb623e2e4626eac5e68e112906/APUtil-0.4.6.tar.gz",
    "platform": null,
    "description": "# APUtil\r\n\r\nUtility classes and functions for arcpy. APUtil stands for **A**rc**P**y and **UTIL**ity.\r\n\r\n## Install \r\n\r\n```shell\r\npython -m pip install aputil\r\n```\r\n\r\nNote: Future releases are published on PyPi.\r\n\r\n## Example\r\n\r\n### `aputil.xcursor`\r\n\r\n### Using `xcursor(cursor)`\r\n\r\n```python\r\nimport arcpy, arcpy.da\r\n\r\nfrom aputil import xcursor\r\n\r\nfeature_class = \"points.shp\"\r\n\r\nwith arcpy.da.SearchCursor(feature_class, [\"FieldName\"]) as cursor:\r\n\r\n    for row in xcursor(cursor):\r\n        \r\n        print(row[\"FieldName\"])  # instead of row[0]\r\n\r\n        # other examples\r\n        print(row.get(\"FieldName\", \"Default Value\"))\r\n        print(row.get_by_index(0, \"Default Value\"))\r\n```\r\n\r\n#### Using `to_row()`\r\n\r\nSee `test/xcursor_test.py` (test `test_to_row`) for an example.\r\n\r\n### `aputil.tcursor`\r\n\r\n### Using `tcursor(cursor)`\r\n\r\n```python\r\nimport arcpy, arcpy.da\r\n\r\nfrom aputil import tcursor\r\n\r\nfeature_class = \"points.shp\"\r\n\r\nwith arcpy.da.SearchCursor(feature_class, [\"FieldName\"]) as cursor:\r\n\r\n    for row in tcursor(cursor):\r\n\r\n        print(row.FieldName)  # instead of row[0]\r\n```\r\n\r\n### `aputil.fc`\r\n\r\n#### Using `use_memory()`\r\n\r\n```python\r\nimport arcpy, arcpy.management\r\n\r\nfrom aputil import fc\r\n\r\narcpy.env.workspace = r\"c:\\data\"\r\n\r\nwith fc.use_memory() as copied:\r\n\r\n    print(arcpy.Exists(copied))  # false (not yet)\r\n    arcpy.management.CopyFeatures(\"buildings.shp\", copied)\r\n    print(arcpy.Exists(copied))  # true\r\n\r\nprint(arcpy.Exists(copied))  # false\r\n```\r\n\r\n#### Using `count(fc)`\r\n\r\n```python\r\nimport arcpy\r\n\r\nfrom aputil import fc\r\n\r\nrecord_count = fc.count(r\"c:\\data\\buildings.shp\")\r\n\r\nprint(record_count)\r\n```\r\n\r\n### `aputil.typings`\r\n\r\n```python\r\nimport arcpy, arcpy.management\r\n\r\nfrom aputil.typings import FeatureClassType\r\n\r\ndef create_feature_class() -> FeatureClassType:\r\n    return arcpy.management.CreateFeatureclass(r\"c:\\temp\", \"test.shp\")\r\n\r\nprint(create_feature_class())\r\n```\r\n\r\n## Run Unit Tests\r\n\r\n```shell\r\ncd c:\\projects\\aputil\r\n[conda activate arcgispro-py3]\r\npython test.py\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Collection of arcpy helper classes and functions",
    "version": "0.4.6",
    "project_urls": {
        "Homepage": "https://github.com/moosetraveller/aputil"
    },
    "split_keywords": [
        "arcpy",
        "util",
        "arcgis",
        "esri",
        "cursor",
        "gis",
        "arcgis-pro"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a27b93307e6751420814fc1c5d1062cf958a9e16f066ba07c61e20e1a5a1f2b3",
                "md5": "36314484e50a29693651de35e30a361a",
                "sha256": "a217d3dfd331ba74e92bf85ee8c88f3a9b7841ce4e9c52f10aff4b6702e57bb4"
            },
            "downloads": -1,
            "filename": "APUtil-0.4.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "36314484e50a29693651de35e30a361a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13831,
            "upload_time": "2023-09-01T00:21:56",
            "upload_time_iso_8601": "2023-09-01T00:21:56.491256Z",
            "url": "https://files.pythonhosted.org/packages/a2/7b/93307e6751420814fc1c5d1062cf958a9e16f066ba07c61e20e1a5a1f2b3/APUtil-0.4.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82309a98f184be8b5c4b1ae3e92288132a0d45cb623e2e4626eac5e68e112906",
                "md5": "72cb607914801e6d970bdd6661303aa7",
                "sha256": "e6c6cc1cf1b1b8f1110c9e9ed01c90ad0b751430584d7d09b080398cdff7132f"
            },
            "downloads": -1,
            "filename": "APUtil-0.4.6.tar.gz",
            "has_sig": false,
            "md5_digest": "72cb607914801e6d970bdd6661303aa7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7294,
            "upload_time": "2023-09-01T00:21:57",
            "upload_time_iso_8601": "2023-09-01T00:21:57.447440Z",
            "url": "https://files.pythonhosted.org/packages/82/30/9a98f184be8b5c4b1ae3e92288132a0d45cb623e2e4626eac5e68e112906/APUtil-0.4.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-01 00:21:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "moosetraveller",
    "github_project": "aputil",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "aputil"
}
        
Elapsed time: 0.12307s