|
POST
|
This is a follow-on comment to an earlier post: ArcGIS Pro update. Currently, Esri has publicly released its third ArcGIS Pro Prerelease, build 1692. The last two builds, 1566 and 1692, have been released as "Prelease Updates." Unfortunately with the Prerelease Updates, they are not available to download through MyEsri. If ArcGIS Pro updates were differential updates, like patches, I could see having users download build 1472 and then update the install using the application itself; however, the updates aren't updates but complete new installations. I don't know how much has changed between builds, but I do know that I am pulling down ~700 MB for each update. Why can't I download build 1692 from MyEsri to deploy internally? Why do i have to create so much extra download traffic? I have currently worked around the issue by grabbing the downloaded MSI and CAB files before the installer cleans them up, but I shouldn't need to find a workaround in the first place. Unless Esri moves towards a truly differential update process, I think the current strategy of updating ArcGIS Pro is flawed and generates lots of unnecessary network traffic, not to mention wasted time while waiting for the not-too-svelte update to download.
... View more
12-15-2014
11:00 AM
|
2
|
8
|
7734
|
|
POST
|
Posting code with syntax highlighting and numbers is useful, as well as specific error messages. For syntax highlighting, click the 'Use advanced editor' link in the upper right corner of the question/reply. Do you know whether the Spatial Analyst extension is being correctly checked out? What is the return value of checking out the license?
... View more
12-14-2014
01:31 PM
|
1
|
0
|
1222
|
|
POST
|
Another tool to consider is Multipart To Singlepart (Data Management). If you took this approach, then you could use the SHAPE@AREA and SHAPE@LENGTH tokens and not get involved directly with manipulating arcpy geometry objects.
... View more
12-14-2014
01:25 PM
|
0
|
0
|
3007
|
|
POST
|
Given the number and nature of your questions today, not to mention the references to "exercise" in path names, it seems you are relying pretty heavily on GeoNet users to figure your class exercises out for you. I don't mind helping a new GIS user get started with arcpy and Python, but I don't get the sense the Help documentation has been thoroughly read before asking for others to provide code. That said, and if I understand your question correctly, I believe the following will get close to what you are after: fc = #path for feature class
SR = arcpy.Describe(fc).spatialReference
units = SR.linearUnitName
cursor = arcpy.da.SearchCursor(fc, ["OID@","SHAPE@"])
for OID, shape in cursor:
print "Feature: {}\tTotal Area: {} {}^2".format(
OID, shape.area, units
)
partnum = 0
for part in shape:
pn = arcpy.Polygon(part, SR)
print "\tPart: {}\t Area: {} {}^2\tPerimeter: {} {}".format(
partnum, pn.area, units, pn.length, units
)
partnum += 1 A few comments to move beyond simply giving you a proverbial fish: If you are going to retrieve the shape as a geometry object, there isn't much point in using the other shape tokens. Since retrieving a shape as a geometry object carries the most overhead, the other tokens were created to speed up the search cursor when one didn't need the full shape but only its area, length, etc.... The code above, since it relies on the area properties instead of the getArea method of the polygon object, assumes you are interested in planar values and using a feature class that is already projected. If you are interested in other measurement types or are using unprojected data, then you will want to look at the getArea method. When retrieving the parts of a polygon, what is returned aren't polygons but arrays of points that need to be reconstructed back into polygons if you are interested in measuring areas and perimeters. I strongly encourage you to read the Polygon (arcpy) help, I think it will help clarify your misunderstanding of how to work with arcpy geometry objects.
... View more
12-14-2014
12:59 PM
|
1
|
2
|
3007
|
|
POST
|
If you look at the Help for Point (arcpy), arcpy.point takes up to five optional arguments with the first two ordered arguments being X and Y coordinates. The coords list is a list of lists with the lists holding XY coordinate pairs. In Python, the asterisk or splat operator is used for Unpacking Argument Lists. Instead of passing each argument explicitly, I used the splat operator to unpack the XY coordinate pairs and pass them together for each point. Following are three different ways to pass the same XY coordinates to arcpy.point: coord = [1.0, 1.0]
#passing XY as indexed list elements
arcpy.Point(coord[0], coord[1])
#passing XY as named local variables
X = coord[0]
Y = coord[1]
#or
X, Y = coord
arcpy.Point(X, Y)
#passing XY using splat operator
arcpy.Point(*coord)
... View more
12-14-2014
10:51 AM
|
2
|
1
|
1231
|
|
POST
|
The gist of what you need is: outFC = #path to shapefile, ending in .shp
coords = [[0.0, 0.0],[0.0, 1.0],[1.0, 1.0],[1.0, 0.0]]
arr = arcpy.Array([arcpy.Point(*coord) for coord in coords])
pn = arcpy.Polygon(arr)
arcpy.CopyFeatures_management(pn, outFC)
... View more
12-14-2014
08:20 AM
|
1
|
3
|
1231
|
|
POST
|
(When I first wrote this reply there was a code snippet that has since been removed, which is unfortunate because it is easier for others to comment on code and it demonstrates previous efforts to solve the problem. Although my comments might not make sense to other readers, the OP should understand them.) Reviewing ArcGIS Help for Create Feature Class (Data Management), especially the code samples, would be helpful. With the current approach you are taking, the Copy Features (Data Management) tool is more likely what you will need.
... View more
12-14-2014
07:26 AM
|
0
|
4
|
1231
|
|
POST
|
Beyond the issue identified by Dan Patterson, you have two additional problems. First, the SQL "IN" operator requires the set of values to be enclosed in parentheses, e.g., expression IN (value1, value2, value3, ...). Second, the ExtractByAttributes where_clause is a string-based SQL expression, and you are passing a reference to a python object instead of an actual string-based list. Assuming values is a Python list containing numbers you want to check for, line 30 would have to be rewritten as: query = "Value IN ({})".format(str(values).strip('[]'))
... View more
12-11-2014
01:51 PM
|
2
|
2
|
1230
|
|
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
|
9086
|
|
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
|
1810
|
|
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
|
1982
|
|
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
|
1810
|
|
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
|
1810
|
|
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
|
1706
|
|
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
|
1706
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 2 weeks ago | |
| 1 | 4 weeks ago | |
| 1 | 12-02-2025 07:31 AM | |
| 1 | 11-03-2025 08:26 AM | |
| 1 | 10-22-2025 12:57 PM |
| Online Status |
Online
|
| Date Last Visited |
7 hours ago
|