+ Reply to Thread
Results 1 to 12 of 12

Thread: Python ERROR 000539

  1. #1
    ABDALLA MOHAMED
    Join Date
    Aug 2011
    Posts
    80
    Points
    0
    Answers Provided
    0


    0

    Default Python ERROR 000539

    Hello.I was running the following in ARCMap version 10: gp.CalculateField_management(nn_output_file, "patch_area", "[F_AREA]/1000000", "VB", ""), and keep getting the following error:
    ERROR 000539:Error running expression: [F_AREA]/1000000. Name 'F_AREA' is not defined. Any hint. Appreciated. Thanks!

  2. #2
    Mathew Coyle

    Join Date
    Feb 2011
    Posts
    1,389
    Points
    968
    Answers Provided
    151


    0

    Default Re: Python ERROR 000539

    Most likely, if that field does indeed exist, you are using improper syntax for the field. What is the data type of the feature class you are calculating on? Square brackets are for personal geodatabases. (See http://help.arcgis.com/en/arcgisdesk...0033000000.htm)

    Also, double check the field data type to make sure it is numeric.

    Also, if you are using ArcGIS 10, you should be using arcpy, not the old arcgisscripting. Unless you have it mapped to the new geoprocessor already.
    Last edited by mzcoyle; 01-09-2012 at 01:28 PM. Reason: Field type
    Mathew Coyle, EADA10
    GIS Analyst
    Alberta-Pacific Forest Industries Inc.
    ArcGIS 10.2.2 Testing
    ArcGIS 10.1 SP1
    Desktop, Server, ArcPad
    Windows 7 SP1 64-bit

  3. #3
    ABDALLA MOHAMED
    Join Date
    Aug 2011
    Posts
    80
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python ERROR 000539

    Mathew..Let me try that and will let you know about the result. Thanks for your input..

  4. #4
    ABDALLA MOHAMED
    Join Date
    Aug 2011
    Posts
    80
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python ERROR 000539

    I used the following code to add and calculate field:-
    gp.AddField_management(nn_file, "p_area", "DOUBLE", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "")
    gp.CalculateField_management(nn_file, "p_area", "[F_AREA]/1000", "PYTHON", "")


    I keep getting error and couldn't figure it out..Any hint??? Thanks!

  5. #5
    Curtis Price

    Join Date
    Oct 2009
    Posts
    1,798
    Points
    875
    Answers Provided
    127


    0

    Default Re: Python ERROR 000539 - Calculate Field fails

    That's VBScript, you need to do one of the following. (This is documented in the Calculate Field tool documentation.)

    VBScript (the default BTW):

    Code:
    gp.CalculateField_management(nn_file, "p_area", "[F_AREA] / 1000")
    Python:

    Code:
    gp.CalculateField_management(nn_file, "p_area", "!F_AREA! / float(1000)","PYTHON")
    • It is best practice (in Python 2.x anyway) to recast one of the operands to float to ensure you get floating division. (Even though if !F_AREA! is a float field python will know that, it's a good idea.)
    • Mathew's comment about different field syntax for different dataset types does not apply here -- that applies only to SQL expressions used in tools like Select and MakeFeaturelayer. In Calculate Field, fields are always surrounded by [] or !!, depending on the choice of script language.
    Last edited by curtvprice; 01-12-2012 at 10:35 AM.

  6. #6
    ABDALLA MOHAMED
    Join Date
    Aug 2011
    Posts
    80
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python ERROR 000539

    Let me try it and I will let you know about the output..
    Thanks a lot...

  7. #7
    aaron boci
    Join Date
    May 2013
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python ERROR 000539

    Hello, I am also getting this error. I am running raster calculator and I have 2 fields in which I am trying to multiply. One field is a float, the other was a long. This did not work. So I added a new field in the layer which had the long and designated it a float, then I filled the column with the values I had before as long. I then tried to multiply them again, but I received the same error. I need my data in float for further processing in Darcy's Tools. Currently I have the thickness and Hydrologic conductivity values. according to the formula K = T/b from those rules, that is the same as Kb=T. Transmissivity. This is the last layer I need to create to perform this tool. but I'm not sure why it will not multiply to floats.

  8. #8
    Curtis Price

    Join Date
    Oct 2009
    Posts
    1,798
    Points
    875
    Answers Provided
    127


    0

    Default Re: Python ERROR 000539

    Aaron, Raster Calculator is different - instead of accessing the fields directly in the expression, you access those data values for each cell using the Lookup() tool.

  9. #9
    aaron boci
    Join Date
    May 2013
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python ERROR 000539

    Yes, I have the two layers necessary, both of which have the same cell size and alignment. What I did to get it to run just now was created a new field in the attribute table as a float. Then, i did a reclassify of that layer on that field. but, reclassify does not make negative values, I did a raster calculation of minus two on every cell. this brought me back to my original values but in long format again. but this time it performed. but did not give me the values I am expecting. one field goes from -2 to 6. the other goes from 0-1,000,000 and I only got values from -358 to 760. all I'm trying to do is simply multiply 2 raster layers values, I've used this tool a hundred times, that's why I am confused as to why it is not working. I understand the different number types but since they're the same, i don't know what to do. I don't know how to program so I am limited to tool use.

  10. #10
    Curtis Price

    Join Date
    Oct 2009
    Posts
    1,798
    Points
    875
    Answers Provided
    127


    0

    Default Re: Python ERROR 000539

    Instead of Reclassify, have you tried the Lookup tool? Say you have a field "XVALUE" in the raster table. In Raster Calculator you can use Lookup to create a new grid with XVALUE as the cell values:

    Lookup("mygrid","XVALUE")

    You can also just use the Lookup tool in the dialog, but the Raster Calculator would allow you to combine the operation with something else, for example:

    Lookup("mygrid","XVALUE") * 100.0

    I read your first post and it seems like you want to create a float field in the raster table, run Calculate Field in your raster table to get your "T/b" value, and .. then use Lookup to make a grid of that float field.

  11. #11
    aaron boci
    Join Date
    May 2013
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python ERROR 000539

    Well I got it to run by reclassifying both of the two layers into long form. so i have the new transmissivity layer. my next step is to run Darcy's flow. I found a way to side step the problem. but I may have a new problem. Darcys flow needs 4 raster layers, all of which have to be the same cell size and alignment, that is fine, im good there, but they all need to be in float, says the directions. also it says if the residual is too high, my data means nothing and that I should put it through a proper porous medium flow program. I think the effective porosity layer is that layer. I'm going to run this tool once I write down what I've done, if it does not run, I will try your advice on how to change all 4 of my layers to float numbers.

  12. #12
    aaron boci
    Join Date
    May 2013
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python ERROR 000539

    I actually have all 4 of my layer created and I ran Darcy's flow tool. Good news is over 99% of my cells had a residual of 0, almost all the other cells were within 1 STD. The bad news is only 75% of my area actually has a result. The areas with high porosity did not calculate and I have a rectangle at the top of my ROI that did not calculate either. I am not sure why this occurred. I will keep my results and continue looking for reasons as to why. and hopefully find a solution. oddly enough, Darcy direction did not work either but magnitude did.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts