Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6eb144

Browse files
committed
Merge remote-tracking branch 'origin/entity_recog_numpy_fix' into entity_recog_numpy_fix
2 parents10a5bde +97120f9 commitc6eb144

File tree

24 files changed

+9285
-9168
lines changed

24 files changed

+9285
-9168
lines changed

‎.github/workflows/arcgis-learn-test.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
env_name:
1212
description:"Name of Conda environment"
1313
required:false
14-
default:"pr_tests_17_sept"
14+
default:"pr_test_19_sept"
1515
test_file:
1616
description:"Path to test file"
1717
required:false
@@ -35,7 +35,7 @@ jobs:
3535

3636
-name:Run tests in arcgis_learn supported conda env - Linux
3737
run:|
38-
ENV_NAME="${{ github.event.inputs.env_name || 'pr_tests_17_sept' }}"
38+
ENV_NAME="${{ github.event.inputs.env_name || 'pr_test_19_sept' }}"
3939
TEST_FILE="${{ github.event.inputs.test_file || 'tests/integration/arcgis_learn/test_common.py' }}"
4040
source /root/anaconda3/etc/profile.d/conda.sh
4141
conda activate $ENV_NAME
@@ -58,7 +58,7 @@ jobs:
5858
export run_weekly=0
5959
export run_backbones=0
6060
export TESTFOLDERPATH="$WORKSPACE/tests"
61-
export PYTHONPATH="$WORKSPACE/tests"
61+
export PYTHONPATH="$WORKSPACE/src:$WORKSPACE/tests"
6262
6363
REPORT_FILE=$WORKSPACE/tests/_output/test-results.xml
6464

‎pixi.lock‎

Lines changed: 6812 additions & 7013 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎pixi.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ channels = ["conda-forge"]
120120
# fastai = {channel = "fastai"}
121121
fastprogress = {channel ="conda-forge"}
122122
pytorch = {channel ="conda-forge"}
123-
timm = {channel ="esri",version ="~=0.4.12"}
123+
timm = {channel ="esri-build",version ="~=1.0.14"}
124124
torchvision = {channel ="conda-forge"}
125125
nodejs = {channel ="conda-forge",version ="~=22.0"}
126126
minizip =">=4,<5"# for zipping up docs
Lines changed: 106 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,71 @@
11
from __future__importannotations
22
importos
33
fromenumimportEnum
4+
importloggingas_logging
5+
importsys,warnings
46

57

6-
classGeometryEngine(Enum):
8+
classModuleWithWarnings(sys.__class__):
9+
"""A module that issues a deprecation warning when the `SELECTED_ENGINE` attribute is accessed."""
10+
11+
def__getattribute__(self,name):
12+
13+
ifname=="SELECTED_ENGINE":
14+
withwarnings.catch_warnings():
15+
warnings.simplefilter("once")
16+
warnings.warn(
17+
f"{name} is deprecated and will be removed in a future version. please use `SELECTED_IO_ENGINE` or 'SELECTED_GEOMETRY_ENGINE' instead.",
18+
DeprecationWarning,
19+
)
20+
21+
returnsuper().__getattribute__(name)
22+
23+
24+
classIOEngine(Enum):
725
# Available geometry engines
826
ARCPY="arcpy"
927
GDAL="gdal"
10-
SHAPELY="shapely"
1128
SHAPEFILE="shapefile"
1229

1330

31+
classGeometryEngine(Enum):
32+
# Available geometry engines
33+
ARCPY="arcpy"
34+
SHAPELY="shapely"
35+
36+
1437
classGeometryEngineManager:
1538
"""
1639
Manages detection and selection of a spatial geometry engine.
1740
18-
Setting "ARCGIS_GEOMETRY_ENGINE" environment variable to "arcpy", "gdal", or "shapely" will prioritize your preferred engine.
41+
Setting corresponding environment variable will prioritize your preferred engine.
42+
Environment variables:
43+
- ARCGIS_IO_ENGINE: for I/O operations (priority order: ARCPY > GDAL > SHAPEFILE)
44+
- ARCGIS_GEOMETRY_ENGINE(currently has no effect): for geometry operations (priority order: ARCPY > SHAPELY)
1945
"""
2046

