POST
|
Thanks again Asrujit SenGupta. Sorry for the confusion. I'm getting my information from the administrators of our Oracle Databases. (Blame the other guy, right? ) I was told yesterday, it was ST_Geometry, but I've been looking into this for weeks and have spoken to various administrators, so I'll double check with them to confirm. So, my next question would be, if we are running ESRI Binary, it sounds like this would lead to the issue I am experiencing. Is there a fix for this? Is there a way to force Query Layers to pick up soatial on ESRI Binary geometry types?
... View more
12-11-2015
09:41 AM
|
0
|
1
|
2267
|
POST
|
Thanks for respnding Asrujit SenGupta. I'm not sure that answers my question. Is the expected behavior for query layers not to work on ST_Geometry? That sounds counter intuitive to the quote in your repsonse. It seems to be telling me that I have the proper geometry (ST_Geometry) so it should work. Also, I have all the permission needed to do this type of query. Maybe to add a bit of information to add to the mystery. We have 2 Oracle databases. Database 1 is used to manage parcels of land for mining activities, so it is comprised of a number of stand alone tables, features classes and spatial views. Database 2 is a larger corporate database and contains, amoung other things, copies of the feature classes and spatial views (but not the stand alone tables) that come from from the mining activities database. Database specs: DB1: SDE 10.2.2. Oracle v11 using ST Geometry Type DB2: SDE 10.2.2. Oracle v12 using SDO Geometry Type. So, in saying that, I tested the copy of one of the feature classes from both Database 1 and Database 2. Database 1 is the database where I have the issue. If I build a query layer using the feature class from Database 2 (the corporate database), it is successful. See images below. Database 1. Notice the 'UNKNOWN' spatial reference: Database 2. Notice that it populates spatial information in picture 2.
... View more
12-11-2015
08:57 AM
|
0
|
5
|
2267
|
POST
|
Hey, I'm just wondering if any one has some suggestions for this. It's still a bit of a mystery to me. Cheers, Mike
... View more
12-10-2015
08:57 AM
|
0
|
7
|
2267
|
POST
|
So, I posted this question after working on the solution for a couple days and as soon as I posted, I found a possible solution. Thought I'd share. I did a quick google search on how to print out a python function definition. It took to to this page: http://stackoverflow.com/questions/427453/how-can-i-get-the-source-code-of-a-python-function A few of the answers suggestion to use a module called 'inspect' which evaluates the contents of classes, methods, functions, etc. Python Inspect Help. One of the inspect functions allows you to find the source code of a function import inspect inspect.getsource(myfunction) so, I tried this (rememebering to pass a string (str) conversion of the inspection into the codeblock parameter): arcpy.CalculateField_management(outClipFC, "PERCENTAGE_OF_OVERLAP_OF_LAYER",
"getPercentOverlapValueOfAOI(!AREA_OF_OVERLAP_HA_OF_LAYER!, {0})".format(extentArea),
"PYTHON", str(inspect.getsource(getPercentOverlapValueOfAOI))) And it works. Hopefully this is helpfully to others.
... View more
12-03-2015
02:44 PM
|
1
|
1
|
2505
|
POST
|
Hey Darren, thanks for the tip. I did come across a few suggestions to use UpdateCursor. This exposes my stubborness. I'm convinced to find a way, only because by using UpdateCUrsor, it would mean I'd have to change a little bit of my other code. If this doesn't work out, so be it. I'll use the Cursor
... View more
12-03-2015
02:11 PM
|
0
|
1
|
2505
|
POST
|
I have a function that I use in a script in a couple different ways. One of the ways I would like to use it, is in the codeblock parameter of: arcpy.CalculateField_management The function is here and basically does some math and returns a value: def getPercentOverlapValueOfAOI(area_of_overlap, extentarea):
if round(area_of_overlap/extentarea * 100, 1) < 0.1:
AOI_Percent_Value = str("<" + "0.0")
else:
AOI_Percent_Value = str(round(area_of_overlap/extentarea * 100,1))
return AOI_Percent_Value and then further down in my script, I use the calculate field function: arcpy.CalculateField_management(outClipFC, "PERCENTAGE_OF_OVERLAP_OF_LAYER",
"getPercentOverlapValueOfAOI(!AREA_OF_OVERLAP_HA_OF_LAYER!, {0})".format(extentArea),
"PYTHON", """getPercentOverlapValueOfAOI""") Consistently, I am receiving the following error ExecuteError: ERROR 000539: Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'getPercentOverlapValueOfAOI' is not defined Now, I understand that in example #2 in the help menu, They use a variable "codeblock" and wrap the function in triple quotes. I believe calculatefield evaluates the code block string and interprets it as a function. The issue I have with that, is that I have a function that I use inside and outsiide of the arcpy.CalculateField_management function. I initially declare it without the triple quotes becuase the native python interpter will obviously not undertand that the triple quoted string is, in fact, a python function. Now, I've tried a number of things to get this to work. For example, I assign a variable to the triple quote wrapped function: codeblock = """def getPercentOverlapValueOfAOI(area_of_overlap):
if round(area_of_overlap/extentArea * 100, 1) < 0.1:
AOI_Percent_Value = str("<" + "0.0")
else:
AOI_Percent_Value = str(round(area_of_overlap/extentArea * 100,1))
return AOI_Percent_Value""" and then pass the codeblock variable into the caluclate field function: arcpy.CalculateField_management(outClipFC, "PERCENTAGE_OF_OVERLAP_OF_LAYER",
"getPercentOverlapValueOfAOI(!AREA_OF_OVERLAP_HA_OF_LAYER!, {0})".format(extentArea),
"PYTHON", codeblock) Now, that seems to work, but it completely defeats the purpose of creating a function. One of the primary purposes of a function is to make the code reusable. It seems like I have to define my variable twice. Once at the beginning of my script and then again so that I can get it wrapped in triple quotes and then pass it to a variable that in turn, gets passed into the caluclate field function. I've also tried to pass the function name into the expression via .format with the same error popping up ( I think I was trying to get creative and silly with this one): arcpy.CalculateField_management(outClipFC, "PERCENTAGE_OF_OVERLAP_OF_LAYER",
"{0}(!AREA_OF_OVERLAP_HA_OF_LAYER!, {1})".format(getPercentOverlapValueOfAOI, extentArea),
"PYTHON", """getPercentOverlapValueOfAOI""") My question is, what is the best way, to take a custom built function and pass it into the calculate field function as a piece of code block and then have the expression parameter recognize it.
... View more
12-03-2015
01:54 PM
|
0
|
5
|
6416
|
POST
|
Hello all, I've been bumbling through some SDE Geodatabases, trying to learn how to query geometry. In particular, AREA and LENGTH. Now, I have 2 different SDE geodatabases. One is running SDO_Geometry, the other is ESRI Binary Spatial Type. In each geodatabase, there is an identical polygon feature class (i.e one is a copy of the other). I wanted to query the length and area of one of them. I started with the feature class with the SDO_geometry: select OBJECTID,GEOMETRY,SDO_GEOM.SDO_Area(Geometry, 0.0005) AREA,SDO_GEOM.SDO_LENGTH(Geometry, 0.005) PERIMETRE
from
MySDEFeatureClass This query works out fine. So in my bumbling, I tried to use the query on the feature class containing the ESRI Binary Spatial Type Geometry and of course, that failed because it isn't using SDO. Then I started googling around and found how to query ST_Geometry. Again, fail. It is not using ST_Goemetry. I tried googling for querying on ESRI Binary Spatial Type and I couldn't really find anything. Again, I'm bumbling because I'm learning as I go, but can I query on this spatial data type? Is there an example on how to do this or is there something I am missing?
... View more
10-13-2015
10:32 AM
|
0
|
2
|
3622
|
POST
|
Thanks Chris. One other piece of information. I tested another database we have. One that's running SDO_Geometry. Building a Query Layer in on a feature class from that database seems to work fine and populates the shapes in ArcMap. The database I want to use is running ESRI Binary spatial type. I am wondering if this might be part of the issue. I can't seem to find any reference to the spatial data types and query layers.
... View more
09-17-2015
11:36 AM
|
0
|
0
|
2267
|
POST
|
I am building a query layer in ArcMap 10.2 via File-->Add Data-->Add Query Layer wizard. I am using a few tables from an Oracle database (11g, ST_Geometry) using ArcSDE 10.2. There are 4 tables that i am using, 3 of which are regular database tables, the 4th is a spatial view. I am hoping to use the spatial view to populate the geometry of the results of the query layer. I have built my query and validated it successfully. I have chosen to use the advanced options and when I get to that part of the wizard, supposedly I can choose a spatial reference so that i can project my results. The problem that I am having is that this area is greyed out and I cannot set a spatial reference. Further to that, it is showing the spatial reference as "Unknown" which leads me to believe that the query layer is not picking up the reference from the spatial view. I have 'Finished' the query layer and all I get is a table with no geomtry attached to plot the shapes. So, I have a few questions: How do I plot the shapes of my query layer, given the version of Oracle and SDE I am running? Can a query layer use a spatial view for the spatial aspect of the layer? If not, how would I accomplish this? Why is the spatial reference greyed out? Thanks in advance for any help.
... View more
09-14-2015
01:49 PM
|
0
|
10
|
5941
|
Title | Kudos | Posted |
---|---|---|
1 | 12-03-2015 02:44 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|