|
POST
|
Thanks for sharing that toolbox Dan, it was 99% of my solution, I just had to tweak the code as it kept crashing as I was using a File GDB and my field names were > 10 characters long, so in the Python I just had it trim the field names back and now it works a treat. Thanks again.
... View more
04-03-2016
04:38 PM
|
0
|
1
|
3001
|
|
POST
|
Hey, I have a points feature class, and it consists of features that all have a unique name, but also a 'site name'. So dozens of points, can have identical site names. I would like to create a polygon around each 'group' of points with the same attribute. For example, all points with the attribute 'Green', then all with attribute of 'Red', then all with attribute 'Orange'. note these points can be co-mingled, so the polygons will be overlapping. The end goal is to create a data driven page set to print all 'like' points. here is a very accurate and 'to scale' outline of what I want... I want the three polygons to be created automatically. Is anyone able to tell me the steps I need to take to create these polygons automatically? Nathan Duncan
... View more
03-31-2016
05:36 PM
|
0
|
4
|
5729
|
|
POST
|
Hi All, Problem: when I turn labels on within a feature class with a join, I get the error 'The field is not nullable'. Method: I have got a Feature class with all properties in my area, these all have a 'parcel_no', these parcels can be joined to an Oracle DB using a simple SQL Query Layer, this is the query: select
CAST(mdu_acc AS INT) as PARC_NO
from
aumememo
where
mem_typ = '38'
group by mdu_acc This returns a table which is looking exactly as expected. No errors appear at this stage. So i then navigate to my polygon feature class, and create the join to this newly added table, all works fine: Still no errors appear, and they display perfectly on the map (in red). Next I try to add a label based on the parcel number from the original Polygon Feature Class, very simple: I press OK, then Bingo, the error appears, but note the labels display perfectly: I have gone and tried to do a simple python label query where it only returns items where fiels is not None, this had no effect at all. I can try turning off the labels in order to remove the error, but this has no effect also. The only way I can get the error to bugger off is by removing the join, then adding the join again. But the second I turn labels on the error re-appears. Has anyone found a solution to this or experienced this before? I am wondering if there is a bug in arc map when creating a join and labeling. I have come across this in the past, but it is not consistent as far as I can tell. Thanks for your time. -Ben Nathan Duncan
... View more
03-30-2016
05:02 PM
|
0
|
0
|
2954
|
|
POST
|
This thread just solved a problem for me, so I thought I would comment on what I did to get the desired outcome, the same as what the original question is. I tried the python script Chase Carter added earlier in this thread, worked perfectly for me, it provided the below columns in a feature class: I did two things differently, the first being I ran it in the python command line, rather than making a toolbox tool. The reason being this will be a once off use, I dont see myself needing this tool very often. The second thing I did was added a line to define the feature class I wanted the fields to be added to. the reason I did this was because I was not using a toolbox tool, but simply running command line. So from Chase' code I deleted these two lines: #Get evidence feature layer name
out_feat_class = gp.GetParameterAsText(0) Then I added a single line in the same spot I deleted the previous two lines from (approx line 26-27) out_feat_class = r'Database Connections\GISADMIN@SDE_Spatial@Smithy.sde\SDE_SPATIAL.GISADMIN.Uploading_New_Data\SDE_SPATIAL.GISADMIN.Airport_ORC_Bearing_Lines' So in summary, this is the entire code I ran to produce the two columns highlighted yellow above: """
Add fields of azimuths and bearings to a featurelayer of lines.
Azimuths can be based on map or geodgraphic coordinates.
For segmented lines, azimuths are length-weighted averages of segments.
"""
# Import system modules
import sys, string, os, math, random, traceback, tempfile
# Create the Geoprocessor object
#gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
import arcgisscripting
gp = arcgisscripting.create()
### Check out any necessary licenses
##gp.CheckOutExtension("spatial")
##
gp.OverwriteOutput = 1
# Load required toolboxes...
#gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
# Script arguments...
try:
#Get bearing type
geodesic = 'true' #gp.GetParameterAsText(1) == 'true'
#Get evidence feature layer name
out_feat_class = r'Database Connections\GISADMIN@SDE_Spatial@Smithy.sde\SDE_SPATIAL.GISADMIN.Uploading_New_Data\SDE_SPATIAL.GISADMIN.Airport_ORC_Bearing_Lines'
#gp.AddMessage(gp.describe(out_feat_class).shapetype)
if gp.describe(out_feat_class).shapetype != "Polyline":
raise Exception,'not a polyline-type feature class'
#Check for Azimuth field
fieldnames = []
fields = gp.ListFields(out_feat_class)
field = fields.next()
while field:
fieldnames.append(field.name)
field = fields.next()
if 'SDMBearing' not in fieldnames:
gp.addfield_management(out_feat_class,'SDMBearing','long',5)
if 'SDMAzimuth' not in fieldnames:
gp.addfield_management(out_feat_class,'SDMAzimuth','long',5)
#Open attribute table for update featureclass
outrows = gp.updatecursor(out_feat_class)
#Define the bearing, azimuth algorithm
def geodesic_azimuth(inshape):
""" Map azimuth calculation from a polyline shape """
sumazmlen = 0
sumbrglen = 0
sumlen = 0
line = inshape.getpart(0)
pnt = line.next()
if pnt:
pnt0 = pnt
pnt = line.next()
while pnt:
delx = pnt.X-pnt0.X
dely = pnt.Y-pnt0.Y
sdmazimuth = int(89.5-math.atan2(dely,delx)*180/math.pi)
if sdmazimuth < -90:
sdmbearing = sdmazimuth + 180
elif sdmazimuth > 90:
sdmbearing = sdmazimuth - 180
else:
sdmbearing = sdmazimuth
#gp.AddMessage(str((sdmbearing,sdmazimuth)))
# sumbrglen += sdmbearing*len
# sumazmlen += sdmazimuth*len
# sumlen += len
pnt0 = pnt
pnt = line.next()
# return [sumbrglen/sumlen,sumazmlen/sumlen]
return [sdmbearing,sdmazimuth]
#Process the lines
outrow = outrows.next()
while outrow:
if geodesic:
outshape = outrow.shape
[sdmbearing,sdmazimuth] = geodesic_azimuth(outshape)
#gp.AddMessage('!: %s,%s'%(sdmbearing,sdmazimuth))
outrow.sdmbearing = sdmbearing
outrow.sdmazimuth = sdmazimuth
else:
pass #map_azimuth(inrow.shape)
outrows.updaterow(outrow)
outrow = outrows.next()
#georow = georows.next()
except (Exception):
# get the traceback object
tb = sys.exc_info()[2]
# tbinfo contains the line number that the code failed on and the code from that line
tbinfo = traceback.format_tb(tb)[0]
# concatenate information together concerning the error into a message string
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + \
str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"
# generate a message string for any geoprocessing tool errors
msgs = "GP ERRORS:\n" + gp.GetMessages(2) + "\n"
gp.AddError(msgs)
# return gp messages for use with a script tool
gp.AddError(pymsg)
# print messages for use in Python/PythonWin
print pymsg
print msgs
raise
... View more
02-17-2016
03:32 PM
|
0
|
1
|
3250
|
|
POST
|
HI Blake, thanks very much for sharing your code, I have got a somewhat similar system automated in out system (no where near as clean cut as yours, mine is very 'backyard' code). I would like to ask an additional question, I see you analyze Datasets on all your tables, can someone claify if this is necessary? I understand this is handy right after performing a compress on the database as it does something (i am unsure what) to all the system tables, but I am unsure what it does with regards to standard feature classes? So i'm not sure if it is necessary for me to run every week on each of my feature classes within my SDE Database. Can you comment on why you run it on your entire system? One other question i just thought of, I notice you run your rebuild index BEFORE you run the Analyze Datasets, is there a reason you have decided to run in this order? I cant find it now, but believe in the past I read that they should be run in the other order, directly after compressing the database. Im hoping someone can set me straight with that one too...
... View more
01-21-2016
09:54 PM
|
0
|
16
|
6831
|
|
POST
|
Hi, I have hundreds of feature datasets that have incorrect XY entents (unknown reason as to why), but I am hoping to save time by automating the pressing of the 'Recalculate' button as seen below: Does anyone know of a tool that I can run with an iterator to run over each of my feature classes??? Thanks
... View more
01-12-2016
09:54 PM
|
1
|
15
|
13672
|
|
POST
|
Nathan Duncan the schema.ini file rears its ugly head again!
... View more
08-17-2015
05:23 PM
|
0
|
0
|
943
|
|
POST
|
Hi All, I have two Polygon layers, one is "Land Parcels", and the other one is "Central Business District (CBD)". Someone has asked me to provide a map showing the CBD area, color the properties within the CBD area Red, and all other properties blue. I know I can do a simple select by location, export a feature class of CBD properties and color this way, but as this property layer changes daily I would like this map to be dynamic. So each time I open the MXD the map is up-to-date. See attached area and two Feature Classes. Adding a field is not an option unfortunately. Any suggestions? Im not good at thinking outside the box. I should also note that this plan will need to be updated and re-distributed every month, hence my automation request, rather than the export feature class workflow. Cheers
... View more
07-26-2015
08:57 PM
|
0
|
3
|
3732
|
|
POST
|
I understand your comment, but not every client/customer/peer I have contact with has access to some form of GIS. I think Excel is a wonderful medium to transfer data between myself and the rest of the world, and it should most definately be supported completely moving forward.
... View more
04-30-2015
11:41 PM
|
0
|
0
|
1977
|
|
POST
|
Hi All, we also worked out why this user was missing the version number from the listUser results, it turns out this user was running arcMap 10.2.2, not 10.3 like all other users. Seems obvious now we think about it. Cheers
... View more
04-30-2015
03:56 PM
|
0
|
0
|
1077
|
|
POST
|
Thanks luke, I have not used that one before, I will give that one a go! May I ask what happens if the character ':' is not within the specified string? Works great for what I wanted. As I want everything preceding the colon, it works. If I need to return anything after (eg. user.ClientName.split(':')[1]) it errors out as soon as a string is found that does not contain a colon. Thanks for your help. Cheers!
... View more
04-27-2015
03:40 PM
|
0
|
1
|
1077
|
|
POST
|
Hi All, I have been running the below line in python, trying to build a list of PC numbers that I can use elsewhere in my script. As PC numbers/names can vary in length I have to modify the output of arcpy.listUsers() to clip the version name which is appended to the ClientName part of the output. So to clarify what I am doing: import arcpy
current_users = arcpy.ListUsers(r'Database Connections\GISADMIN@SDE_Spatial@Smithy.sde')
for user in current_users:
print user this outputs my users currently connected to the DB, this is an example output: user(ClientName=u'ACC5283-12:10.3.0.1823', ConnectionTime=datetime.datetime(2015, 4, 27, 12, 21, 48, 1), ID=66566, IsDirectConnection=True, Name=u'GISADMIN') user(ClientName=u'ACC5285-12:10.3.0.1823', ConnectionTime=datetime.datetime(2015, 4, 27, 13, 13, 17), ID=66589, IsDirectConnection=True, Name=u'"ALBURY\\KERRIERO"') user(ClientName=u'ACC5623-12:10.3.0.1823', ConnectionTime=datetime.datetime(2015, 4, 27, 13, 36, 35), ID=66594, IsDirectConnection=True, Name=u'"ALBURY\\KADENBR"') user(ClientName=u'ACC5279-12', ConnectionTime=datetime.datetime(2015, 4, 27, 14, 16, 21), ID=66599, IsDirectConnection=True, Name=u'"ALBURY\\PATREAON"') Now in order for my script to work I have to make all the ClientNames similar, so what I need is basically 'ACCXXXX-12', and cut off the rest of the clientName which I believe is the version the user is running. Normally I would simply do print user.ClientName[:-12] and this would be fine, but as the ClientName is not consistent it is breaking my code. See in my output, the user PatreaON (PC name is ACC5279-12), it for some unknown reason does not include the version number. And that is my problem, is anyone able to tell me why this users output is different to everybody elses? P.S unfortunately I cannot simply use user.ClientName[0:10] as the pc numbers range from 0-6000, meaning varying length, and ACC is for my current site, this also varies. Any ideas as to why this user is different? Cheers
... View more
04-26-2015
10:32 PM
|
0
|
4
|
4297
|
|
POST
|
Hi Gabriel, Sorry for the confusion, now I re-read my question I can see it is definitely flawed. 1. Index was the incorrect/misleading name, but I more mean a legend/table which lists all building names. So on the map it will show a building number (the example screen shot has '92' & '93'), than in the bottom right/left of the page have a little table with something like: "92. Toilet Block", new line "93. Change Rooms" 2. I think I have answered this in my point 1 above. I simply want textual information displayed, as you correctly pointed out I already have the points shown on the map itself. Cheers
... View more
04-26-2015
10:13 PM
|
0
|
1
|
1509
|
|
POST
|
I had never noticed this option, but its exactly what I was looking for. The Default Patch option was what I needed, i simply edited the width to suit and it was good as gold. Cheers thanks everyone for your time. Nathan Duncan
... View more
04-01-2015
06:42 PM
|
1
|
0
|
1298
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-17-2018 08:51 PM | |
| 1 | 09-23-2018 07:38 PM | |
| 1 | 04-08-2019 10:05 PM | |
| 1 | 02-03-2019 03:06 PM | |
| 1 | 12-20-2019 07:16 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:24 AM
|