2147
def__init__(self):
2248
"""Initialize and select an engine."""
2349
self._detect_available_engines()
24-
self.engine=self._select_engine()# Store the selected engine
50+
self.io_engine=self._select_io_engine()# Store the selected engine
51+
self.geometry_engine= (
52+
self._select_geometry_engine()
53+
)# Store the selected engine
2554

2655
def_detect_available_engines(self):
2756
"""
2857
Check for installed spatial libraries.
2958
If we can import, we assume it is available.
3059
"""
31-
self.available_engines= {
60+
self.available_io_engines= {
61+
IOEngine.ARCPY:self._is_installed("arcpy"),
62+
IOEngine.SHAPEFILE:self._is_installed("shapefile"),
63+
IOEngine.GDAL:self._is_installed("osgeo"),
64+
}
65+
66+
self.available_geometry_engines= {
3267
GeometryEngine.ARCPY:self._is_installed("arcpy"),
33-
GeometryEngine.SHAPEFILE:self._is_installed("shapefile"),
3468
GeometryEngine.SHAPELY:self._is_installed("shapely"),
35-
GeometryEngine.GDAL:self._is_installed("osgeo"),
3669
}
3770

3871
def_is_installed(self,module_name):
@@ -43,34 +76,88 @@ def _is_installed(self, module_name):
4376
exceptImportError:
4477
returnFalse
4578

46-
def_select_engine(self):
47-
"""Select the best available engine, prioritizing user preference."""
79+
def_select_io_engine(self):
80+
"""Select the best available engine for I/O operations, prioritizing user preference."""
81+
# Get the preferred engine from the environment variable ARCGIS_IO_ENGINE
82+
preferred_engine=os.getenv("ARCGIS_IO_ENGINE","").lower()
83+
84+
# Check if the preferred engine is in the list of available engines
85+
ifpreferred_engineinIOEngine._value2member_map_:
86+
selected_engine=IOEngine(preferred_engine)
87+
# If the preferred engine is available, return it
88+
ifself.available_io_engines.get(selected_engine,False):
89+
returnselected_engine# Use user-specified engine if available
90+
91+
# Default priority order: arcpy > gdal > shapefile
92+
# Iterate through the default engines and select the first available one
93+
forenginein [
94+
IOEngine.ARCPY,
95+
IOEngine.GDAL,
96+
IOEngine.SHAPEFILE,
97+
]:
98+
ifself.available_io_engines[engine]:
99+
returnengine# Return the first available engine from the default priority order
100+
101+
def_select_geometry_engine(self):
102+
"""Select the best available engine for geometry operations."""
48103
# Get the preferred engine from the environment variable ARCGIS_GEOMETRY_ENGINE
49104
preferred_engine=os.getenv("ARCGIS_GEOMETRY_ENGINE","").lower()
105+
iflen(preferred_engine)>0:
106+
warnings.warn(
107+
"ARCGIS_GEOMETRY_ENGINE environment variable is set but currently has no effect. "
108+
"Geometry engine selection always follows the default priority order: ARCPY > SHAPELY. "
109+
"Previously, this variable was used to select the I/O engine, but now it's reserved for selecting geometry engine (not yet implemented). "
110+
"To select the I/O engine, use the ARCGIS_IO_ENGINE environment variable.",
111+
DeprecationWarning,
112+
)
50113

51114
# Check if the preferred engine is in the list of available engines
52115
ifpreferred_engineinGeometryEngine._value2member_map_:
53116
selected_engine=GeometryEngine(preferred_engine)
54117
# If the preferred engine is available, return it
55-
ifself.available_engines.get(selected_engine,False):
118+
ifself.available_geometry_engines.get(selected_engine,False):
56119
returnselected_engine# Use user-specified engine if available
57120

58-
# Default priority order: arcpy >gdal > shapefile
121+
# Default priority order: arcpy >shapely
59122
# Iterate through the default engines and select the first available one
60123
forenginein [
61124
GeometryEngine.ARCPY,
62-
GeometryEngine.GDAL,
63-
GeometryEngine.SHAPEFILE,
64125
GeometryEngine.SHAPELY,
65126
]:
66-
ifself.available_engines[engine]:
127+
ifself.available_geometry_engines[engine]:
67128
returnengine# Return the first available engine from the default priority order
68129

69130

70131
# Create a global instance so all modules can import it
71132
ge=GeometryEngineManager()
72-
SELECTED_ENGINE=ge.engine
73-
HAS_ARCPY=ge.available_engines[GeometryEngine.ARCPY]
74-
HAS_PYSHP=ge.available_engines[GeometryEngine.SHAPEFILE]
75-
HAS_SHAPELY=ge.available_engines[GeometryEngine.SHAPELY]
76-
HAS_GDAL=ge.available_engines[GeometryEngine.GDAL]
133+
134+
SELECTED_IO_ENGINE=ge.io_engine
135+
"""Selected I/O engine for IO operations.
136+
It can be one of the following:
137+
- `IOEngine.ARCPY`
138+
- `IOEngine.GDAL`
139+
- `IOEngine.SHAPEFILE`
140+
141+
Priority: ARCPY > GDAL > SHAPEFILE
142+
"""
143+
144+
SELECTED_ENGINE=SELECTED_IO_ENGINE
145+
"""Deprecated alias for `SELECTED_IO_ENGINE`."""
146+
147+
_SELECTED_GEOMETRY_ENGINE=ge.geometry_engine
148+
""">Note: `ARCGIS_GEOMETRY_ENGINE` is currently NOT used in engine selection.
149+
150+
Designed for selecting geometry engine for geometry operations.
151+
It can be one of the following:
152+
- `GeometryEngine.ARCPY`
153+
- `GeometryEngine.SHAPELY`
154+
155+
Priority: ARCPY > SHAPELY
156+
"""
157+
158+
HAS_ARCPY=ge.available_io_engines[IOEngine.ARCPY]
159+
HAS_PYSHP=ge.available_io_engines[IOEngine.SHAPEFILE]
160+
HAS_SHAPELY=ge.available_geometry_engines[GeometryEngine.SHAPELY]
161+
HAS_GDAL=ge.available_io_engines[IOEngine.GDAL]
162+
163+
sys.modules[__name__].__class__=ModuleWithWarnings

‎src/arcgis/features/geo/_accessor.py‎

Lines changed: 72 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,35 +1185,72 @@ class GeoAccessor(object):
11851185
<arcgis.features.geo._accessor.GeoAccessor object at <mem_addr>>
11861186
11871187
.. note::
1188-
**Setting theGeometry Engine:**
1189-
By default, thelibrary used for spatial transformations (e.g., reading/writing
1190-
shapefiles, file geodatabases, or spatial DataFrames)is determined by the
1188+
**Setting theI/O Engine:**
1189+
By default, thelibraries used for spatial transformations (e.g., reading/writing
1190+
shapefiles, file geodatabases, or spatial DataFrames)are determined by the
11911191
available libraries in the environment. You can explicitly set the library used
1192-
for certain spatial operations through an environment variable called
1193-
`ARCGIS_GEOMETRY_ENGINE`. The variable **MUST** be set at the top of the script.
1194-
The options available are:
1195-
1196-
* *shapefile* - for the `Python Shapefile Library (PyShp) <https://github.com/GeospatialPython/pyshp>`_
1197-
A lightweight option that works well for simple shapefile operations but lacks advanced capabilities
1198-
of *gdal* or *arcpy*.
1199-
* *arcpy* - for the Esri `ArcPy <https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/what-is-arcpy-.htm>`_
1200-
library. **Requires** a license for use. Best for full compatibility with Esri's ArcGIS ecosystem,
1201-
including advanced geoprocessing tools.
1202-
* *gdal* - for the `Open Source Geospatial Foundation gdal <https://gdal.org/en/stable/>`_ translator
1203-
library. A good balance of performance and compatibility with multiple GIS formats. Ideal
1204-
for working with large datasets and open-source workflows.
1192+
for certain spatial operations through the environment variable:
1193+
1194+
- `ARCGIS_IO_ENGINE` (**I/O operations**):
1195+
* *arcpy* - for the Esri `ArcPy <https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/what-is-arcpy-.htm>`_
1196+
library. **Requires** a license for use. Best for full compatibility with Esri's ArcGIS ecosystem,
1197+
including advanced geoprocessing tools.
1198+
* *gdal* - for the `Open Source Geospatial Foundation gdal <https://gdal.org/en/stable/>`_ translator
1199+
library. A good balance of performance and compatibility with multiple GIS formats. Ideal
1200+
for working with large datasets and open-source workflows.
1201+
* *shapefile* - for the `Python Shapefile Library (PyShp) <https://github.com/GeospatialPython/pyshp>`_
1202+
A lightweight option that works well for simple shapefile operations but lacks advanced capabilities
1203+
of *gdal* or *arcpy*.
1204+
1205+
The variable **MUST** be set at the top of the script. If not set, the first available library in the environment will be used for each engine.
1206+
The default order is: ARCPY > GDAL > SHAPEFILE.
12051207
12061208
To set environment at the top of the script, add:
12071209
12081210
.. code-block:: python
12091211
12101212
import os
1211-
os.environ["ARCGIS_GEOMETRY_ENGINE"] = "<engine of choice>"
1213+
os.environ["ARCGIS_IO_ENGINE"] = "<engine of choice>" # e.g., "gdal"
12121214
12131215
.. note::
12141216
If you are using shapely in conjunction with shapefiles instead of arcpy or gdal, you will have to
12151217
do all reprojections manually. Shapely does not support projections.
12161218
1219+
See Shapely's docs for applying coordinate transforms with ``shapely.transform`` and pyproj's
1220+
``Transformer`` for CRS reprojection:
1221+
1222+
- Shapely transform: https://shapely.readthedocs.io/en/stable/reference/shapely.transform.html
1223+
- pyproj Transformer: https://pyproj4.github.io/pyproj/stable/api/transformer.html
1224+
1225+
Example (reproject WGS84 lon/lat to UTM Zone 18N):
1226+
1227+
.. code-block:: python
1228+
1229+
from shapely import Point, transform # Shapely >= 2.0
1230+
from pyproj import Transformer
1231+
1232+
# Build a reusable transformer (always_xy=True keeps lon/lat order)
1233+
tfm = Transformer.from_crs("EPSG:4326", "EPSG:32618", always_xy=True)
1234+
1235+
pt_wgs84 = Point(-75.0, 50.0)
1236+
pt_utm = transform(pt_wgs84, tfm.transform, interleaved=False)
1237+
# -> POINT (500000 5538630.703)
1238+
1239+
For Shapely 1.8.x, use ``shapely.ops.transform`` instead:
1240+
1241+
.. code-block:: python
1242+
1243+
from shapely.geometry import Point
1244+
from shapely.ops import transform
1245+
from pyproj import Transformer
1246+
1247+
tfm = Transformer.from_crs("EPSG:4326", "EPSG:32618", always_xy=True)
1248+
pt_utm = transform(tfm.transform, Point(-75.0, 50.0))
1249+
1250+
Note: Shapely geometries do not carry any CRS (Coordinate Reference System) information.
1251+
They are simply collections of coordinates in a flat (Cartesian) space.
1252+
It's up to you (either in your code or through a wrapper like GeoPandas) to track and apply the CRS.
1253+
12171254
"""
12181255

12191256
_viz=None
@@ -1242,15 +1279,15 @@ def _check_geometry_engine(self):
12421279
fromarcgis._impl._geometry_engineimport (
12431280
HAS_ARCPY,
12441281
HAS_SHAPELY,
1245-
SELECTED_ENGINE,
1246-
GeometryEngine,
1282+
SELECTED_IO_ENGINE,
1283+
IOEngine,
12471284
)
12481285

12491286
self._HASARCPY=self._HASARCPYorHAS_ARCPY
12501287
self._HASSHAPELY=self._HASSHAPELYorHAS_SHAPELY
1251-
self._USE_ARCPY=self._USE_ARCPYorSELECTED_ENGINE==GeometryEngine.ARCPY
1252-
self._USE_PYSHP=self._USE_PYSHPorSELECTED_ENGINE==GeometryEngine.SHAPEFILE
1253-
self._USE_GDAL=self._USE_GDALorSELECTED_ENGINE==GeometryEngine.GDAL
1288+
self._USE_ARCPY=self._USE_ARCPYorSELECTED_IO_ENGINE==IOEngine.ARCPY
1289+
self._USE_PYSHP=self._USE_PYSHPorSELECTED_IO_ENGINE==IOEngine.SHAPEFILE
1290+
self._USE_GDAL=self._USE_GDALorSELECTED_IO_ENGINE==IOEngine.GDAL
12541291
returnself._HASARCPY,self._HASSHAPELY
12551292

12561293
# ----------------------------------------------------------------------
@@ -1986,8 +2023,8 @@ def insert_layer(
19862023
Inserting table data is not supported for ArcGIS Enterprise deployments.
19872024
19882025
.. note::
1989-
Thegeometry engine used for this operation can be set with the
1990-
the `ARCGIS_GEOMETRY_ENGINE` environment variable. Available options:
2026+
TheIO engine used for this operation can be set with the
2027+
the `ARCGIS_IO_ENGINE` environment variable. Available options:
19912028
19922029
* `"shapefile"`
19932030
* `"gdal"`
@@ -2160,8 +2197,8 @@ def to_featureclass(
21602197
The ``to_featureclass`` exports a spatially enabled dataframe to a feature class.
21612198
21622199
.. note::
2163-
Thegeometry engine used for this operation can be set with the
2164-
the `ARCGIS_GEOMETRY_ENGINE` environment variable. Available options:
2200+
TheIO engine used for this operation can be set with the
2201+
the `ARCGIS_IO_ENGINE` environment variable. Available options:
21652202
21662203
* `"shapefile"`
21672204
* `"gdal"`
@@ -2227,8 +2264,9 @@ def to_table(self, location, overwrite=True, **kwargs):
22272264
With ArcPy null integer values will remain null.
22282265
22292266
.. note::
2230-
The geometry engine used for this operation can be set with the
2231-
the `ARCGIS_GEOMETRY_ENGINE` environment variable. Available options:
2267+
The IO engine used for this operation can be set with the
2268+
the `ARCGIS_IO_ENGINE` environment variable. Available options:
2269+
(note that `"shapefile"` is not supported for this method)
22322270
22332271
* `"gdal"`
22342272
* `"arcpy"`
@@ -2389,8 +2427,8 @@ def to_featurelayer(
23892427
With ArcPy null integer values will remain null.
23902428
23912429
.. note::
2392-
Thegeometry engine used for this operation can be set with the
2393-
the `ARCGIS_GEOMETRY_ENGINE` environment variable. Available options:
2430+
TheIO engine used for this operation can be set with the
2431+
the `ARCGIS_IO_ENGINE` environment variable. Available options:
23942432
23952433
* `"shapefile"`
23962434
* `"gdal"`
@@ -2725,8 +2763,8 @@ def from_featureclass(location, **kwargs):
27252763
With ArcPy null integer values will remain null.
27262764
27272765
.. note::
2728-
Thegeometry engine used for this operation can be set with the
2729-
the `ARCGIS_GEOMETRY_ENGINE` environment variable. Available options:
2766+
TheIO engine used for this operation can be set with the
2767+
the `ARCGIS_IO_ENGINE` environment variable. Available options:
27302768
27312769
* `"shapefile"`
27322770
* `"gdal"`
@@ -2779,8 +2817,8 @@ def from_table(filename, **kwargs):
27792817
The ``from_table`` method allows a :class:`~arcgis.gis.User` to read from a non-spatial table
27802818
27812819
.. note::
2782-
Thegeometry engine used for this operation can be set with the
2783-
the `ARCGIS_GEOMETRY_ENGINE` environment variable. Available options:
2820+
TheIO engine used for this operation can be set with the
2821+
the `ARCGIS_IO_ENGINE` environment variable. Available options:
27842822
27852823
* `"shapefile"`
27862824
* `"gdal"`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp