|
POST
|
Swept area 1. Convert large polygon to vertices (Data Management>Features>Vertices To Points) 2. Add an ID field and populate with OBJECTID (AddField, CalculateField) 3. Copy and Paste whole set in editor 4. With pasted still selected move to new final position using Editor>Move... 5. Exit edit 6. Convert outside point pairs to lines (Points To Line) using ID as line field 7. Select the two outer lines, delete the rest, add two lines to create a box 8. Convert 4 closed lines to a polygon (Feature To Polygon) 9. Go back to large polygon, copy and paste and move the same move 10. Union the three polygons 11. Dissolve Now if you have 3000 steps that trace a path instead of the straight lines, substitute a path instead of the straight line after step 7.
... View more
10-07-2011
03:58 AM
|
0
|
0
|
6865
|
|
POST
|
Save a layer with the default symbolgy to disk. Use the Python arcpy.mapping tools to edit the Map Document, load the layer x times and then change the source to each separate grid.
... View more
10-07-2011
02:13 AM
|
0
|
0
|
1783
|
|
POST
|
Think of a process to solve the task acting on the whole featureclass at once. ArcGIS is a geo-relational system, like a relational database. When you create an SQL query you don't consider each row of the table, you just specify what you want. The same applies to all the geoprocessing tools. Let ArcGIS sort out the details. So I did not have in mind clipping out the single feature into 350 featureclasses. Only to split an excessively large polygon into many polygons in the same featureclass. This allows indexing and other efficiencies when processing. That is what DICE does. We would ignore the dicing and just consider the original boundary. I regularly work with millions of features and see no issue with that. I cannot see any difficulty in designing a process to solve the problem in a few minutes. Perhaps you want to animate it? How are you defining the 3000 steps? Does it depend on the shape of the polygon boundary? Are the bearing and distance for each step in a table? Maybe you don't really mean stretched at all? Perhaps "swept area" might be a better term? Why do you need 3000 steps if the movement is linear? If it is a linear swept area, all you have to do is convert the vertices to points, copy a set to the final position, join the from-dots to the to-dots at the sides and build a new polygon. The swept area will have the shape of the front and back preserved with straight sides. There are simple tools to do all these steps in a series of single steps. Bounding boxes find the max and min vertices, creating lines from points is another and creating polygons from lines another. If you can't manage a Python script, maybe the modelbuilder would suit, or just manually run the tools.
... View more
10-07-2011
02:02 AM
|
0
|
0
|
6865
|
|
POST
|
You haven't tried it! Adjust doesn't work that way. It works on the whole featureclass, no matter how many polygons or vertices. Coincident vertices will be adjusted by the same amount so the edges will still be coincident. Adjust defines two error surfaces (TINs) from the vectors and applies a correction to every one of the millions of vertices in the featureclass. Ah, so the polygons only have 80 vertices each, that sounds better. If I was considering the flow of a glacier I would be using my open channel flow training to model the ice as if it flowed like water, where the valley is wider, or deeper, the ice would move slower. I could therefore create a velocity field that would be used as a basis to generate the link vectors.
... View more
10-07-2011
01:44 AM
|
0
|
0
|
6865
|
|
POST
|
Things have changed a lot at 10.x for Spatial Analyst. Before you look for fancy alternatives, just refactor it for the new Python Grid Algebra. The key improvement that stands out here is that the grid is held in memory, so you could iterate over the same grid without reloading it each time, and the output is also held in memory until you want to save it. But if that is still to slow, could numpy be programmed to run the same processes? Cup of Coffee Rule If any process takes longer than a cup of coffee, interrupt it and fix it or find a better way. I would never accept a model that takes 40 hours. What if you have to re-run it?
... View more
10-06-2011
07:30 PM
|
0
|
0
|
1760
|
|
POST
|
The key to understanding "donuts" is that there is a [null point] separating the nested rings list of points in each part. Not between parts. There are some conference technical workshop presentations that set this out very well. A polygon array in a python pseudocode list would look like this: (of course it has to be in an Arcpy array in internal binary, you cannot just pour this into the array, maybe you can with AsShape, but assembling the list as a JSON string is just as hard). Your example list does not distinguish between parts and donuts. [[pt,pt,pt,,pt,pt,pt],[pt,pt,pt,pt]] This is a polygon containing two separate parts, with the first part containing a hole. You don't have to reverse the directions, ArcGIS does that for you automatically to generate a valid shape. You can have islands inside donuts and so on. Lakes can be like this, an island in the lake that has a small lake in the island. When you assemble the part array of points and you get to the donut, just add a null point and carry on. I think of it as a 'pen down - pen up' operation that we used to program for pen plotters. It appears that your error is to add a null point at the end of a part, rather than making the hole within the same part. Likewise adding a null point between parts would not make a donut, just a null part which would be erases by the validator. Earlier when you reversed the coordinates, it seems that ArcObjects detected that and added in a null for you to make a donut, but I wouldn't rely on that.
# donut example
# with explicit null pair to flag a donut
# this example only has one feature and one part in the feature
# coordinate pairs are shown as tuples for clarity
# Kim Ollivier
coordList = [[
[(-88.684979400000032, 38.154361399999985), (-88.666690199999962, 38.154329800000042),
(-88.67131005539963, 38.154337782166039), (-88.675899944207302, 38.154345712555887),
(-88.675899944207302, 38.150691003182175), (-88.67131005539963, 38.150691003182175),
(-88.67131005539963, 38.147037172952786), (-88.675899944207302, 38.147037172952786),
(-88.685066075460313, 38.147037172952786), (-88.684979400000032, 38.154361399999985),
(),
(-88.680463013034853, 38.152519617763254), (-88.680463013034853, 38.15068957953018),
(-88.678182297717754, 38.15068957953018), (-88.678182297717754, 38.152519617763254),
(-88.680463013034853, 38.152519617763254)]
]]
def main():
array = arcpy.Array()
point = arcpy.Point()
null_point = arcpy.Point()
# Create a list to store the features
features = []
# Read the coordinates
for feature in coordList:
print "feature", feature
for part in feature:
for coordPair in part:
print coordPair
if len(coordPair) == 0:
array.add(null_point)
else:
point.X = coordPair[0]
point.Y = coordPair[1]
array.add(point)
# Create the polygon object
polygon = arcpy.Polygon(array)
# Clear the array for the next feature
array.removeAll()
# Append to the feature list
features.append(polygon)
# Copy the features to an output feature class
arcpy.CopyFeatures_management(features, outputFeatureClass)
if __name__ == '__main__':
import arcpy
arcpy.env.overwriteOutput = True
outputShapeDir = "c:/temp"
outputShapeFile = "test.shp"
if not arcpy.Exists(outputShapeDir+"/"+outputShapeFile):
spatialRef = arcpy.SpatialReference(4326) # or "GCS_WGS_1984"
outputFeatureClass = arcpy.CreateFeatureclass_management( outputShapeDir, outputShapeFile, "POLYGON", "", "", "", spatialRef )
else:
outputFeatureClass = outputShapeDir+"/"+outputShapeFile
main()
To go back the other way, see my resource example tool "Fill Donut" on the resources page. http://resources.arcgis.com/gallery/file/Geoprocessing-Model-and-Script-Tool-Gallery/details?entryID=C4E10FE5-1422-2418-A06D-33952BB8D1D7 I know that Esri has added a tool to do this and you can manually edit donuts, but this is a script to show how to program them.
... View more
10-06-2011
05:56 PM
|
0
|
0
|
1350
|
|
POST
|
An interesting task made harder by having too many vertices in a polygon. 100m vertices, are you serious?? The first thing I would do is DICE the glacier up for performance and sanity. Have you considered using rubber sheeting? Now called Spatial Adjustment. 0 Just add a few links to show how much distortion you require and run Adjust. You would add long links at the tongue and short links at the top. Put some identity links at the far end to anchor it. Save your links to enable you to repeat and illustrate. If you need more points than can be added by hand: 1. Make up some from - to points with paired IDs. This may come from a grid of points that you systematically move with some sort of equation. 2 Convert this to a tab separated text file to load into the Adjust tool 3 Run the adjust. You could turn the from to pairs into a set of vectors to check the distortion is as required. The limit in ArcIINFO Workstation was 50,000 links. It may be a lot less in ArcMap, but you don't need a vector for every vertex. Adjust automatically builds two TIN of the distortion in x and y and applies it to each glacier vertex.
... View more
10-06-2011
05:25 PM
|
0
|
0
|
6865
|
|
POST
|
My most thumbed book is now rare, but still available on Amazon. Visual Quickstart Guide Python by Chris Fehily, Peachpit Press first edition. The second edition is a different book by a different author and layout and is useless. This book has exactly the right level of Python and lots of small examples to illustrate. http://www.amazon.com/Python-Chris-Fehily/dp/0201748843/ref=sr_1_1?s=books&ie=UTF8&qid=1317896965&sr=1-1 Although it is for version 2.1 all of it is still relevant for geoprocessing scripting.
... View more
10-06-2011
02:31 AM
|
0
|
0
|
1340
|
|
POST
|
You can do this by defining new fields with the fieldinfo parameter when you create a layer and then save back to a featureclass. see MakeFeatureLayer_management(fc,"layer","whereclause","workspace",fieldinfo) The help is useless here. I suggest you run the tool and then right-click the result to get a Python snippet to see the syntax, the replicate for each field change you require in a script. You need to set up a ; delimited string containing four space separated values. (Who thought that was a good idea? What about a nested Python list??) eg "From_name To_name Hidden_Flag Ratio;From_name To_name Hidden_Flag Ratio;...."
... View more
10-06-2011
02:24 AM
|
0
|
0
|
614
|
|
POST
|
At 10.1 there is a arcpy.mapping.ListBookmarks() function that provides a list of names and extents.
... View more
10-05-2011
11:32 PM
|
0
|
0
|
3229
|
|
POST
|
If you use a cursor to read in the data you can convert the values into a Python datetime object. That is much easier to round off and then write it out to a date field again. Note that you have to have a featureclass that handles datetime objects which does not include dBase and hence shapefiles. Note that rounding down is easy, just truncate the minutes and milliseconds. Rounding up is a bit trickier because the next minute may be a whole hour, that is where the datetime object makes it easy, we create a timedelta object of one minute that will do the tricky date arithmetic for us. In this case you want a floor function so no rounding is required. Python: batteries included. import datetime,math
exact = datetime.datetime.now()
newsecs = math.floor(exact.second/30.0)*30.0
newtime = exact.replace(second=newsecs,microsecond=0)
print exact,newtime 2011-08-17 21:37:46.296000 2011-08-17 21:37:30
2011-08-17 21:37:56.562000 2011-08-17 21:37:30
2011-08-17 21:38:02.171000 2011-08-17 21:38:00
2011-08-17 21:39:35.484000 2011-08-17 21:39:30
It would be possible to create a function that could be used in the field calculator. I don't recommend that. It is much easier to debug and add extra tests to use a cursor. What if the field is Null? In a cursor you can add more tests to trap unexpected data.
... View more
08-17-2011
01:25 AM
|
0
|
0
|
495
|
|
POST
|
It is likely to be network and SDE delays. Copy the editing dataset to a local file geodatabase, edit it and then replace it in SDE at the end. The extra steps will be still worth it. Another technique is to tag all the features to be moved in an attribute and reselect/merge them at the end.
... View more
08-17-2011
01:00 AM
|
0
|
0
|
656
|
|
POST
|
We all would if we could, but the AddIn Python Wizard is not downloadable. Could you get this fixed? http://forums.arcgis.com/threads/36026-Python-AddIn-Wizard-download-refused It would still be useful to be able to create a (blank) python script as part of the tool wizard. Just think of all the script kiddies trying to write their first tool and script in the "Geoprocessing With Python" class.
... View more
08-16-2011
01:45 AM
|
0
|
0
|
2043
|
|
POST
|
I tend to create a new tool in a 'top-down' process: Create a new toolbox Add a new tool Add in the parameters Edit the documentation for the general purpose Open the script to start writing At Win 7 this has got even harder if you do not have Administrator access to streamline Windoze. "Adding" a script is not appropriate because I have yet to create the script. It would be useful to be able to create an empty file with a py suffix right there. In the absence of a create, you can open the folder with the common dialog and create a text file on the fly and change the name and extension. Then select your new file. But this is impossible unless file extension types have been made visible in Windows control panel. This could also be eased if a file type of Python script was added to the registry so you could create a python script file as an option. The only other way is to open PythonWin separately and save a script before you start a new tool. That is not very integrated and is confusing when teaching students. It should be possible to work entirely inside ArcMap to manage the whole toolbox/scripting process.
... View more
08-13-2011
05:24 PM
|
0
|
11
|
2818
|
|
POST
|
It's like the old Irish joke about getting directions when lost - "If I was trying to get to your destination I wouldn't start from here"! It would help to see a diagram of your final requirements. Geoprocessing tools work best on the whole dataset at once, not in the interative solution that you are imagining. My first thought is that a set of stepped circles along a road is a Buffer. So why not a buffer of distance equal to the radius. Then the circles will fit inside the buffer. So how do you get the centres? Centres along the roads can be easily created using a linear referencing system and using an event table with distances equal to twice the radius. I can see this might clash at intersections, so some sort of sphere-packing might be required there. Maybe linear referencing can be used there to only pass through the intersection once to resolve that, with side roads stopping at a suitable distance that does not intersect the main road buffer. All of these processes would run once for the whole dataset, maybe there would be several steps (say less than 10) to handle exceptions to weed out strange cases, but not millions of iterations.
... View more
08-12-2011
11:09 PM
|
0
|
0
|
1045
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 3 weeks ago | |
| 2 | 06-12-2026 03:28 PM | |
| 1 | 03-11-2023 03:54 PM | |
| 1 | 09-15-2024 10:32 PM | |
| 1 | 03-12-2026 01:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|