Community
All Communities
Products
ArcGIS Pro
ArcGIS Survey123
ArcGIS Online
ArcGIS Enterprise
Data Management
Geoprocessing
ArcGIS Web AppBuilder
ArcGIS Experience Builder
ArcGIS Dashboards
ArcGIS CityEngine
ArcGIS Spatial Analyst
All Products Communities
Industries
Education
Water Resources
State & Local Government
Transportation
Gas and Pipeline
Water Utilities
Roads and Highways
Telecommunications
Natural Resources
Electric
Public Safety
All Industries Communities
Developers
Python
JavaScript Maps SDK
Native Maps SDKs
ArcGIS API for Python
ArcObjects SDK
ArcGIS Pro SDK
Developers - General
ArcGIS REST APIs and Services
ArcGIS Online Developers
File Geodatabase API
Game Engine Maps SDKs
All Developers Communities
Worldwide
Comunidad Esri Colombia - Ecuador - Panamá
ArcGIS 開発者コミュニティ
Czech GIS
ArcNesia
Esri India
GeoDev Germany
ArcGIS Content - Esri Nederland
Esri Italia Community
Comunidad GEOTEC
Esri Ireland
Používatelia ArcGIS
All Worldwide Communities
All Communities
Developers
User Groups
Industries
Services
Community Resources
Worldwide
Events
Learning
ArcGIS Topics
Networks
GIS Life
View All Communities
ArcGIS Ideas
GIS Life
Community Resources
Community Help Documents
Community Blog
Community Feedback
Member Introductions
Community Ideas
All Community Resources
Sign In
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show
only
|
Search instead for
Did you mean:
Cancel
Home
:
All Communities
:
Products
:
Geoprocessing
:
Geoprocessing Questions
:
Using Python in Field Calculator
Options
Subscribe to RSS Feed
Mark Topic as New
Mark Topic as Read
Float this Topic for Current User
Bookmark
Subscribe
Mute
Printer Friendly Page
Using Python in Field Calculator
Subscribe
1801
5
Jump to solution
09-23-2010 09:46 AM
by
BrianElliott
New Contributor
09-23-2010
09:46 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
How can I get this simple code to work using python in the field calculator? I cannot get the syntax correct to save my life.
if (!Shape_Area! / 2000) - (math.trunc (!Shape_Area! / 2000) + 1) = 0:
EQ = (!Shape_Area! / 2000) * 30
else:
EQ = (truncate ((!Shape_Area! / 2000) + 1) * 30
I can't get passed the first line without a syntax error.
I would love any help on this,
thanks
Solved!
Go to Solution.
Tags
(3)
Tags:
_geoprocessing
analysis
gp
Reply
0
Kudos
All Posts
Previous Topic
Next Topic
1 Solution
Accepted Solutions
by
DanPatterson_Re
tired
MVP Emeritus
09-23-2010
10:51 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
tested on a shapefile not a geodatabase
View solution in original post
Preview file
65 KB
Reply
0
Kudos
5 Replies
by
BrianElliott
New Contributor
09-23-2010
10:17 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
I did not copy all of the code correctly. Still cannot get passed first line of code...
if (!Shape_Area! / 2000) - math.trunc((!Shape_Area! / 2000) + 1) == 0:
EQ = (!Shape_Area! / 2000) * 30
else:
EQ = math.trunc((!Shape_Area! / 2000) + 1) * 30
Reply
0
Kudos
by
GerryGabrisch
Occasional Contributor III
09-23-2010
10:33 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
Assuming the indentations are correct, you don't use the ! in the code itself, and you need == not =.
See the link below.
Good luck
if (Shape_Area / 2000) - (math.trunc (Shape_Area / 2000) + 1) == 0:
www.esri.com/news/arcuser/0507/files/pythonscript.pdf
Reply
0
Kudos
by
DanPatterson_Re
tired
MVP Emeritus
09-23-2010
10:51 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
tested on a shapefile not a geodatabase
Preview file
65 KB
Reply
0
Kudos
by
BrianElliott
New Contributor
09-23-2010
11:37 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
THANKS DAN!!!
I need to learn more about python, obviously. Your code worked perfectly.
Now I can go get a beer.
🙂
Reply
0
Kudos
by
DanPatterson_Re
tired
MVP Emeritus
09-23-2010
03:05 PM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
pass one through the screen
Reply
0
Kudos
Post Reply