Collection of arcpy helper classes and functions
Project description
APUtil
Utility classes and functions for arcpy. APUtil stands for ArcPy and UTILity.
Install
python -m pip install aputil
Note: Future releases are published on PyPi.
Example
aputil.xcursor
Using xcursor(cursor)
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)
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()
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)
import arcpy
from aputil import fc
record_count = fc.count(r"c:\data\buildings.shp")
print(record_count)
aputil.typings
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
cd c:\projects\aputil
[conda activate arcgispro-py3]
python test.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
APUtil-0.4.6.tar.gz
(7.3 kB
view details)
Built Distribution
APUtil-0.4.6-py3-none-any.whl
(13.8 kB
view details)
File details
Details for the file APUtil-0.4.6.tar.gz
.
File metadata
- Download URL: APUtil-0.4.6.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6c6cc1cf1b1b8f1110c9e9ed01c90ad0b751430584d7d09b080398cdff7132f |
|
MD5 | 72cb607914801e6d970bdd6661303aa7 |
|
BLAKE2b-256 | 82309a98f184be8b5c4b1ae3e92288132a0d45cb623e2e4626eac5e68e112906 |
File details
Details for the file APUtil-0.4.6-py3-none-any.whl
.
File metadata
- Download URL: APUtil-0.4.6-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a217d3dfd331ba74e92bf85ee8c88f3a9b7841ce4e9c52f10aff4b6702e57bb4 |
|
MD5 | 36314484e50a29693651de35e30a361a |
|
BLAKE2b-256 | a27b93307e6751420814fc1c5d1062cf958a9e16f066ba07c61e20e1a5a1f2b3 |