POST
|
Hi I am trying to write a definition query on a points file on an Oracle DB. I want to retrieve records added in the last six months. So far, I have written the following: MONTHS_BETWEEN (SYSDATE, TO_DATE ( DATE_CREATED, 'DD/MM/YYYY')) <6 This doesn't return any rows at all. I have also tried this code: SYSDATE - DATE_CREATED < 185 This works to a certain extent but it is not precise. Can anyone please help me find a solution to this? Thanks.
... View more
05-25-2012
02:28 AM
|
0
|
1
|
619
|
POST
|
I changed the expression type to PYTHON_9.3 and it's working now.
... View more
10-21-2011
06:57 AM
|
0
|
0
|
198
|
POST
|
Hi I am using 10 with an ArcView licence, so don't have access to Feature To Point tool. Which version, 9.2, 9.3 and 10.x all have different syntax to access the shape field properties. I recommend you instead of accessing the centroid this way, take an easier path: use the out of the box Feature To Point tool followed by the Add XY Coordinates tool.
... View more
10-20-2011
01:23 AM
|
0
|
0
|
198
|
POST
|
Hi I have attached the zip which contains the shape file. Please have a look. Thanks. The * is okay, that just means the field is binary, which is a good thing. The csv export you posted doesn't have a shape field, and doesn't contain the original field formats, so it doesn't help much with determining the problem. Please see the attached screenshots for proper export technique.
... View more
10-20-2011
01:21 AM
|
0
|
0
|
982
|
POST
|
Well that's interesting. You do have a shape field called Shape, I assume? Maybe you can attach a one-record copy of this table so we can reproduce the error. Yes, the Shape field is there but it is called Shape * see the attached screen shot. Also, I have attached a record for you.
... View more
10-19-2011
07:00 AM
|
0
|
0
|
982
|
POST
|
I see what you mean! In that case, let's take Alexander's advice and use the LabelPoint of the pArea. Change this:
pPoint = pArea.Centroid
To this:
pPoint = pArea.LabelPoint
Great! It's working. All points are now appearing inside the polygons. Thanks, James and Alexander. You have been really helpful.
... View more
10-19-2011
06:49 AM
|
0
|
0
|
131
|
POST
|
You have the right idea; you're just making it more complicated than it needs to be. Try: arcpy.CalculateField_management(test_poly, "X_COORD", "!Shape!.centroid.x", "PYTHON", "") I have attached a screenshot below. Hi I've tried that but it is throwing this error: Executing (Calculate Field): CalculateField BuildingTest Easting !Shape!.centroid.x PYTHON # Start Time: Wed Oct 19 15:36:21 2011 ERROR 000539: Error running expression: GPVARIANTOBJECT0.centroid.x <type 'exceptions.AttributeError'>: 'str' object has no attribute 'x' Failed to execute (Calculate Field). Failed at Wed Oct 19 15:36:21 2011 (Elapsed Time: 0.00 seconds)
... View more
10-19-2011
06:40 AM
|
0
|
0
|
982
|
POST
|
Sorry, forgot to show you where the point is appearing. See attached.
... View more
10-19-2011
06:19 AM
|
0
|
0
|
505
|
POST
|
Well, your do loop contains a few lines which are different from the code I have in VBA:
Option Explicit
Sub CreateCentroid()
''provides access to members that control the MXD
Dim pDoc As IMxDocument
''Provides access to members that control the map.
Dim pMap As IMap
''Set the MXD to this mxd file
Set pDoc = Application.Document
''Set the focus to the current map
Set pMap = pDoc.FocusMap
''Provides access to members that hand out enumerated features,
''field collections and allows for the updating, deleting and inserting of features.
Dim pFCursor As IFeatureCursor
''Provides access to members that manage a set of selected table rows or features.
Dim pSelectionSet As ISelectionSet2
''Provides access to members that control feature selection.
Dim pFSelection As IFeatureSelection
''Set the first layer as the active layer
Set pFSelection = pMap.Layer(0)
''Set the selected features
Set pSelectionSet = pFSelection.SelectionSet
''set the pfeaturecursor
Set pFCursor = Nothing
''Get a cursor from the selected features
pSelectionSet.Search Nothing, False, pFCursor
''Provides access to members that identify a polygon and permit controlled access to its inner and outer rings.
Dim pPoly As IPolygon4
''Provides access to members that return properties common to rings and polygons.
Dim pArea As IArea
''Provides access to members that define two dimensional points.
Dim pPoint As IPoint
''Variable to hold the X coordinate
Dim lat As Long
''Variable to hold the Y coordinate
Dim lon As Long
''Provides access to members that return and set properties of a feature.
Dim pFeat As IFeature
Set pFeat = pFCursor.NextFeature
Do Until pFeat Is Nothing
Set pPoly = pFeat.ShapeCopy
Set pArea = pPoly
Set pPoint = pArea.Centroid
lat = pPoint.X
lon = pPoint.Y
Set pFeat = pFCursor.NextFeature
Loop
MsgBox "The Eastings:" & lat & " The Northings:" & lon
End Sub
Could this be the reason? See the attached screenshot for an example of a polygon that I am trying to work with. With square or rectangle polygons, it is fine but with any other strange shape it is not appearing inside the polygon.
... View more
10-19-2011
06:13 AM
|
0
|
0
|
505
|
POST
|
Hi Still stuck at this final bit. I was reading about the IArea.Centroid Property and in the remarks at the end of the page, it says: "The Centroid does not always occur inside the Area of the geometry. The Centroid is not the same as the center of the geometry or the Envelope binding the geometry (but it may be if and only if that is also the center of the weighted area)." Is there anyway I can keep the centroid inside the selected polygon? Thanks
... View more
10-19-2011
03:19 AM
|
0
|
0
|
505
|
POST
|
Hi I am trying to do what this example is showing in VB: http://support.esri.com/en/knowledgebase/techarticles/detail/32482 I am trying to use python instead of VB.
... View more
10-19-2011
01:36 AM
|
0
|
0
|
982
|
POST
|
Hi I am trying to use python script in a model but it is throwing an error message: ERROR 000539: Runtime error <type 'exceptions.NameError'>: name 'table2' is not defined Failed to execute (Calculate Field). I guess, it is about how to use table2 in the CalculateField_management function. I am not sure how I can do it. I have attached the screen shot of my model and the script. Any help would be really appreciated. Thanks
... View more
10-18-2011
03:51 AM
|
0
|
11
|
1871
|
POST
|
Hi Is there any guidance on how to translate VBA code to Python? The reason I want to do this is because I wanted to use some powerful features of Arcpy which do not exist in VBA. Thanks.
... View more
10-18-2011
01:34 AM
|
0
|
1
|
495
|
POST
|
You just create a Model with your input features as a model parameter. When you run the tool with some features selected, it will process only the selected features. If no feature is selected then it will process all features. You don't need to prompt the user to select. All model tools works the above way. Great! Thanks for your help.
... View more
10-18-2011
01:14 AM
|
0
|
0
|
198
|
POST
|
Thanks for your help again. One final thing is that at the moment, some points are being created outside the selected polygons. Is there a way to keep them inside polygons?
... View more
10-17-2011
07:39 AM
|
0
|
0
|
505
|
Title | Kudos | Posted |
---|---|---|
1 | 10-13-2011 08:28 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|