|
POST
|
You are calling your function as a property of arcpy, not a function (not sure why it doesn't give an error, but it's not doing what you think it's doing). It should be: arcpy.ImportTest_CDWGeo()
... View more
04-28-2015
09:03 AM
|
1
|
2
|
3172
|
|
POST
|
The main tool you're looking for is Select Layer By Location, where overlap_type = (ideally) BOUNDARY_TOUCHES or (more realistically) WITHIN_A_DISTANCE (search_distance = 1m or so). You can cycle through individual geometries using a Search or Update Cursor.
... View more
04-27-2015
04:42 PM
|
0
|
0
|
1347
|
|
POST
|
Is the issue that it calculates 3D distance when you want 2D distance, or vice versa? Or are the values completely wrong (e.g. using decimal degrees rather than meters)?
... View more
04-27-2015
04:02 PM
|
0
|
0
|
678
|
|
POST
|
AFAIK, the only way to access guides inside a specific mxd is through ArcObjects, which you can access through comtypes/Snippets (see here for more). I don't believe deleting your Normal.mxt will do anything to an existing mxd, but I can't test that at the moment. This will remove the vertical guides from an mxd, if you have comtypes and Snippets properly installed - you can do the same for horizontal guides: from comtypes.client import GetModule, CreateObject
from Snippets import GetLibPath, InitStandalone
def main():
InitStandalone()
modCarto = GetModule(r"C:\Program Files (x86)\ArcGIS\Desktop10.2\com\esriCarto.olb")
snapGuide = CreateObject(modCarto.SnapGuides, interface=modCarto.ISnapGuides)
mxdObject = CreateObject(modCarto.MapDocument, interface=modCarto.IMapDocument)
mxdObject.Open(r"C:\junk\guides.mxd")
snapGuide = mxdObject.PageLayout.VerticalSnapGuides
snapGuide.RemoveAllGuides()
mxdObject.Save()
del mxdObject
if __name__ == '__main__':
main()
... View more
04-27-2015
02:39 PM
|
0
|
1
|
1923
|
|
POST
|
When you say one polygon shape with two polygons, do you mean one multipart polygon, or two overlapping polygons within the same feature class? It sounds like you're looking for the intersect method within the polygon object(s).
... View more
04-23-2015
06:53 AM
|
0
|
2
|
2502
|
|
POST
|
Can you explain exactly what the correct result is, and why editor clip or Erase would work? Is it that you want to clip based on certain features, not all? I suspect you're looking for arcpy cursors and polygon difference (http://resources.arcgis.com/en/help/main/10.1/index.html#//018z00000061000000), but need more info.
... View more
04-22-2015
07:12 AM
|
0
|
4
|
2502
|
|
POST
|
I'm surprised that the dynamic text doesn't update before exporting - it should. For example, the following script updates dynamic text (current time) between exports: import arcpy
mxd = arcpy.mapping.MapDocument(r'C:/junk/time_test.mxd')
arcpy.mapping.ExportToPDF(mxd, r"C:/junk/time_test1.pdf") #comment on 2nd run
#arcpy.mapping.ExportToPDF(mxd, r"C:/junk/time_test2.pdf") #uncomment on 2nd run
del mxd I suppose I'm confused by this statement: "The script does all the exporting and ordering of pages, so the .mxd never actually opens to update the dynamic text." Can you post your script?
... View more
04-20-2015
02:41 PM
|
0
|
2
|
1614
|
|
POST
|
Good analogy (the moon thing, not the rocket scientist thing haha), my answer is definitely overkill. For most people, adding a dummy image box is the way to go, rather than fighting with ArcObjects.
... View more
04-16-2015
11:52 AM
|
0
|
0
|
1606
|
|
POST
|
Warning: extremely convoluted method below (installing and configuring comtypes/Snippets can be painful), and technically, it doesn't use arcpy at all. But it does use Python You can access most, if not all, ArcMap functionality using ArcObjects in Python. The code below adds 'happy.jpg' to an empty mxd's layout, but with a little tweaking, you could add it to whatever mxd you choose. from comtypes.client import GetModule, CreateObject
from Snippets import GetLibPath, InitStandalone
def CType(obj, interface):
"""Casts obj to interface and returns comtypes POINTER or None"""
try:
newobj = obj.QueryInterface(interface)
return newobj
except:
return None
def main():
InitStandalone()
modCarto = GetModule(r"C:\Program Files (x86)\ArcGIS\Desktop10.2\com\esriCarto.olb")
modGeom = GetModule(r"C:\Program Files (x86)\ArcGIS\Desktop10.2\com\esriGeometry.olb")
modArcMapUI = GetModule(r"C:\Program Files (x86)\ArcGIS\Desktop10.2\com\esriArcMapUI.olb")
modFramework = GetModule(r"C:\Program Files (x86)\ArcGIS\Desktop10.2\com\esriFramework.olb")
app = CreateObject(modFramework.AppROT, interface=modFramework.IAppROT)
mxDoc = CType(app.Item(0).Document,modArcMapUI.IMxDocument)
layout = mxDoc.PageLayout
graphicContainer = CType(layout, modCarto.IGraphicsContainer)
pictureElement = CreateObject(modCarto.JpgPictureElement, interface=modCarto.IPictureElement)
envelope = CreateObject(modGeom.Envelope, interface=modGeom.IEnvelope)
envelope.PutCoords(0, 0, 5, 5)
pictureElement.ImportPictureFromFile(r'C:\junk\happy.jpg')
iElement = CType(pictureElement,modCarto.IElement)
iElement.Geometry = envelope
graphicContainer.AddElement(iElement,0)
app.Item(0).SaveDocument()
if __name__ == '__main__':
main()
... View more
04-16-2015
09:44 AM
|
2
|
2
|
1606
|
|
POST
|
If your layers are each properly referenced (i.e. have the correct spatial reference applied according to their own data), just change the data frame coordinate system to Mollweide to project your data on-the-fly. Here's where to find it (note how I searched for it):
... View more
04-15-2015
02:43 PM
|
1
|
0
|
1437
|
|
POST
|
Those coordinates are lat/long, not British National Grid meters. I assume you want to use a geographic (unprojected) coordinate system (WGS84 or NAD83, probably) to import the points, then Project to British National Grid.
... View more
04-15-2015
02:20 PM
|
1
|
4
|
7978
|
|
POST
|
Can't you just run Summary Statistics, where case fields = soil type and DA value, and stat type = sum area?
... View more
04-14-2015
09:05 AM
|
3
|
2
|
2399
|
|
POST
|
You can access field values by including them in the UpdateCursor. The list, ['SHAPE@XY','X_SHIFT','Y_SHIFT'] (change X_SHIFT and Y_SHIFT to your field names), translates to row[0], row[1], and row[2], respectively. import arcpy
in_features = r"C:/Temp/CP_C06.shp"
def shift_features(in_features):
with arcpy.da_UpdateCursor(in_features, ['SHAPE@XY','X_SHIFT','Y_SHIFT']) as cursor:
for row in cursor:
cursor.updateRow([[row[0][0] + (row[1] or 0), row[0][1] + (row[2] or 0)]])
return
shift_features(in_features)
... View more
04-14-2015
09:00 AM
|
0
|
9
|
3073
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM | |
| 2 | 07-16-2020 11:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|