|
POST
|
I wanted to gp.Delete("table_rel") but the Delete() function or Exists() function does not even see them. I see a note that suggests that I set OverwriteOutput = True when writing them, but that doesn't clean them out of a file geoadatabase. The only option looks like a GeeWiz Basic style "poke" using ArcObjects, remember those? Can someone give me that syntax?
... View more
07-29-2010
03:19 PM
|
0
|
0
|
2587
|
|
POST
|
Which gave me the idea to try a cursor on a featureset, and that worked too! # latlong.py
# get a point from NZTM and convert to lat/long
#
import arcgisscripting
gp = arcgisscripting.create(9.3)
inFeatSet = gp.GetParameter(0)
row = gp.SearchCursor(inFeatSet,"","c:/arcgis/nzgd2000.prj").next()
lat = row.shape.centroid.Y
long = row.shape.centroid.X
gp.AddMessage(str(lat)+" "+str(long))
del row
... View more
07-28-2010
03:02 AM
|
0
|
0
|
355
|
|
POST
|
Well I suppose an in_memory featureclass is OK latlong.py
# get a point from NZTM and convert to lat/long
#
import arcgisscripting
gp = arcgisscripting.create(9.3)
inFeatSet = gp.GetParameter(0)
gp.OverwriteOutput = True
inFeatSet.Save("in_memory/pointer")
row = gp.SearchCursor("in_memory/pointer","","c:/arcgis/nzgd2000.prj").next()
lat = row.shape.centroid.Y
long = row.shape.centroid.X
gp.AddMessage(str(lat)+" "+str(long))
del row
... View more
07-28-2010
02:54 AM
|
0
|
0
|
355
|
|
POST
|
If you use the tool form setting to collect an interactive point as a featureset you get the coordinates in the current projection. I want to turn that into a WGS84 lat/long to query a web service that requires that format. The only way I can see to do this is by setting an output projection and using a cursor to write a table, then open it up again to see what happened. But the whole point of featuresets is to avoid exactly that sort of inefficiency. There (was), IS an AML function to project a point returned by &Getpoint &Map. Here is the Workstation help snippet [SHOW CONVERT <in_units> <xy> <out_units>] Returns the converted x,y coordinates from units in one specified coordinate space to units in another specified coordinate space. UNITS can be PAGE, MAP, PROJECTEDMAP, or GRAPH. The respective MAPEXTENT, MAPPROJECTION and GRAPHEXTENT must be set first.
... View more
07-28-2010
02:17 AM
|
0
|
2
|
498
|
|
POST
|
Meanwhile, someone could help us here. The ESRI help has example scripts in C# and Vb.NET that could be converted to Python using the comtypes module as demonstrated by Mark Cederholm. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000002w1000000 This could be made into a simple script or module that would do the zooming for us until 10.1 arrives. An excellent little example of extending ArcPy using ArcObjects.
... View more
07-25-2010
02:49 AM
|
0
|
0
|
1961
|
|
POST
|
I ended up using the tool in catalog to set it all up. I just went back and did a find-replace to change the file paths. Much quicker than typing all of it. I have a spatial join in one script that is 20685 characters long, most all of it is field mapping. I wrote papers shorter than that in college. That is how I create field maps too, but you can set the workspace to shorten the paths to fit the fieldmap string into one line.
... View more
07-13-2010
01:44 AM
|
0
|
0
|
1327
|
|
POST
|
An interesting problem that is glossed over in the help. I solved this by creating a table with a date field, populating it and then reading them with a SearchCursor. When Python reads/writes a date field using a cursor it expects a date object using the datetime module. So I found that you have to create and manipulate dates as datetime objects. The datetime module is actually very convenient and cursors work for everything except NULL values.
# datetest
import arcpy,datetime
ws = "c:/home/python/datetest.gdb"
arcpy.env.workspace = ws
rows = arcpy.UpdateCursor("fcdate")
for row in rows :
print row.timestamp,type(row.timestamp)
if row.timestamp == None:
row.timestamp = datetime.datetime.now()
else :
row.timestamp = row.timestamp + datetime.timedelta(hours=10,minutes=30,seconds=15)
rows.updateRow(row)
del row,rows Here is an example featureclass with an existing date field. It had a few dates and a null record. Note that you can read the dates and print them because a date object has a default 'representation'. It is not a string, you can just print the object as a string without casting. Note how you increment a date, using a timedelta object. You also have to trap null dates. I have used a file geodatabase (not a shapefile) because I expected it to handle a full datetime not just a date as in dBase or INFO. More help in the pythonwin help for python for the datetime module.
... View more
07-13-2010
01:35 AM
|
0
|
0
|
1043
|
|
POST
|
Regrettably there are some differences in running scripts in IDLE, Pythonwin, ArcCatalog and ArcMap that cause some things to just not run. I just open up my scripts in Pythonwin and run them from there, since that is where they were debugged. It may be worth changing to 9.3 format if you have later versions. It may be related to the gp processor not releasing locks, especially the AddField tool. There used to be a gp.RefreshCatalog(database) command that might help, this has mysteriously disappeared in documentation in later version because its 'not needed', but you might try that before you open the ODBC cursor. There are bugs in Python modules too, so upgrading to the latest version of ArcGIS forces an upgrade of Python as well.
... View more
06-25-2010
03:16 AM
|
0
|
0
|
3758
|
|
POST
|
Thanks Kimo. So, I can assume that all outer rings will be clockwise? I don't care how they are built, by connecting points or converting a dxf, ArcGIS will always have outer rings in a clockwise fashion? Thanks Here is the shapefile specification http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf This explains the rules for shapes, and even more stringent rules apply to OGC polygons. http://en.wikipedia.org/wiki/Simple_Features
... View more
06-24-2010
02:12 AM
|
0
|
0
|
1095
|
|
POST
|
You can see the counts of each featureclass in ArcCatalog without any Python scripting. Add features count as a column in the options for display and then touch each featureclass to update the metadata. then when you select the geodatabase or folder the counts will display in the listing.
... View more
06-19-2010
04:12 AM
|
0
|
0
|
3196
|
|
POST
|
I understood that a polygon must be defined in a Counter-clockwise direction to be valid. (I got this reversed in my original answer) A clockwise ring will define a hole in a polygon. But it must be enclosed by the first ring. So the outside ring must start counter-clockwise with alternate clock/counter-wise nested rings if you had the (real) case of say a lake on an island in a lake. The check/repair geometry tool will soon take note if you actually manage to build an invalid topology at a low level. Somet loaders check on loading and reject invalid topology. But if you copy a featureclass using featureclassTofeatureclass you will copy the invalid geometry, storing up problems for any later analysis and drawing. OGC well known text does not define the direction except to note that the righthand rule will imply the polygon 'faces up". If you hod up your right hand with thumb, first and second fingers stretched, first finger along the line, then the second finger points to the inside and the thumb points up. KML definitely gets it 'wrong' from an Esri point of view, so always repair geometry when loading KML polygons or they won't draw properly and you will have trouble editing them. I am having trouble with loading data via spatialite too. The WKT loader seems to bypass any geometry validation and even just gets it wrong.
... View more
06-19-2010
03:54 AM
|
0
|
0
|
1094
|
|
POST
|
Create an array object to receive the geometry from the row. Then you can use that temporary feature as a mask polygon.
... View more
06-19-2010
03:48 AM
|
0
|
0
|
1209
|
|
POST
|
import sys, os, string, csv, re, arcgisscripting
gp = arcgisscripting.create()
gp.OverWriteOutput = True
# Set local variables
out_path = "d:/work"
out_name = "points.shp"
geometry_type = "POINT"
template = "DISABLED"
has_m = "DISABLED"
has_z = "DISABLED"
# Set workspace after variables
gp.workspace = out_path
#Creating a spatial reference object
spatial_reference = gp.CreateSpatialReference('Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj')
# use relative path for this path is an undocumented trick
#Execute CreateFeatureclass
if gp.Exists(out_name) : gp.Delete(out_name)
gp.CreateFeatureclass_management(out_path, out_name, geometry_type, '#', has_m, has_z, spatial_reference)
gp.AddField_management(out_name, "maxSize", "DOUBLE", 11, 4)
f = open("D:/work/x30minpts.txt")
# never start file or folder names with a digit, even if Windows allows it
cur = gp.InsertCursor(out_name) # open outside loop once only
pnt = gp.CreateObject('POINT') # only need one instance outside loop
csvReader = csv.reader(f) # defaults ok for example
for row in csvReader:
xCoord = row[0] # reads as strings, not numbers
yCoord = row[1]
size = row[2]
# print(xCoord,yCoord,size),type(xCoord),type(yCoord),type(size)
row = cur.NewRow()
pnt.x = float(xCoord)
pnt.y = float(yCoord)
row.maxSize = float(size) # attributes are property of the row, not the pmt
row.shape = pnt
cur.InsertRow(row)
del cur,row,pnt
f.close()
... View more
06-18-2010
02:35 PM
|
0
|
0
|
591
|
|
POST
|
You can't delete rows with a SearchCursor, it is read-only. Try an UpdateCursor You might still encounter problems, Image catalogs seem to be special tables.
... View more
06-13-2010
03:51 AM
|
0
|
0
|
372
|
|
POST
|
The proper answer is YES, at 10.0 there is a new set of tools called "Data Driven Pages" that have the equivalent utilities that were available in DS MapBook menu: I mis-understood that you wanted a text based index. Someone will have to write that in Python as a new resource. Can't be too hard with data driven pages. Might give it a go myself when I have time. I remember an AML tool that did this.
... View more
06-10-2010
03:06 AM
|
0
|
0
|
1940
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-26-2025 03:48 PM | |
| 1 | 05-08-2025 02:07 PM | |
| 1 | 05-07-2025 05:13 PM | |
| 3 | 04-04-2025 03:16 PM | |
| 2 | 05-07-2025 05:21 PM |
| Online Status |
Offline
|
| Date Last Visited |
10-20-2025
06:39 PM
|