POST
|
I have created a new table by joining two tables. Now I want to loop through this new table with a searchCursor and find records with a specific attribute, e.g. "number" = 10. But I get an error because no field with the name "number" is found. Since I have joined two tables, the name of the field is "tableA_tableB_number" (just the aliasName is still "number"). To be able to loop through this table I added a new field "number" and copied the values of the field "tableA_tableB_number" to this field. But this is quite tedious and sometimes I join tables that have already been joined and then it gets complicated... So I tried it with field_mapping and wanted to change the name of the field to the aliasName, but it didn't work. Here's my code (I took the field_mapping part from the tread http://forums.arcgis.com/threads/33060-field-mapping-in-python-for-ArcGIS-10?highlight=rename+field) def GetFieldMappings(fc_in, dico):
field_mappings = arcpy.FieldMappings()
field_mappings.addTable(fc_in)
for input, output in dico.iteritems():
field_map = arcpy.FieldMap()
field_map.addInputField(fc_in, input)
field = field_map.outputField
field.name = output
field_map.outputField = field
field_index=field_map.findInputFieldIndex(fc_in, input)
field_map.removeInputField(field_index)
field_mappings.addFieldMap(field_map)
del field, field_map
return field_mappings
def main():
pass
if __name__ == '__main__':
main()
IN_TABLE = "xy"
FieldDict = {}
FieldDict[field.name]=field.aliasName
Mapper = GetFieldMappings(IN_TABLE, FieldDict)
arcpy.TableToTable_conversion(IN_TABLE, "ab.gdb", "test", "",Mapper)
fieldList = arcpy.ListFields( "H:\\Moorinventar\\FM_OBJEKTBLAETTER\\Data\\FM_OBJEKTBLAETTER.gdb\\test4")
for field in fieldList:
print field.name
print field.aliasName The names of the fields in the new table are still the old names, not the old aliasNames. At the end of the day I just want to be able to loop through the table and find certain records. How could I do this? Thanks in advance Vera
... View more
05-21-2012
04:28 AM
|
0
|
0
|
885
|
POST
|
In our company we have a "geoportal" that consists more or less of a list with links to where the datafiles are on our server and some complementary information about the data. The data is described in detail in pdf-files and there's no possibility to search. Now we're thinking about updating to the Geoportal-Extension, particularly as we want to offer the user the possibility to search for data. As we don't have a lot of resources to set up the geoportal and later to maintain it, we don't want to write a lot of metadata (and later to keep it up to date), but go on using those pdf-Files as the main source of information about the data and write as little metadata as possible. I spent quite some time reading in the Geoportal-Help and elsewhere in the web and here's what I figured out: I think we can't avoid writing some metadate for our data in a standardized way, so that we can load it in the geoportal. As a part of the metadata, there would be a link to the pdf-file with the description and if the user searches for something, the pdf file would be searched as well. BUT is the search enging of the geoportal able to search in pdf-files? If not, is it possible, to install a second search engine just for the pdf's? (obviously they do exist >> http://www.searchtools.com/info/pdf.html) Would this be possible to realize? Or how else could I include those pdf-files in the geoportal? Thanks in advance!
... View more
01-26-2012
04:56 AM
|
0
|
1
|
1319
|
POST
|
I think my problem had something to do with the memory, as you suggested, Jeff. I got my script running through all the numbers by creating a batch-file and running the script for about 150 numbers at a time. thanks for your help Vera
... View more
01-24-2012
09:51 PM
|
0
|
0
|
299
|
POST
|
Could there be an unsupported or null character in the field: str(AKT_FM.Nummer)? No, because once the error occurred for one number, it continues to occur for all the following numbers as well (if an error occurs in one of the modules, the main loop doesn't stop but continues with the next number.) But could it be, that's it has something to do with the way I'm running the script? I'm using PyScripter and started the script by pressing the "run" button.
... View more
01-12-2012
03:34 AM
|
0
|
0
|
299
|
POST
|
I've written an application that generates double-sided pdf-Documents. In the main module it loops through up to 1700 numbers and for each of them it generates in an own module the backside-pdf and the frontside-pdf. Back in the main it creates a new empty pdf and appends the frontside and the backside. This works fine for the first about 700 or so numbers. But then the following error appears as it tries to create the first of the pdfs for this numer: [PHP]PYTHON ERRORS: Traceback info: File "H:\Moorinventar\FM_OBJEKTBLAETTER\Scripts\Rueckseite.py", line 669, in main arcpy.mapping.ExportToPDF(mxd, pdf_doc,"PAGE_LAYOUT") Error Info: PageLayoutObject: Error in executing ExportToPDF[/PHP] (That's how I create my pfd-path: pdf_doc = os.path.join(pfad_pdf,"Seite_2_" + str(AKT_FM.Nummer) + ".pdf") ) When I restart the script, beginning at number 700, then it works fine, until the same error appears again after the next about 700 numbers. I guess the problem is not really the ExportToPDF, but rather something with the file system / folder... (all pdfs are written in the same folder. The back- and frontside-pdf are deleted, once the doublesided-pdf is created). Any ideas what could be the problem? Thanks in advance! Vera
... View more
01-11-2012
09:56 PM
|
0
|
4
|
939
|
POST
|
It's working! My script is quite long by now and setting the extent of this dataframe on my layout is just one small part. I tried exporting the map to a pdf right after I set the extent and it was drawn correctly. My problem was, that later in the script I set the size of the dataframe explicitly in a loop through all my layout-elements. For some reason, whenever two features are selected the size of the dataframe is set to a size that doesn't fit on the layout anymore and consequently nothing is drawn. Now I don't set the size anymore, and it works ok. Thanks, Vera
... View more
12-07-2011
11:11 PM
|
0
|
0
|
167
|
POST
|
In my script I select a feature (layer with definition query) and set the extent of the dataframe to the extent of this feature. This works fine, as long as just one feature is selected. Sometimes though, two features need to be selected. In this case, I do get the extent of the features and I can set the extent of the dataframe, but nothing gets drawn. Here's my code:
Layer_xy.definitionQuery = DefinitionQuery
newExtent = Layer_xy.getExtent(True)
# newExtent = Layer_xy.getSelectedExtent(True)
df.extent = newExtent
df.panToExtent(df.extent)
print "Extent of feature:\nXMin: %f, YMin: %f, \nXMax: %f, YMax: %f" % \
(df.extent.XMin,df.extent.YMin,df.extent.XMax,df.extent.YMax)
I tried it both with Layer_xy.getExtent and Layer_xy.getSelectedExtent and with or without panToExtent, with Layer_xy.getSelectedExtent(True) or (False), but nothing was ever drawn... Any suggestions? Thanks for your help. Vera
... View more
12-07-2011
06:44 AM
|
0
|
2
|
490
|
POST
|
I found out how I can do it: Properties-Dialogue of the textelement in the layout-window: > Change Symbol > Edit Symbol > Units: mm Vera
... View more
11-16-2011
05:20 AM
|
0
|
0
|
294
|
POST
|
Is there a way to set the font size of a textelement in a layout directly in mm? I tried it like that: str = "<FNT name=\"Arial\" size=\"5 mm\">Test...</FNT>" textelement.text = str but it didn't work (the textelement wasn't drawn at all on the layout...) I can always convert the mm in pt (1 mm = 2.85 pt) first, but it would be handy if I could do it directly... Thanks in advance Vera
... View more
11-16-2011
02:23 AM
|
0
|
1
|
402
|
POST
|
Jeff, Thanks for the answer and the sample code. It doesn't work like that though..
txt.text = row.getValue("filedName")
rect.elementHeight = txt.elementHeight + 0.1
If the text consists of more than one line, "txt.elementHeight" is still just one line high and thus in the rectangle text field all the text is written on the same line. I solved my problem though by checking my text, if it contains "\n"-characters and if it does, I write it in an rectangle text field, otherwise in a simple text field. Vera
... View more
11-07-2011
03:53 AM
|
0
|
0
|
211
|
POST
|
Hello all I have a text-field in a layout, that I have to populate with data from a database. As this data consists of one up to four lines of text, I'm using a rectangle-text-field. The text-position within the field should always be in the lower left corner, that is, if there's only one line of text, the empty space in the text-field should be above the line of text. I can set the anchor point of the textfield, but I don't see any way of setting the textposition within the textfield. Any ideas? Thanks in advance. Vera
... View more
11-03-2011
03:50 AM
|
0
|
3
|
358
|
POST
|
joldekop;136108 wrote: ..... while row: id= row.getValue ("FID") outFC=id + ".shp" sel = str('"FID" = ' " ' "+id+" ' ") arcpy.Select_analysis(InShapefile, OutFC, sel) row = rows.next() >> indent block 2! (after while row:) I'm using "Pyscripter" to write my scripts. If you forget to indent code there, it's marked as an error.
... View more
09-23-2011
03:44 AM
|
0
|
0
|
273
|
POST
|
Hi Marc Thanks for your reply, especially for the hint with the where_clause, but it still doesn't work. I use variables for the tables and fields and what confuses me now is how to build the where clause, with quotes or without. I tried all kinds of versions, but none would work. I get the following error messages: An invalid SQL statement was used. [QueryTable1] An invalid SQL statement was used. Failed to execute (MakeQueryTable). Here's my code: # path to the file-geodatabase pfad_gdb = "H:\\Moorinventar\\FM_OBJEKTBLAETTER\\Data\FM_OBJEKTBLAETTER.gdb\\" # the two tables within the file-geodatabase table_TEILOBJ = pfad_gdb + "FM_TEILOBJ_REV_2007_MIT_HM" # table A table_HM_FM = pfad_gdb + "HM_FM_VIEW" # table B # the fields to use for the join Field_TeilbOj_ObjNr = table_TEILOBJ+".FM_OBJ" # table_A.number Field_TeilbOj_TObjNr = table_TEILOBJ+".FM_TOBJ" # table_A.subnumber Field_HMFM_ObjNr = table_HM_FM+".FM_OBJ" # table_B.number Field_HMFM_TObjNr = table_HM_FM+".FM_TOBJ" # table_B.subnumber # key field key_field= Field_TeilbOj_ObjNr # no field list, as all the fields are needed # where clause where_clause_ohne_HM= "\""+Field_TeilbOj_ObjNr + "\" = \""+Field_HMFM_ObjNr+"\" AND \""+Field_TeilbOj_TObjNr+"\" = \""+ Field_HMFM_TObjNr+"\" AND \""+Field_HMFM_ObjNr+"\" IS NULL" arcpy.MakeQueryTable_management([table_TEILOBJ,table_HM_FM], "QueryTable1", "USE_KEY_FIELDS",key_field, "",where_clause_ohne_HM) Thanks in advance! Vera
... View more
09-19-2011
06:22 AM
|
0
|
0
|
242
|
POST
|
Hello, I???m quite new to both Python and ArcGIS and I can???t figure out how to solve the following problem: I have two tables (???A??? and ???B???) which both have a first key_field (???number???) and a second key field ???subnumber???. Table ???A??? has more records than table ???B???. Now I have to select all those records from table ???A??? that are NOT contained in table ???B??? too. (Later on I have to loop through those records.) I tried the following statement: arcpy.MakeQueryTable_management(tableList, ???query1???,"USE_KEY_FIELDS", key_fields_List, ??????, whereClause) tableList: table ???A??? and ???B??? query1: new Table view key_fields_List: A.number, A.subnumber,B.number, B.subnumber where clause: B.number is NULL I get the following error message: An invalid SQL statement was used. [query1]. As soon as I run it without the key_fields_List and a where_clause, it runs ok and the two tables get joined (somehow???). I guess it???s my key_fields_List that???s wrong??? (I tried it just with "number, subnumer" as well, but I get the same error.) Does anyone know how I have to define the different terms of the MakeQueryTable-statement? Or is there a different way how I could solve my problem? Thanks for your help Vera
... View more
09-16-2011
02:25 AM
|
0
|
2
|
3318
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|