Community
All Communities
Products
ArcGIS Pro
ArcGIS Survey123
ArcGIS Online
ArcGIS Enterprise
Data Management
ArcGIS Experience Builder
Geoprocessing
ArcGIS Web AppBuilder
ArcGIS Dashboards
ArcGIS Field Maps
ArcGIS StoryMaps
All Products Communities
Industries
Education
Water Resources
State & Local Government
Transportation
Gas and Pipeline
Water Utilities
Roads and Highways
Telecommunications
Natural Resources
Electric
Imagery and Remote Sensing Insights (IRIS) COP
All Industries Communities
Developers
Python
JavaScript Maps SDK
Native Maps SDKs
ArcGIS API for Python
ArcGIS Pro SDK
ArcObjects SDK
Developers - General
ArcGIS REST APIs and Services
ArcGIS Online Developers
Game Engine Maps SDKs
File Geodatabase API
All Developers Communities
Global
Comunidad Esri Colombia - Ecuador - Panamá
ArcGIS 開発者コミュニティ
Czech GIS
ArcNesia
Europe
Esri India
Americas
Asia Pacific
Comunidad GEOTEC
GeoDev Germany
ArcGIS Content - Esri Nederland
All Global Communities
All Communities
Developers
User Groups
Industries
Services
Community Resources
Global
Events
Learning
Networks
ArcGIS Topics
Products
View All Communities
ArcGIS Ideas
GIS Life
Community Resources
Community Help Documents
Community Blog
Community Feedback
Member Introductions
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
:
Re: 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
Select to view content in your preferred language
Translate Now
Using Python in Field Calculator
Subscribe
2124
5
Jump to solution
09-23-2010 09:46 AM
by
BrianElliott
Deactivated User
09-23-2010
09:46 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
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
tested on a shapefile not a geodatabase
View solution in original post
Preview file
65 KB
Reply
0
Kudos
5 Replies
by
BrianElliott
Deactivated User
09-23-2010
10:17 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
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
Frequent Contributor
09-23-2010
10:33 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
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
tested on a shapefile not a geodatabase
Preview file
65 KB
Reply
0
Kudos
by
BrianElliott
Deactivated User
09-23-2010
11:37 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
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
pass one through the screen
Reply
0
Kudos
Post Reply