|
POST
|
How exactly are you running Python? The interactive Python window in ArcGIS? IDLE? Stand-alone Python console?
... View more
07-15-2015
01:31 PM
|
0
|
3
|
3980
|
|
POST
|
Xander Bakker and Dan Patterson, great comments and dialogue, thanks for chiming in. I will elaborate a bit more, but will add comments at the root level to minimize how deep the nested comments go. Overall, like all software packages/applications/libraries, GeoDjango isn't perfect. That said, there are some things it does well in terms of implementing the GEOS library and how one interacts with geometry objects. I think the NumPy integration in ArcGIS/ArcPy is big, a really positive step, but I also see it existing outside of the ArcPy Geometry classes. Maybe the ArcPy Geometry classes are used under the hood for part of the transition between geospatial data store and NumPy array, but the user doesn't directly interact with ArcPy Geometry classes.
... View more
07-15-2015
10:19 AM
|
3
|
1
|
3585
|
|
POST
|
I have been working with Django, specifically GeoDjango, on and off for a few weeks, and I must say it has opened my eyes. When working with the GeoDjango GEOS API, geometries work quite a bit different than in ArcGIS. Geometries are Pythonic GEOSGeometry objects are ‘Pythonic’, in other words components may be accessed, modified, and iterated over using standard Python conventions. Since the idea is already implemented and documented, I won't dive into the specifics here of how true or more Pythonic geometries work. Given that ArcPy is a Python site package, I think ArcPy geometries should be a bit more robust in terms of using standard Python conventions to interact with them. This is one area where ArcGIS Pro has been a big let down, i.e., ArcGIS Pro was not used as an opportunity to re-invent/re-invigorate the ArcPy site package. I have posted the idea on ArcGIS Ideas (Pythonic ArcPy Geometries) and opened an Esri Support Enhancement Request (ENH-000089037: Make ArcPy Geometries truly Pythonic) if anyone wants to vote for it or attach their customer number to the idea.
... View more
07-14-2015
03:24 PM
|
0
|
17
|
11734
|
|
POST
|
Have you done any explicit sorting before running the field calculator? For example, have you sorted the OBJECTID field first and then run the code? My other suggestion was going to be using an update cursor as Xander Bakker has suggested and provided code for already.
... View more
07-14-2015
02:19 PM
|
1
|
0
|
3095
|
|
POST
|
The OP is/was asking about ST_Geometry, and ST_Geometry in SQLite specifically. I agree that a lot of spatial can be done with SQL outside of the SDE stack, but MSDN documentation has limited value in this case since ST_Geometry isn't implemented on SQL Server.
... View more
07-10-2015
10:05 AM
|
0
|
0
|
2985
|
|
POST
|
I don't have any comments regarding the formatting/structure of the code. I think others have already provided good feedback on that topic. In taking a quick look over your code, I do have a couple questions regarding content, if you are open to discussing content as well as structure. What is the purpose of the pass statement on Line #80 or what do you think it is doing? Seeing the use of ArcPy messaging, I assume you are running this as a script tool. Am I right? I ask because the current structure of the code will basically hide errors from the user, i.e., the Results window will always show the script as completing even if it generated an error and didn't complete. As The Zen of Python states: "Errors should never pass silently."
... View more
07-09-2015
01:03 PM
|
1
|
0
|
1878
|
|
IDEA
|
Given that ArcPy is a Python site package, the ArcPy geometries should actually be Pythonic. What do I mean by Pythonic? ArcPy geometries and components should be accessible and modifiable using standard Python conventions like iterating, indexing, and slicing among others. The idea isn't original; in fact, Pythonic geometries have already been implemented in GeoDjango (Geometries are Pythonic).
... View more
07-09-2015
10:40 AM
|
28
|
10
|
6315
|
|
POST
|
Interesting point. Not surprisingly, the documentation for the Extent object isn't very specific. Does the Extent object always return the minimum axis-aligned bounding rectangle or does/can it return a different minimum bounding rectangle in certain situations?
... View more
07-06-2015
03:37 PM
|
0
|
1
|
2506
|
|
POST
|
Are ArcGIS Desktop and MS SQL Server Management Studio installed on the same machine as ArcGIS Pro? What operating system are you running? What SQL Server client, specifically, is installed?
... View more
07-06-2015
11:35 AM
|
0
|
0
|
3598
|
|
POST
|
To follow-up on what Darren Wiens suggests, the Extent object (obtained through the Describe object) got support for JSON and polygon properties at ArcGIS 10.3 (What's new in ArcGIS 10.3). Having the Extent object support polygon properties greatly eases working with them in situations like this one. A couple of comments/thoughts: Extent objects work with Minimum Bounding Rectangles (MBRs), a.k.a. "bounding box." In comparing MBRs of two datasets, it is completely possible that one dataset or MBR of a dataset will fall within the MBR of another dataset while none of the features from either dataset intersect. With the Esri Extent object, and particularly with SDE datasets, I haven't tested whether the Extent object pulls information from existing statistics on a dataset or whether the extent is newly computed when the object is created. If the former, it could be possible the MBR returned isn't accurate if the statistics are stale on a dataset. I can't say one way or another. If it is important enough, I suggest you verify the behavior before relying on it.
... View more
07-06-2015
10:12 AM
|
1
|
3
|
2506
|
|
POST
|
I can't think of anything simple right off the top, but there is nearly always a way to do what you want if you want to do it bad enough. Some ideas are thrown around over in a StackExchange post: Checking current user privileges for an SDE dataset with Python/arcpy. Regardless of the specific approach, verifying permissions before trying to delete a dataset will be an expensive operation, or expensive enough that I might just go with a try/except block instead. Whereas some or most languages are LBYL, Python works pretty well with EAFP. Do you expect the attempt to fail or succeed most of the time? If it fails or the user doesn't have permissions, what will you do then?
... View more
07-01-2015
02:20 PM
|
1
|
0
|
849
|
|
POST
|
From the Python documentation on String Literals: In triple-quoted strings, unescaped newlines and quotes are allowed (and are retained), except that three unescaped quotes in a row terminate the string. (A “quote” is the character used to open the string, i.e. either ' or ".) Since unescaped newlines and quotes are allowed in triple-quoted strings, you need to terminate the triple-quoted string before trying to concatenate it with another string using "normal" syntax.
... View more
07-01-2015
01:55 PM
|
2
|
1
|
6373
|
|
POST
|
The first thing that comes to mind is scope and namespace issues, not syntax, per se. Do you have background processing under Geoprocessing options enabled or disabled? If disabled, does your code run if you enable it? Are you running a Python script in a regular Toolbox or a Python Toolbox?
... View more
07-01-2015
11:50 AM
|
0
|
1
|
6373
|
|
POST
|
Use Calculate Field, it will do the type conversion from double to text for you. (Making simple field calculations)
... View more
07-01-2015
08:48 AM
|
1
|
9
|
3448
|
|
POST
|
If you are willing to install/import comtypes, the following code can be used to give dataset sizes and timestamps for shapefiles in a folder or datasets in a file geodatabase: def GetDatasetFileStatsFromWorkspace(in_workspace):
from comtypes.client import CreateObject, GetModule
import os
def _GetDatasetFileStats(pDataset):
from datetime import datetime, timedelta
from dateutil import tz
DFS = {}
d = datetime(1970, 01, 01, tzinfo=tz.tzutc())
pDFS = pDataset.QueryInterface(esriGeoDatabase.IDatasetFileStat2)
DFS['StatSize'] = pDFS.StatSize
DFS['StatTime'] = {
'LastAccess': d + timedelta(0, pDFS.StatTime(0)),
'Creation': d + timedelta(0, pDFS.StatTime(1)),
'LastModification': d + timedelta(0, pDFS.StatTime(2))
}
return DFS
assert os.path.isdir(in_workspace), "Workspace is not folder or file geodatabase"
comDirectory = os.path.join(
os.path.join(arcpy.GetInstallInfo()['InstallDir']), 'com'
)
esriDataSourcesGDB = GetModule(os.path.join(comDirectory, 'esriDataSourcesGDB.olb'))
esriDataSourcesFile = GetModule(os.path.join(comDirectory, 'esriDataSourcesFile.olb'))
esriGeoDatabase = GetModule(os.path.join(comDirectory, 'esriGeodatabase.olb'))
if in_workspace.endswith('.gdb'):
pWSF = CreateObject(esriDataSourcesGDB.FileGDBWorkspaceFactory,
interface=esriGeoDatabase.IWorkspaceFactory)
else:
pWSF = CreateObject(esriDataSourcesFile.ShapefileWorkspaceFactory,
interface=esriGeoDatabase.IWorkspaceFactory)
pWS = pWSF.OpenFromFile(in_workspace, 0)
pEnumDS = pWS.Datasets(1)
pDS = pEnumDS.Next()
DS = {}
while pDS:
if pDS.Type == esriGeoDatabase.esriDTFeatureDataset:
pEnumSS = pDS.Subsets
pSS = pEnumSS.Next()
while pSS:
Name = os.path.join(pDS.Name, pSS.Name)
DS[Name] = _GetDatasetFileStats(pSS)
pSS = pEnumSS.Next()
else:
DS[pDS.Name] = _GetDatasetFileStats(pDS)
pDS = pEnumDS.Next()
return DS if DS else None A couple or few comments: The dataset size and timestamps are coming from the IDatasetFileStat2 interface of the Geodatabase library. Dataset size is in bytes (original format). Dataset timestamps are Python timedate in UTC (converted from original to Python type). The function returns a dictionary of properties for all shapefiles in a folder or datasets in a file geodatabase. The dictionary keys are dataset names. Feature datasets are recursed, and the feature dataset name is prefixed to the dataset name. The timestamps are further stored in another dictionary with those keys being the type of timestamp: Creation, LastModification, LastAccess. Error catching is limited. The code is demonstrative and not production. One assertion statement is included to catch the most likely error of an invalid workspace type being passed since com errors can be cryptic, or at least in this case. If you do install comtypes and haven't worked with it before, see the following StackExchange post about a configuration change that is necessary to make it work with ArcGIS: ArcObjects + comtypes at 10.1 and newer
... View more
06-30-2015
08:28 PM
|
1
|
1
|
2398
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Friday | |
| 2 | 2 weeks ago | |
| 1 | 2 weeks ago | |
| 2 | 06-05-2026 10:30 AM | |
| 1 | 05-29-2026 08:22 AM |
| Online Status |
Online
|
| Date Last Visited |
5 hours ago
|