|
BLOG
|
Dan Patterson wrote: Sorted dictionaries should be the norm for namespace, but alas, that won't happen.. Sorted or ordered? If you meant ordered, there is some light around the corner with ArcGIS Pro since it uses Python 3.x. With Python 3.x, one can create a metaclass and use the __prepare__() method to replace the normal/default/unordered namespace dictionary with an ordered dictionary. I can't recall at the moment whether I have seen someone implement similar functionality in Python 2.x, but it surely wouldn't be as straightforward as in Python 3.x.
... View more
01-05-2015
03:39 PM
|
0
|
0
|
594
|
|
POST
|
How are you setting the workspace environment? Can you post the functional part of the code that isn't working? Do you have more than 1 Python install on the machine?
... View more
12-22-2014
06:54 AM
|
0
|
6
|
3665
|
|
POST
|
When it comes to discrete raster data, especially color maps, I have always thought ArcMap's rendering engine falls short. Looking at how a section of 470012130.tif renders on my screen between Windows Photo Viewer and ArcMap. Windows Photo Viewer: ArcMap: Granted, Windows Photo Viewer is treating the image as RGB while ArcMap is dealing with the color map, but it just seems the quality difference shouldn't be this pronounced.
... View more
12-21-2014
08:54 AM
|
0
|
0
|
1177
|
|
POST
|
Switching to bilinear could make things worse in this case because the data is discrete, even densely discrete. Bilinear resampling is more for continuous data, and even the Improving the display of raster data help page is really geared toward continuous data and not discrete data.
... View more
12-21-2014
08:16 AM
|
0
|
0
|
5458
|
|
POST
|
The ZIP file you reference has 2 TIFs. Both are georeferenced, although only one of them has the term "geo" in it. Looking at the TIFF image metadata shows the following, and ArcMap shows the same information. 470012130_geo.tif: Geographic, NAD83 470012130.tif: Projected, NAD83 UTM zone 10N Which image are you having problems with? And what is the projection of the data frame? Your "good" capture didn't come through as an attachment so I am not clear on what you are expecting to see.
... View more
12-21-2014
08:10 AM
|
0
|
1
|
1177
|
|
POST
|
Although this is an older thread/message, I stumbled onto this problem recently and noticed some odd behavior with the ArcPy Geometry Classes and spatial references. As Neil Ayres points out, including a spatial reference is a good practice. The documentation of ArcPy Geometry Classes is a bit weak or confusing on this specific issue because spatial_reference is listed as an optional argument with a default value of None. According to the documentation, there is no reason your original code shouldn't work. What is happening might be related to a similar issue that was discussed in detail years back by Dan Patterson and David Wynne in the Errors in arcpy's Polygon class thread. I don't know what exactly is going on, but I would say there is a bug in the ArcPy Geometry Classes. Looking at the same set of coordinates with four different spatial reference scenarios: coords = [(147.7359, -35.5386), (147.7374, -35.5397), (147.7304, -35.5409),
(147.7304, -35.5409), (147.7255, -35.5439), (147.7249, -35.5416)]
SR_list = [['noneSR', None],
['emptySR', arcpy.SpatialReference()],
['webmercSR', arcpy.SpatialReference(3857)],
['wgs84', arcpy.SpatialReference(4326)]]
results = [['SR_Name', 'Type', 'PCSName', 'GCSName', 'XYResolution', 'pointCount']]
for SR_name, SR in SR_list:
pn = arcpy.Polygon(
arcpy.Array([arcpy.Point(*coord) for coord in coords]),
SR
)
pnSR = pn.spatialReference
if pnSR is None:
results.append([SR_name, SR.type, SR.PCSName,
SR.GCSName, SR.XYResolution, pn.pointCount])
else:
results.append([SR_name, pnSR.type, pnSR.PCSName,
pnSR.GCSName, pnSR.XYResolution, pn.pointCount])
for result in results:
print '{:<12}{:<12}{:<36.34}{:<12.10}{:<12.10}{:<4}'.format(*result)
Yields:
SR_Name Type PCSName GCSName XYResoluti pointCount
noneSR Unknown 0.0001 0
emptySR 0.0 6
webmercSR Projected WGS_1984_Web_Mercator_Auxiliary_Sp 0.0001 0
wgs84 Geographic GCS_WGS_19 1e-09 6
To me, this behavior seems odd. Using no spatial reference (None), which is the default, arcpy.Polygon does not generate an error, but it effectively doesn't generate a polygon either (from a practical perspective, I don't consider a polygon with zero points a polygon, especially when it should have six points). Using an empty spatial reference, arcpy.Polygon generates a 6-pt polygon using a spatial reference that has no type, no names, and no XY resolution. Interestingly enough, although a polygon is generated with six points and all the Polygon methods work, none of the geoprocessing tools (CopyFeatures_management, etc...) that I tried would work with it, likely due to its nonexisting spatial reference. Using the Web Mercator projection, arcpy.Polygon fails to create the polygon in question even though the coordinates are valid within the Web Mercator projection. And finally using a geographic coordinate system, arcpy.Polygon generates the polygon we have been after the whole time. From my perspective, the none/default and Web Mercator spatial references should generate a 6-pt polygon but don't while the empty spatial reference should generate an error instead of generating a 6-pt polygon.
... View more
12-18-2014
02:59 PM
|
1
|
6
|
3338
|
|
POST
|
Your current attempt isn't working because you are trying to multiply a string by a floating point number, which Python doesn't like so the CalculateField_management tool won't work either. Try rewriting Line 21 as: Expression = "!Qs_Mt_a! * {}".format(float(LSARqssedret))
... View more
12-17-2014
09:02 AM
|
2
|
5
|
2600
|
|
POST
|
From Database connections in ArcGIS Pro: Note: ArcGIS Pro connects to enterprise geodatabases and enterprise databases (contains no geodatabase repository tables) on supported platforms, however, the contents of an enterprise database cannot be added to the Map at this time. Please read more about the Make Query Layer geoprocessing tool as an alternative to working with data stored in a database.
... View more
12-17-2014
06:08 AM
|
0
|
0
|
792
|
|
POST
|
I have IE11 on Windows 7, the specific path may differ by OS or IE version.
... View more
12-15-2014
12:46 PM
|
0
|
0
|
2489
|
|
POST
|
C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\{uniquiely_generated_folder_name}\downloads.arcgis.com As soon as the installer is complete, all the files in those folders are deleted, so there is a window of opportunity to copy them out.
... View more
12-15-2014
12:39 PM
|
0
|
2
|
2489
|
|
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
|
8649
|
|
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
|
1732
|
|
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
|
4059
|
|
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
|
4059
|
|
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
|
1986
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 3 weeks ago | |
| 1 | 4 weeks ago | |
| 1 | 3 weeks ago | |
| 3 | 3 weeks ago | |
| 1 | 05-22-2026 05:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
Thursday
|