|
POST
|
Richie Carmichael, I don't recall seeing any comments or documentation about Diagrammer being retired at 10.2. Did I miss it somewhere?
... View more
12-11-2014
01:03 PM
|
1
|
0
|
11760
|
|
POST
|
A quick code example.... There are various ways to add fields to structured numpy arrays. Although it might not be the most performant, I typically use a solution proposed by Vebjorn Ljosa on StackExchange: Adding a field to a structured numpy array. def add_field(a, descr):
if a.dtype.fields is None:
raise ValueError, "`A' must be a structured numpy array"
b = numpy.empty(a.shape, dtype=a.dtype.descr + descr)
for name in a.dtype.names:
b[name] = a[name]
return b Although some people suggest using append_fields from numpy.lib.recfunctions, I have run into problems when the appended field will hold subarrays. Using the Code Sample from the NumPyArrayToFeatureClass (arcpy.da) Help page (but dropping the TX spatial references): import numpy
outFC = #Output FS location and name
# Create a numpy array with an id field, and a field with a tuple
# of x,y coordinates
array = numpy.array([(1, (471316.3835861763, 5000448.782036674)),
(2, (470402.49348005146, 5000049.216449278))],
numpy.dtype([('idfield',numpy.int32),('XY', '<f8', 2)]))
# Export the numpy array to a feature class using the XY field to
# represent the output point feature
arcpy.da.NumPyArrayToFeatureClass(array, outFC, ['XY']) yields a feature class with the following table: Using the add_field function above to duplicate the 'XY' field: import numpy
outFC = #Output FS location and name
# Create a numpy array with an id field, and a field with a tuple
# of x,y coordinates
array = numpy.array([(1, (471316.3835861763, 5000448.782036674)),
(2, (470402.49348005146, 5000049.216449278))],
numpy.dtype([('idfield',numpy.int32),('XY', '<f8', 2)]))
# Add new field to duplicate XY field so they show up as attributes
arr = add_field(array, [('XY1', '<f8', 2)])
arr['XY1'] = array['XY']
# Export the numpy array to a feature class using the XY field to
# represent the output point feature
arcpy.da.NumPyArrayToFeatureClass(arr, outFC, ['XY']) yields a feature class with the following table: Unlike the Code Sample, I usually don't store the XY coordinates as a tuple in a numpy structured array because they end up getting stored as subarrays, which I find a bit more cumbersome to work with and not a requirement to use NumPyArrayToFeatureClass.
... View more
12-10-2014
10:06 AM
|
0
|
0
|
2552
|
|
POST
|
From a post 6 months ago in the ArcGIS Beta Community forums: Kent Marten wrote: This is expected as direct read of Excel worksheets (or Named Ranges) as tables is not planned to be supported during the first release of ArcGIS Pro.
... View more
12-09-2014
05:50 PM
|
1
|
2
|
2870
|
|
POST
|
You can take the geoprocessing route as Xander Bakker suggests. If you want a pure Python/NumPy solution, please post a bit more information. You say you are getting a duplicate field error with the array, but what method or function is returning the error? I didn't catch it at first, but your original dtype had a Lat and Lat1 as well as a Long and Long1. Do those represent different lats and longs or duplicates? You mentioned pulling this data from a database through a DSN connection to create the array. Would it work to connect to the table and use the MakeXYEventLayer_management to make an event layer that you can save to disk afterwards.
... View more
12-09-2014
03:45 PM
|
0
|
0
|
2552
|
|
POST
|
By default, or at least in my experience, NumPyArrayToFeatureClass doesn't include the shape fields as attribute fields in the output feature class. If you want LatLong as attributes as well, copy the columns and give the new columns a different name, and either use the new columns or the original as the shape fields with the other set getting incorporated as attributes.
... View more
12-09-2014
08:35 AM
|
1
|
3
|
2552
|
|
POST
|
The Key Error outside of the Try block is the crux of the issue. As far as the interpreter is concerned, there is no key corresponding to the value you are giving it, so it returns a Key Error, i.e., u'B01001e1' is not key, period. At this point, are there any differences in capitalization or white spaces? I don't think it is an text encoding issue. Trying printing your dictionary (print dictflds) and double checking that there is in fact a u'B01001e1' key.
... View more
12-08-2014
12:17 PM
|
0
|
1
|
2615
|
|
POST
|
A few things. What is the error message, specifically? Second, it seems you are naming your dictionary 'dict', which shadows the built-in dict constructor. Although shadowing a built-in doesn't break the code, per se, it does make it more difficult to read and therefore more prone to errors. Third, the code snippet doesn't show the dictionary object being created, is that just handled earlier?
... View more
12-08-2014
11:09 AM
|
0
|
3
|
2615
|
|
DOC
|
Rudy Prosser, thanks for pulling this information together in one place. Although I have been working with geodatabases for years, this compilation of geodatabase-related information will be great to share with others in our organization that are newer to geodatabases. Since 10.3 is right around the corner, get ready to update most of the links!
... View more
12-05-2014
12:52 PM
|
0
|
0
|
3920
|
|
POST
|
Map documents (mxd) are part of ArcGIS Desktop, not ArcGIS Pro. ArcGIS Pro is organized differently and has Project files (aprx), similar to the old ArcView Project files (apr). Once you create a new ArcGIS Pro project, you can import MXDs as maps within the project.
... View more
12-05-2014
12:44 PM
|
3
|
3
|
5262
|
|
POST
|
The functional code for recursively listing feature classes in a geodatabase is provided as ListFeatureClasses example 1 in the help for ListFeatureClasses (arcpy). The topic was also covered in the Recursive list feature classes post at ArcPy Cafe a couple years back. For your situation, I believe the following code will work: import os
ws = #path to gdb
arcpy.env.workspace = ws
for ds in arcpy.ListDatasets(feature_type="Feature"):
for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
arcpy.Rename_management(
os.path.join(ws, ds, fc),
os.path.join(ws, ds, '{}_{}'.format(ds,fc[:-3]))
) The code above will rename what you have already manually renamed.
... View more
12-05-2014
06:37 AM
|
0
|
0
|
1656
|
|
POST
|
I ran this question through Esri Support: BUG-000083762: In each cursor documentation, specify the type of lock being closed and released, as a shared lock is still present in the geodatabase after the 'with' statement executes. I can't say I am surprised, but Esri seems to be calling this a documentation bug and not a software bug, likely because it is much easier to update the documentation to say not all the locks are actually removed.
... View more
12-04-2014
03:21 PM
|
0
|
0
|
2878
|
|
POST
|
Bug BUG-000083762: In each cursor documentation, specify the type of lock being closed and released, as a shared lock is still present in the geodatabase after the 'with' statement executes.
... View more
12-04-2014
03:04 PM
|
0
|
0
|
5259
|
|
POST
|
Simply running compress on a geodatabase doesn't ensure all of the edits get pushed into base tables, unless running compress fully compresses the geodatabase. Is the VERSIONS table showing the state ID for the Default version as 0? Also, does the associated versioned view show all the records?
... View more
12-04-2014
05:30 AM
|
1
|
0
|
2619
|
|
POST
|
When you say "in SQL Server," are you querying against the base tables or the associated multiversioned view or versioned view? You may only have the Default version, but the base tables don't reflect what is in the Default version unless the geodatabase has been compressed. Since you are using 10.2.2, versioned views should be created automatically when you register the layers as versioned. Try querying against those views and see if your missing records are there.
... View more
12-02-2014
12:58 PM
|
1
|
4
|
2619
|
|
POST
|
In your original post, you state the SelectLayerByAttribute_management tool is "an expensive transaction." Assuming you mean expensive in terms of time, what are you using to time the tool and what are you comparing it against? Generally, I stick with the arcpy functions and classes as much as possible and use the geoprocessing tools only when necessary or beneficial. In this type of situation, i.e., getting the bounding extent of selected features or a subset of features, I find the geoprocessing tools are faster for most of the datasets I interact with regularly. I have had success using a mapping layer and the SelectLayerByAttribute_management tool: def GetExtent(fc, sql):
lyr = arcpy.mapping.Layer(fc)
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", sql)
return lyr.getSelectedExtent() Writing simple functions and using timeit on one of my datasets with ~250,000 records, I find using a map layer and SelectLayerByAttribute at least an order of magnitude faster than a search cursor. I can't say for your datasets, but it might be worth trying the geoprocessing tools instead of relying on a search cursor.
... View more
12-02-2014
12:44 PM
|
0
|
0
|
4968
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-11-2026 07:04 AM | |
| 1 | a month ago | |
| 2 | 07-06-2026 12:29 PM | |
| 1 | 07-06-2026 12:00 PM | |
| 2 | 06-05-2026 10:30 AM |
| Online Status |
Online
|
| Date Last Visited |
7 hours ago
|