POST
|
Thanks Jake for picking up the error - I did notice that as I re-read the post over breakfast this morning. Glad the process worked.
... View more
02-04-2014
11:16 AM
|
0
|
0
|
538
|
POST
|
Hi The 'raster to point' tool will be able to help. A couple of questions: 1/ are all the rasters in the same directory? 2/ where do you want to store the output files? 3/ how do you want to name the output files? It would be quite straightforward if all the rasters are in the same folder, and you want to store all of the point feature classes in the same location (ie in a folder if working with shapefiles, or in a geodatabase if working with feature clases) The easiest thing to do would be to write a simple loop, using a list to contain all the names of the raster files. I don't have a arcpy-enabled machine with me tonight, so the code below isn't absolutely correct or validated, however you will want to do something like this: #import libraries
import arcpy
from arcpy import env
#set environments
arcpy.env.workspace = r'[file path to where your rasters are stored]
outworkspace = r'[file path to where you want to save outputs]
#create list
rasterlist = arcpy.ListRasters("*")
#loop thru list
for raster in rasterlist:
arcpy.RasterToPoint_conversion(rasterlist, outworkspace + "//" + str(raster) + "_point", "VALUE")
#this confirms you are looking at the VALUE field of the raster, and calling the output file the same name as the raster, appended by _point.
del outworkspace, raster, rasterlist
Good luck.
... View more
02-03-2014
11:48 PM
|
0
|
0
|
538
|
IDEA
|
-->
I would LOVE it if I was able to edit gdb (aspatial) tables using the Attribute Editor option in the Editor toolbar. It doesn't happen often, but there are certain projects where I need to maintain aspatial data, and as it stands this is an awkward thing to do, as I need to edit each record / attribute individually in the attribute table view. The ability to edit using Attribute Editor would mean that I could quickly and consistently apply the same attribute to a number of records, and the transposed view would mean that I could easily visually validate the updated records.
... View more
10-24-2013
06:10 PM
|
2
|
0
|
712
|
POST
|
Hi all A theoretical question at this point, but one I may implement if I can work out a way. I have a custom MXD that is used by non-technical people in the field - basically their only input is to sketch lines on a tablet screen with a stylus. We have an enterprise licence agreement, and have configured our licence server to allow checking out / borrowing of licences for offline use for a period of time (10 days I think). I am wondering, is it possible to script a solution in Python, that would # check if it is running on a borrowed (offline) or network licence # if on a borrowed licence, check the expiry date # if there are less than days to run, return the licence and then re-borrow (basically to reset the clock). If I can get this rolling, I pretty much have a set and forget solution, as I have already scripted a solution to check for network connection and then to sync data with a gdb available on network share. Ideally I could have one script that would automatically execute on machine startup, user then just opens the project and hits the road.
... View more
10-21-2013
02:17 AM
|
0
|
1
|
361
|
POST
|
Spot on! Thank you - that has worked well. Kicking myself as I saw that in the example code but stupidly thought it was a comment, therefore didn't include it.
... View more
08-14-2013
06:01 PM
|
0
|
0
|
661
|
POST
|
Good morning all I'm trying to pull together some code to export the data view (not the page layout view) to PNG. The issue I'm having is that when I use the df variable in the ExportToPNG function, I am getting an Assertion Error. If I substitute df for "PAGE_LAYOUT" the script runs, but the output is not what I'm looking for. Any ideas how to solve this? This is what I've got so far: import arcpy import os from arcpy import env from time import localtime, strftime # Set workspace arcpy.env.workspace = r'd:\gis\aerialtracking\output' ws = arcpy.env.workspace if str(os.path.exists(ws)) == "False": os.makedirs(ws) # Set time variable and print output variable printtime = strftime("%Y%m%d_%H%M", localtime()) print printtime pngname = "mapexport_" + printtime + ".png" print pngname # Set mxd mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd) #Export PNG arcpy.mapping.ExportToPNG(mxd, pngname, df, df_export_width = 1600, df_export_height = 1200, world_file = True) #delete variables del df, ws, printtime, pngname, mxd Edit: I didn't actually get this above code to run, but I got similar code running thru the Python window in ArcMap. >>> arcpy.mapping.ExportToPNG(mxd, r'D:\gis\aerialtracking\output\test.png', "PAGE_LAYOUT") >>> arcpy.mapping.ExportToPNG(mxd, r'D:\gis\aerialtracking\output\test.png', df) Runtime error <type 'exceptions.AssertionError'>:
... View more
08-14-2013
05:19 PM
|
0
|
3
|
1488
|
POST
|
Gday Yes there is a way. I would use the 'fishnet' tool to make the grid. Can't immediately help with the coding, but I would use the following process. # determine extent of your irregular polygon # create fishnet within that extent with your 1km parameters # clip fishnet polygon to the extent of your irregular polygon # union the clipped fishnet and your irregular polygon # clean up any unwanted fields Good luck!
... View more
08-23-2012
09:37 PM
|
0
|
0
|
613
|
POST
|
Solved it myself. I think. [output_text.write(str(seltheme.getValue(repfld1)) + " - " + str(seltheme.getValue(repfld2)) + "\n")
... View more
08-21-2012
09:13 PM
|
0
|
0
|
268
|
POST
|
Firstly, apologies for grammar and spelling, I am typing one handed and nursing a baby with the other. I am looking for a way to use a variable as a field name for a search cursor, with the variable being drawn from another search cursor that runs down a dbf table. The context is that the dbf table contains a list of themes that need to be queried, and also a list of fields in those themes that need to be reported. I hope to pluck out the field names that need to be reported on and apply these to the search cursor running down the theme. Any thoughts? I am currently using arcpy.getValue but it does not seem to be working. Code snippet below: if int(theme.REPFLD_NUM) == 0: pass elif int(theme.REPFLD_NUM) == 1: repfld1 = str(theme.getValue("REPFLD_1")) output_text.write(seltheme.repfld1 + "\n") del repfld1 elif int(theme.REPFLD_NUM) == 2: repfld1 = str(theme.getValue("REPFLD_1")) repfld2 = str(theme.getValue("REPFLD_2")) output_text.write(seltheme.repfld1 + " - " + seltheme.repfld2 + "\n") del repfld1, repfld2 and so on. Would appreciate any suggestions.
... View more
08-21-2012
08:56 PM
|
0
|
1
|
865
|
POST
|
Good afternoon all Having some issues with the Select By Location function returning an odd error message that I can't shake out. I'm pretty confident it's falling over on the first half of the if..else command. This is in there to differentiate between features which need to be checked with a buffer distance and those that don't (this bit of code will be iterated through all the features in a dataset individually). Code (or snippets of): sqlquery = OIDFieldName + "=" + str(oid)
dataset_tocheck_lyr = arcpy.MakeFeatureLayer_management(dataset_tocheck, "dataset_tocheck_lyr", "\"sqlquery\"")
themelocation_lyr = arcpy.MakeFeatureLayer_management(themelocation, "themelocation_lyr") #create temp layer of theme location
bufferdist = str(int(overlayfeature.DIST)) + " Meters"
.
.
.
if int(overlayfeature.DIST) == 0:
arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
output_text.write("Buffer is zero, not factoring into SBL\n\n")
else:
arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "\"bufferdist\"", "NEW_SELECTION")
output_text.write("Buffer is not zero, factoring additional string into SBL\n\n") Error: Traceback (most recent call last):
File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "U:\PythonValuesChecking\Python Scripts\ValuesChecker.py", line 74, in <module>
arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4381, in SelectLayerByLocation
raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
Failed to execute (SelectLayerByLocation).
This has thrown a few other problems at me, which I have so far been able to solve, but this one has got me stuffed. Any thoughts?
... View more
08-18-2012
09:07 PM
|
0
|
1
|
1275
|
POST
|
OK I think I've solved it. The special characters got me thinking, and while I can't get my head around them completely as yet, I can see why they are used. I also prefer to use a solution that I can comprehend and then use this as a building block for more learning. I ended up creating a variable called sqlquery outside of the function, by concatenating together the OIDFieldName and the oid, and I then pass this variable through the function: while oid < num_feats: #create WHILE loop for OID in [0, num_feats]
sqlquery = OIDFieldName + "=" + str(oid) #form sqlquery outside of the function and then pass thru using special character \
print sqlquery # temp code to check how sqlquery variable appears and to check progression of the loop
arcpy.MakeFeatureLayer_management(dataset_tocheck, "dataset_tocheck_lyr", "\"sqlquery\"")
oid = oid + 1 I haven't assembled the rest of the function yet, but I have inserted the print sqlquery line into the loop to see that it iterates through correctly. Cross fingers, this might work. Thanks everyone for their responses.
... View more
08-16-2012
09:16 PM
|
0
|
0
|
2964
|
POST
|
Thanks folks, there looks to be some excellent answers here. Once I get a chance to get my head back in the code later today I'll try these options. The reason I am using this method is that I need to pull out each feature individually, and run a spatial selection against it, and a bunch of other datasets, and report back in a unique text file for each feature. The list of the other datasets is maintained in a dbf table, and I'll use a search cursor to flick through those. I may be back for more help yet!
... View more
08-16-2012
01:48 PM
|
0
|
0
|
2964
|
POST
|
Hello Caution... Python rookie here. I am sure this will be a very easy answer, but for the life of me I can't figure it out. I am trying to write an iterator that will cycle through the features within a feature class, checking each of them against a values layer. I have almost worked out how to run the iteration by identifying the OID field and the number of features, and then run a while: loop, but I have struck a problem in creating the temporary layer that will house the single feature for checking. Code below: # new code using OID and while loop:
num_feats = int(str((arcpy.GetCount_management(dataset_tocheck)))) #returns number of features in dataset to check. Initial result is type RETURN, covert to STRING and then to INTEGER.
descFC = arcpy.Describe(dataset_tocheck) #set descFC variable for dataset to check
OIDFieldName = str(descFC.OIDFieldName) #find OID fieldname of dataset to check, convert to STRING
oid = 0 #create OID variable for WHILE loop
arcpy.MakeFeatureLayer_management(dataset_tocheck,"dataset_tocheck_lyr") #make feature layer from feature class
while oid < num_feats: #create WHILE loop for OID in [0, num_feats]
dataset_tocheck_subset = arcpy.SelectLayerByAttribute_management("dataset_tocheck_lyr", "NEW_SELECTION", OIDFieldName = oid)
oid = oid + 1 The issue I am striking is using the variables OIDFieldName and oid in the SelectLayerByAttribute function. I am trying to use variables as I want to make this code as portable as possible and once it is running, assemble into a tool for corporate deployment. Error being returned: Traceback (most recent call last):
File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "U:\PythonValuesChecking\Python Scripts\ValuesChecker.py", line 70, in <module>
dataset_tocheck_subset = arcpy.SelectLayerByAttribute_management("dataset_tocheck_lyr", "NEW_SELECTION", OIDFieldName = oid)
TypeError: SelectLayerByAttribute() got an unexpected keyword argument 'OIDFieldName'
Am I able to use variables in this manner? What am I doing wrong?
... View more
08-16-2012
03:28 AM
|
0
|
5
|
9770
|
POST
|
Good morning I am currently working on generating a very large map (5 metres wide x 2.5 tall) to be displayed on a wall. Due to system limitations, I have generated the map as a number of tiles, with the intention of stitching these tiles together using Adobe Illustrator or similar prior to outsourcing the printing (a technique that has worked for me in the past). To speed up this process, I was wondering if it was possible to access / use the embedded georeferencing within the pdf tiles in Illustrator to help allign and stitch the tiles? I am not at all familiar with Illustrator (have outsourced this component of the job) but am wondering if anyone is aware of a potential solution. Cheers Anthony
... View more
02-05-2012
02:23 PM
|
0
|
1
|
1090
|
POST
|
Slick solution (I like the idea of it) - how does it deal with grids and coordinates? Are they drawn on top of the data frame? I have also encountered this problem in a new version 10 database. Here is a very goofy solution: In Layout view, create a graphic rectangle that goes out the edge of the page. (can use guides for this) Create another rectangle the same size as the Data Frame, align to the data frame Select rectangle 2, then rectangle 1, and choose Drawing --> Graphic Opperations --> Subtract. You will now have a square doughnut graphic that frames your Data Frame. Send the new graphic to the back Send the Data Frame to the back Set the graphic to have the same border you want your Data Frame to have. Now when you export, the square doughnut graphic will mask anything that hangs out of the Data Frame.
... View more
01-12-2012
08:26 PM
|
0
|
0
|
729
|
Title | Kudos | Posted |
---|---|---|
1 | 10-30-2019 10:07 PM | |
1 | 12-01-2020 09:24 PM | |
1 | 01-09-2018 07:17 PM | |
1 | 06-08-2016 02:49 PM | |
1 | 07-03-2016 11:54 PM |
Online Status |
Offline
|
Date Last Visited |
12-01-2020
10:55 PM
|