POST
|
The third option is not ideal because it forces me to send an extra parameter to the executing script that is ignored. That also implies that if the script were called from the command line, the user would have to do the same thing (unless I also added some code that recognizes command-line vs arcmap). Also, I attempted to implement the third option briefly yesterday and was unable to get it to work. I am not sure if it is because what I want is impossible or I just was doing something wrong.
... View more
04-01-2013
05:05 AM
|
0
|
1
|
465
|
POST
|
I am trying to build a script tool using ArcGIS's 10.0 built-in python functionality. I have been trying to create a multiple value string parameter with a pre-determined set of values that each of the multiple values can take. For instance, I might give the user a value list including ['up', 'down', 'left', 'right'] and then in the tool dialog the user should be able to choose from that list multiple times, with repeats. For instance, the user might choose ['up', 'up', 'left'] as three separate inputs. I cannot seem to get this to work. I do not want what ArcGIS considers a "MultiValue" "String" with a "Value List" filter. This only allows the user to select multiple values in the value list, without repeats. Alternatively, I cannot get a satisfactory result when I create a "MultiValue" "String" with no filter. In this case, the user is completely unable to add to or remove values from the list (because, for some reason, the "Add Value" button is always disabled). How does that make any sense? A third option, which I consider a huge failure if I have to resort to it, is to create two parameters, where the first parameter is a non-multivalue dropdown list and the second parameter is a multi-value string that successively appends choices from the first parameter to its values. Is there a simple way to achieve what I am asking?
... View more
03-31-2013
12:02 PM
|
0
|
3
|
775
|
POST
|
I am attempting to buffer only the inside of a polygon to create a doughnut effect. To do so, I first use "Polygon to Line (Data Management)" to convert the polygon to a polyline. I then use "Buffer (Analysis)" with a "Side Type" set to "RIGHT". This produces an erroneous result where (I believe) the origin of the polyline has an extra crossed section of polygon (see below). As an alternative solution, I suppose I could 1) buffer the original polygon with a negative "OUTSIDE" buffer, then 2) "Erase" the smaller polygon from the original one. I mainly wanted to flag this as an error in the software. If there is somewhere else I should have posted it, such remarks are helpful. In the below image, the bold black line is the original polygon boundary turned into a polyline. The light blue polygon is the "RIGHT" buffered polyline which has the erroneous bow on one part. This occurs for both rectangular and circular polygons (I thought it might have something to do with the intersection angle). [ATTACH=CONFIG]23083[/ATTACH]
... View more
03-29-2013
07:47 AM
|
0
|
0
|
387
|
POST
|
Ah, I did not pay close enough attention when reading that the first several times. I'll give the priority field a try and see how it fairs. Thanks for the help.
... View more
11-22-2012
03:27 AM
|
0
|
0
|
1636
|
POST
|
have you tried to specify a specific cell size or are you relying on the defaults? I would specify an output cell size to optimize the conversion. There is a specific cell size I have to use. In general, cell sizes will not be small.
... View more
11-20-2012
09:47 AM
|
0
|
0
|
1636
|
POST
|
Just thought of a pretty inefficient solution, which could be generalized to non-binary outputs: convert the polygon to a polyline run Polygon to Raster on the polygon run Polyline to Raster on the polyline use Con( ~ IsNull (raster), 1, 0 ) on each raster output = [polyline_raster] | [polygon_raster]
... View more
11-20-2012
09:46 AM
|
0
|
0
|
1636
|
POST
|
I am writing a script that converts features to a binary raster based on presence/absence in a cell. In practice, when converting polylines to raster using "Polyline to Raster (conversion)", any cell through which a line passes is counted as data in the output raster. However, (and here is my problem), when converting polygons to raster using "Polygon to Raster (conversion)", only cells whose center is overlapped by the polygon are counted as data in the output. My problem is that I want the polyline to raster functionality when executing polygon to raster, i.e. I want any cell for which the polygon overlaps at all to be turned into data in the output. Is there a way to do this? To illustrate the problem: [ATTACH=CONFIG]19440[/ATTACH] Notice that the sliver that sticks down in the original polygon is missing in the polygon to raster, but is present in the polyline to raster (bottom row). What I would like is to have the output in the bottom-right, but for the values inside the raster border to have the same value as the border. Edit: I know that you can change the polygon to raster behavior to use "maximum area", but this still registers NoData if the cell area covered is <50%. My example illustrates how polygon to raster still fails.
... View more
11-20-2012
09:22 AM
|
0
|
7
|
5426
|
POST
|
Was there any resolve to this? I have not yet found a resolution, but it has been a long time and I foresee having to try this again.
... View more
10-30-2012
06:58 AM
|
0
|
0
|
509
|
POST
|
Try this:
features = [r.Shape for r in cursor]
I tried this and it works just fine. However, I am using 10.1 (but I didn't use da.searchcursor). I suspect it will work on 10.0. Also, you can use the in_memory workspace to make a temporary featureclass instead of writing out a shapefile. Mike Your solution didnt work. I am using ArcMap 10.0, which may be the problem. I will have to look into the in_memory workspace, which I didnt know existed. Thank you.
... View more
10-30-2012
06:53 AM
|
0
|
0
|
342
|
POST
|
I think I too have seen this before and it isn't so intuitive from the online samples - and I may not explain it well, but I'll give it a shot. The cursor row object is a reference, a 'pointer' if you will...so when you go to the next row, it's actually referencing the next geometry. (At least that's how I understand it.) Methods have changed for 10.1 and I'm still at 10, so I cannot test this - however, I think it's a little more straightforward at 10.1 so I think it's easier to show that 1st. I think you need the object reference like this for the list you seem to be after (this should only store a list of the geometry objects): features = [r[0] for r in arcpy.da.SearchCursor(shapefile, ("SHAPE@"))] The 10.1 documentation actually states a geometry object is returned using the '@' token. Also notice the use of the da (data access module), supposedly a performance enhancement, although I am not sure it is efficient to load the geometry as you wish into a list - better test it out. For 10.0, which I am a little more familiar with, but haven't tested this at length enough to say it'll work, I think you have to 'load' the geometry into a separate object you create, as in the script excerpt shown (this is not what I wrote, but a webhelp sample): ######################################## # Create an empty Geometry object # g = arcpy.Geometry() # Run the CopyFeatures tool, setting the output to the geometry object. GeometryList # is returned as a list of geometry objects. # geometryList = arcpy.CopyFeatures_management("c:/temp/outlines.shp", g) ######################################## I didn't know CopyFeatures could be used directly - that a cursor is not necessary to do exactly what you want (although I suppose you'll be opening a cursor to then write further output). This short script in its entirety can be found here (at the bottom of the page): Using geometry objects with geoprocessing tools Resource Center » Professional Library » Geoprocessing » Geoprocessing with Python » Accessing geographic data in Python http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Using_geometry_objects_with_geoprocessing_tools/002z0000001z000000/ That worked! I wont claim to understand why, but I greatly appreciate the help. It's great to know you can have arcpy write to in-memory variables using a predefined Geometry object. I will be using that in the near future.
... View more
10-30-2012
06:52 AM
|
0
|
0
|
342
|
POST
|
I want to load multiple features from a shapefile into a list before processing them; processing must come after. However, when I try to do this, I end up with the features all referencing the same object rather than having separate objects. Some code: # define the input file shapefile = '_myfile.shp' # import arcpy import arcpy arcpy.overwriteOutput = True # set the cursor shpName = arcpy.Describe(shapefile).shapeFieldName cursor = arcpy.SearchCursor(shapefile) # get the features BEFORE doing processing # WHERE THINGS GET FUNKY features = [r.getValue(shpName) for r in cursor] cursor = None r = None # to illustrate these are all the same, save them results = [] for i in xrange(len(features)): fName = '_myfeat%i.shp' % i results.append(arcpy.CopyFeatures_management(features, fName) Well, I just tried running my own code and got even worse results. This time, instead of the features all being the same, I had one feature that was completely out of whack, with an infinite inside-out rectangle extending to the left, and all other saved features being empty (but with the same extent?). I then ran it two more times on the same file, and ArcMap crashed when I tried to load the individual shapefiles into the program. I then ran it again on another shapefile and got similar behavior, where one feature from the shapefile was present, and all the others are empty. Any clues as to how to amend this? The major problem is that I am processing the features after loading all of them into Python. If I copy the features to their own shapefiles as soon as I load them, then the problem goes away. However, I'd like to avoid making a separate shapefile for each and every feature due to I/O time and file sizes.
... View more
10-14-2012
11:36 AM
|
0
|
4
|
585
|
POST
|
I want to plan construction of a road from a given lon,lat coordinate to existing highway infrastructure. My planning is sensitive to The total length of the road. Changes in elevation along the road. Land cover. I have an idea of how to do this, but I am pretty sure there are ArcGIS ModelBuilder models out there that could reduce the effort I have to put into doing this. I am wondering if anyone can point me to a resource that will get me started. Again, I think know which tools to use in ArcMap if I were going to do the whole thing myself, but I'd prefer a tool or model that did the job for me. Thanks Edit: I might add that I came across this walking route planning analysis, which is really close to what I want. However, I'd like to get something tailored for roads and perhaps less complex.
... View more
04-29-2011
09:01 AM
|
0
|
0
|
430
|
POST
|
I've developed a toolbox in Python and am writing a small install script for it. I want to add the toolbox to ArcMap/ArcCatalog's ArcToolbox and save it to the defaults via the script. Is there a way to do this programmatically? I want to mimic the final result of these steps using my Python install script (or do whatever works): 1. Open ArcMap/ArcCatalog 2. Right-click on ArcToolbox in the ArcToolbox list and click Add Toolbox. 3. Find the toolbox, highlight it and click Open. 4. Right-click in the empty area in the ArcToolbox list and click Save Settings > To Default Thanks in advance for help!
... View more
05-17-2010
11:15 AM
|
0
|
4
|
6109
|
Title | Kudos | Posted |
---|---|---|
3 | 07-13-2013 07:15 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|