POST
|
Yes I am still seeing the error when I try to insert a buffer manually, so that would seem to be the issue, although I tried to add a fairly large polygon that I shortened for viewing purposes: INSERT INTO planningcadastre.demolition_notifications_gis (OBJECTID, NOTIFICATION_ID, SHAPE) VALUES (4, 5, sde.st_geometry('polygon ((3122386.18571073 10066866.95637797, 3122364.77499239 10067520.98755021, 3122300.63437265 10068172.21820313, 3122194.03845723 10068817.85962838, 3122045.44393815 10069455.14673963, 3121855.48696898 10070081.35119589, 3121624.98119640 10070693.79058780, ...3122300.63437265 10065561.69455279, 3122364.77499239 10066212.92520571, 3122386.18571073 10066866.95637797)',2277))
... View more
12-02-2019
02:17 PM
|
0
|
0
|
948
|
POST
|
Thanks everyone. I modified the query to this and good news - I dont receive a syntax error, just ORA-01031: insufficient privileges! I suspect I dont have those for the geometry_st functions? I am asking my IT about that. BTW, I also tried it without the where clause as suggested, and I get the same error. INSERT INTO planningcadastre.demolition_notifications_gis (OBJECTID, NOTIFICATION_ID, SHAPE) select 1,2,sde.st_buffer(l.shape, 500) from location.address_point l where l.place_id = 802689;
... View more
12-02-2019
10:25 AM
|
0
|
1
|
948
|
POST
|
Hello, Is it possible to use an st_geometry function that is part of a SELECT statement to INSERT records into an Oracle SDE geodatabase (12g)? I have constructed the following statement from which I receive Error ORA-00917; missing comma. INSERT INTO gis_table (objectid, gis_table_id, shape) VALUES (1, 2, (sde.st_geometry ('polygon((SELECT sde.st_astext(sde.st_buffer(l.shape, 500)) as shapebuffer FROM location.address_point l where l.place_id = 802689))', 2277)) The part of the query SELECT sde.st_astext(sde.st_buffer(l.shape, 500)) as shapebuffer FROM location.address_point l where l.place_id = 802689 returns and Oracle type CLOB, which turns out to actually be POLYGON (( 3112886.18568189 10066866.95637797, 3112885.11514598 10066899.65808421, etc etc)), So I see I may be duplicating the keyword POLYGON, but I have changed that and I get other errors. Or I freely admit I may be using the wrong functions or process to do this. Thanks in advance of the great answers I am sure to get... Paul Frank
... View more
11-26-2019
11:33 AM
|
1
|
5
|
1143
|
POST
|
Darren, Now I think you were correct the first time. I ran it again and my fix didn't work. So then I looked at it again, and I am using 2 versions of the same layer in this mxd, so I went back and added your code to the other layer, and everything looks correct now. I am still a little foggy on what is going on but it seems to work. Again, thanks!
... View more
12-04-2015
02:08 PM
|
0
|
0
|
1882
|
POST
|
Darren, You helped me figure it out. I did have the code you suggested but I got to thinking it still had something to do with the surchcursor. It turns out I needed to move on to the next record before exporting the map, as opposed to after, which is how I had it. Thanks!
... View more
12-04-2015
01:53 PM
|
0
|
1
|
1883
|
POST
|
Hello, Perhaps this is really an Arcmap question, but I am using arcpy.searchcursor to find new records, perform a definition query on a polygon, and create maps from the polygon outline. Everything works as intended except after the first map, subsequent maps have a polygon with the blue selection outline. Ive tried a few things to eliminate this. One workaround I have considered is creating a new layer from the definition query, and removing the old layer. I have also changed the options in Arcmap to not use blue as a selection color. I suppose this has something to do with the searchcursor, but I am not sure how to get around that. Thanks for looking Paul Frank
... View more
12-04-2015
12:01 PM
|
0
|
4
|
4636
|
POST
|
Hello, I am having trouble adding a thumbnail along with my addItem statement in the attached python script. A file is successfully added to ArcGIS online, but the thumbnail is nowhere to be found. I have searched for answers and followed the help as best I can but without success. Any help is much appreciated.
... View more
07-31-2015
01:41 PM
|
0
|
1
|
3004
|
POST
|
Hello again, I found my problem. Thanks to all who looked. The issue was I hadn't created legend object for the second map. After discovering that, I copied the code for the first legend, then forgot to change the mxd object to the second map. I also cleaned up some of the variables. Here is the last part of the script where I made the fixes: mxd.saveACopy(newplanamendmeetingmxd) #save to another file
meetingmxd = arcpy.mapping.MapDocument(newplanamendmeetingmxd)
dfmeetingmxd = arcpy.mapping.ListDataFrames(meetingmxd)[0]
planamendbwaddlayer = arcpy.mapping.Layer(bufferlayerlocation)
arcpy.mapping.AddLayer(dfmeetingmxd, planamendbwaddlayer, "TOP")
notifylayer = arcpy.mapping.ListLayers(meetingmxd, notificationupdatelyr, dfmeetingmxd)[0]
arcpy.mapping.UpdateLayer(dfmeetingmxd, notifylayer, notifysymlyr, True)
removelyr = arcpy.mapping.ListLayers(meetingmxd, notificationupdatelyr, dfmeetingmxd)[0]
arcpy.AddMessage("removelayer is " + removelyr.name)
meetinglegend = arcpy.mapping.ListLayoutElements(meetingmxd, "LEGEND_ELEMENT", "Legend")[0] #set legend object
meetinglegend.removeItem(removelyr)
meetingmxd.save()
... View more
05-16-2014
11:21 AM
|
0
|
0
|
334
|
POST
|
Hello, I use a python script in arccatalog that creates an mxd, adds a layer, updates it's symbology, and then tries to remove it from the legend. The error I receive is Traceback (most recent call last): File "G:\NEIGHBOR PLAN\ArcView\Scripts_Extns\make_plan_amendment_map.py", line 107, in <module> legend.removeItem(removelyr) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\_mapping.py", line 745, in removeItem return convertArcObjectToPythonObject(self._arc_object.removeItem(*gp_fixargs((legend_item_layer, index), True))) IndexError: 0 I post the entire script here, but the issue comes up at the very end. I know there are some inefficiencies but I was having a hard time understanding that I hadn't created the necessary layer objects required for the UpdateLayer and AddLayer tools. The offending code is commented out. # ------------------------------------------------------------------------------
# Name: make_plan_amendment_map.py
# Purpose: Make and print a plan amendment map. The user
# enters a case number, and the script would zoom the map to that
# case and fill out the title and other map elements based on the
# case information.
# Created on: December 20, 2011
# Updated on: May 15, 2014
# By: Paul Frank
# ------------------------------------------------------------------------------
# Import system modules
import arcpy
from arcpy import env
import os
env.overwriteOutput = True
#declare setup variables
print arcpy.GetMessages()
inworkspace = arcpy.GetParameterAsText(0) #declare workspace variable
incasenum = arcpy.GetParameterAsText(1) #case number to center map
innpa = arcpy.GetParameterAsText(2) #neighborhood planning area
innewuse = arcpy.GetParameterAsText(3) #new land use
inolduse = arcpy.GetParameterAsText(4) #old land use
inaddress = arcpy.GetParameterAsText(5) #address
mxd = arcpy.mapping.MapDocument(r"G:\NEIGHBOR PLAN\ArcView\Projects\Templates\\planamendment_template.mxd")
newordinancemxd = inworkspace + "\\" + incasenum + "_ordinance_request.mxd"
newplanamendmeetingmxd = inworkspace + "\\" + incasenum + "_FLUM_BW.mxd"
notificationbufferlyr = r'G:\NEIGHBOR PLAN\ArcView\Themes\Neighborhood Planning Areas\planamendmentbufferlyrs\notification_buffer.lyr'
qyrstring = "CASE_NUMBER = " + "'" + incasenum + "'" #string to create definition query
amendbuffer = incasenum[0:13].replace('-', '')
notificationupdatelyr = "notification_buffer"
amendbufferpath = r"G:\NEIGHBOR PLAN\ArcView\Themes\Neighborhood Planning Areas\plan_amendments.gdb\Polygons" + "\\" + amendbuffer
bufferlayerlocation = r"G:\NEIGHBOR PLAN\ArcView\Themes\Neighborhood Planning Areas\planamendmentbufferlyrs" + "\\" + amendbuffer + ".lyr"
arcpy.AddMessage("Amendment buffer is " + amendbufferpath)
arcpy.AddMessage("Created variables!")
#create definition query for case and zoom to that polygon
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] #set dataframe object
flumlyr = arcpy.mapping.ListLayers(mxd, "FLUM", df)[0] #set layer object for selection target
zcaselyr = arcpy.mapping.ListLayers(mxd, "ZoningCases", df)[0] #set layer object to select from
zcaselyr.definitionQuery = qyrstring #create definition query for centering map
df.extent = zcaselyr.getSelectedExtent(False)
currentscale = df.scale
if currentscale < 2400:
df.scale = 2400
else:
df.scale = 3600
arcpy.AddMessage("Created definition query for case and zoomed to case polygon!")
arcpy.Buffer_analysis(zcaselyr, amendbufferpath, "500 Feet", "FULL", "ROUND", "ALL")
bufferlayer = arcpy.MakeFeatureLayer_management(amendbufferpath, "notification_buffer").getOutput(0)
arcpy.SaveToLayerFile_management(bufferlayer, bufferlayerlocation, "ABSOLUTE")
#select nearby features to draw in legend
nameofflumlyr = flumlyr.name
arcpy.AddMessage("Flum layer is" + nameofflumlyr)
arcpy.SelectLayerByLocation_management(flumlyr, "WITHIN_A_DISTANCE", zcaselyr, "2000 Feet", "NEW_SELECTION") #select nearby features
outputlyr = "FLUM_Select" #declare variable to add selected features to display
selLayer = arcpy.MakeFeatureLayer_management(flumlyr, outputlyr).getOutput(0) #make feature layer from selection
arcpy.AddMessage("Drew Legend!")
#adjust symbology and legend
arcpy.ApplySymbologyFromLayer_management(selLayer, flumlyr) #use symbology from parent layer
arcpy.mapping.AddLayer(df, selLayer)
arcpy.mapping.RemoveLayer(df, flumlyr) #remove parent layer
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0] #set legend object
legend.adjustColumnCount(2) #adjust legend object
flumstring = innewuse.replace("'", "")
zcaselyr.name = flumstring
arcpy.AddMessage("Adjusted Symbology in Legend!")
#adjust title and subtitle
elmtitle = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Title")[0]
elmtitle.text = "Exhibit A" + '\n' + innpa + " Neighborhood Planning Area" + '\n' + "Amendment " + incasenum
arcpy.AddMessage("Adjusted Title!")
elmcallout = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Callout")[0]
elmcallout.text = inaddress + '\n' + " " + '\n' + "Future Land Use Designation:" + '\n' + innewuse
arcpy.AddMessage("Adjusted Callout!")
#create final mxd
mxd.saveACopy(newordinancemxd) #save to another file
arcpy.AddMessage("Saved ordinance request map!")
elmtitle.text = innpa + " Neighborhood Planning Area" + '\n' + incasenum
elmcallout.text = inaddress + '\n' + "Future Land Use Map Request:" + '\n' + "From: " + inolduse + '\n' + "To: " + flumstring
arcpy.AddMessage("Saved plan amendment meeting map! Open maps and make necessary adjustments")
#create meeting mxd with buffer
mxd.saveACopy(newplanamendmeetingmxd) #save to another file
meetingmxd = arcpy.mapping.MapDocument(newplanamendmeetingmxd)
dfmeetingmxd = arcpy.mapping.ListDataFrames(meetingmxd)[0]
planamendbwaddlayer = arcpy.mapping.Layer(bufferlayerlocation)
arcpy.mapping.AddLayer(dfmeetingmxd, planamendbwaddlayer, "TOP")
notifylayer = arcpy.mapping.ListLayers(meetingmxd, "notification_buffer")[0]
planamendbwaddlayersymbol = arcpy.mapping.Layer(notificationbufferlyr)
arcpy.mapping.UpdateLayer(dfmeetingmxd, notifylayer, planamendbwaddlayersymbol, True)
arcpy.AddMessage("updated layer!")
#removelyr = arcpy.mapping.ListLayers(meetingmxd, "notification_buffer", dfmeetingmxd)[0]
#legend.removeItem(removelyr)
meetingmxd.save()
del mxd
arcpy.AddMessage("Created Map!")
... View more
05-15-2014
07:42 AM
|
0
|
1
|
882
|
POST
|
Hello, I also tried deleting ALL of the 3rd party applications, including FME, LP360, and others, and ArcMap finally opened, although it is still somewhat slow. But at least I can open it. There may be one 3rd party application that is slowing or preventing Arcmap from opening, so obviously delete one at a time, unless you want to delete all of them and reinstall what you need later. Thanks Paul Frank City of Austin
... View more
10-11-2013
11:46 AM
|
0
|
0
|
645
|
POST
|
Hello, Perhaps this question needs to be in another forum, but I loaded the USA_Recent_Population_Change layer from ArcGIS online, and the legend appears to be from the 2000-2010 population change, in various colors, instead of the blue chlorepleth that appears in the map. Will you all update this information soon? The link given in the layer description - http://goto.arcgisonline.com/maps/Demographics/USA_Recent_Population_Change - doesnt seem to work or tell me anything more. Thanks Paul City of Austin
... View more
06-04-2013
01:06 PM
|
0
|
0
|
593
|
POST
|
Paul: In your last post you stated: "But there are also a lot of definition queries and symbology that will require additional changes in the mxd's themselves." Can you please explain what additional work would need to be done with definition queries and symbology when moving to a new geodatabase? Any definition queries and symbology based on old field names will need to be changed. That will be a challenge for some of our less experienced users. I wrote this script for my department because nothing was provided by our IT department. The script repairs the datasource, but if a user wants the color blue to represent something, they might get green. Arcmap 10 python does not have modules for symbols. My understanding is we will eventually have a layer library so this sort of transition is smoother in the future.
... View more
11-13-2012
01:15 PM
|
0
|
0
|
406
|
POST
|
It definitely looks like you have your mxd.save() outside of your loop. I would have it as the last line under your if statement to verify your file is an mxd.
if filename.lower().endswith(".mxd"):
...
arcpy.AddMessage("Finished replacing " + filename)
mxd.save()
Mathew, Thanks. That seems to be the trick. Another issue I was having was the script would get stuck on event layers. So I added a second qualifier to my if statement: for lyr in lyrs:
if lyr.isFeatureLayer and 'sde' in lyr.dataSource: #added the 'sde' code to proceed on sde sources
In the end, I was hoping this script would do a good portion of the work required to make our transition to new SDE sources. But there are also a lot of definition queries and symbology that will require additional changes in the mxd's themselves. Anyways, I'm attaching the final working .py file. Cheers, Paul
... View more
11-13-2012
08:08 AM
|
0
|
0
|
406
|
POST
|
Hello - we are migrating to new SDE datasources, and I am trying to make the changes to our mxd's. This is complicated by new names for the geodatabases. My issue now seems to be when saving the mxd's. I have a number of loops, and perhaps the problem is I do not have my indentations correct. In the end, I am not seeing the changes in the mxds. Any suggestions are appreciated! Paul Frank # Author: Paul Frank, City of Austin # Date: November 7, 2012 # Version: ArcGIS 10.0 # Purpose: This script will iterate through each MXD in a folder and change the SDE connection and dataset name. # Then it will save the mxd that it has finished changing. The script is intended to run from a script # tool that requires a parameter with the folder containing MXDs. #setting variables import arcpy, os arcpy.env.overwriteOutput = True print arcpy.GetMessages() #setting variables for new data source and table that lists the old and new dataset names newdatasource = r"C:\Documents and Settings\frankp\Application Data\ESRI\Desktop10.0\ArcCatalog\DataMart.sde" sdechangetable = r"G:\NEIGHBOR PLAN\ArcView\Themes\GIS_Administration\sde_change.dbf" #Read input parameters from GP dialog #folderPath = arcpy.GetParameterAsText(0) folderPath = r"C:\arcinfo\New Folder" try: #Loop through each MXD file for filename in os.listdir(folderPath): fullpath = os.path.join(folderPath, filename) if os.path.isfile(fullpath): if filename.lower().endswith(".mxd"): #Reference MXD mxd = arcpy.mapping.MapDocument(fullpath) arcpy.AddMessage("Changing " + mxd.filePath) print "changing " + mxd.filePath #Reference each data frame and report data DFList = arcpy.mapping.ListDataFrames(mxd) for df in DFList: #Reference each layer in a data frame lyrs = arcpy.mapping.ListLayers(mxd, "", df) for lyr in lyrs: if lyr.isFeatureLayer: olddataset = lyr.datasetName arcpy.AddMessage("Setting " + olddataset) print "Setting " + olddataset rows, row = None,None rows = arcpy.SearchCursor(sdechangetable, "\"OLDSDE\" = " + "'" + olddataset + "'") row = rows.next() #proceed if a match is found in sde layers list if row <> None: newdataset = row.getValue("NEWSDE") arcpy.AddMessage("Changing " + olddataset + " to " + newdatasource + " " + newdataset) print "Changing " + olddataset + " to " + newdatasource + " " + newdataset #attempt to change the datasource. Datasource may not actually exist even if found in list try: lyr.replaceDataSource(newdatasource, "SDE_WORKSPACE", newdataset) lyr.name = newdataset arcpy.AddMessage(olddataset + " changed!") print olddataset + " changed!" except: arcpy.AddError(arcpy.GetMessages(2)) #do not proceed because no match was found in sde layers list else: arcpy.AddMessage("Can not replace " + lyr.name) print "Can not replace " + lyr.name else: arcpy.AddMessage("Trying next layer") print "trying next layer" arcpy.AddMessage("Finished replacing " + filename) mxd.save() arcpy.AddMessage("Saved " + filename) print "saved copy of mxd" del mxd del row del rows del folderPath, fullpath except Exception, e: import traceback map(arcpy.AddError, traceback.format_exc().split("\n")) arcpy.AddError(str(e))
... View more
11-09-2012
07:03 AM
|
0
|
6
|
2412
|
POST
|
Folks, Ok, we just unchecked the "Use Printer Paper Settings" on the Page and Print Setup. Problem solved, though I'd like to know why it defaulted to the "slide" setting when I open the file. Thanks
... View more
03-30-2012
07:20 AM
|
0
|
0
|
454
|
Title | Kudos | Posted |
---|---|---|
1 | 11-26-2019 11:33 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|