|
POST
|
One way that this could be found is by using the arcpy.mapping module to list out all the layers in your MXD. Here is an example of that where it will list both the fully qualified file path and the workspace path:
import arcpy
mxd = arcpy.mapping.MapDocument("<MXDPath>")
df = arcpy.mapping.ListDataFrames(mxd)
for d in df:
print "Data Frame: " + d.name
layers = arcpy.mapping.ListLayers(mxd, "", d)
for lyr in layers:
print "Layer Name: " + lyr.name
print "Data Source: " + lyr.dataSource #This will return the fully qualified path of the file (C:\Shapefiles\femapnls.shp)
print "Workspace Path: " + lyr.workspacePath #This will return the workspace path of the file (C:\Shapefiles)
Output:
Data Frame: Layers
Layer Name: FEMA
Data Source: C:\Shapefiles\femapnls.shp
Workspace Path: C:\Shapefiles
Note: This output will be reflect a similar path name if there are raster, csv, dbf, etc. in the MXD (C:\Raster\Aerial.tif)
... View more
10-15-2014
08:03 AM
|
0
|
1
|
4593
|
|
POST
|
This can be done using the geometry column of the shapefile to return the length and area in the Calculate Field tool. ArcGIS Help 10.1
import arcpy
shp = r"<Path>\<ShapefileName>.shp"
arcpy.CalculateField_management(in_table=shp,
field="EdgeRatio",
expression="!shape.length!/!shape.area!",
expression_type="PYTHON_9.3",
code_block="#")
... View more
10-14-2014
04:20 PM
|
2
|
1
|
3754
|
|
POST
|
Hi Bahram, probably the easiest way to get all the client libraries required is to download them from the my.esri.com portal. However, they can also be downloaded directly from PostgreSQL. The only issue of downloading them directly from PostgreSQL is that the libiconv-2.dll (for Win32) is not included in the PG binaries, this instead comes from the PostGIS install. If you would like to download the client libraries from the my.esri.com you can use the following steps to download the libraries. Log into my.esri.com Click the My Organizations tab Click Products from the Organization ribbon Click Downloads from the Products list 5. Click View Downloads next to your current version of ArcGIS for Desktop 6. Expand the Additional Products tab to download the correct version of the PostgreSQL client
... View more
10-02-2014
04:23 PM
|
2
|
7
|
4492
|
|
BLOG
|
For some users, it is much more efficient to insert data into their SDE feature classes via SQL statements. Although its fairly straightforward to do this for a single feature, it gets a little more complicated when a lot of records need to be inserted while referencing the sde.next_rowid function. However, one way to fulfill the constraints of the primary key and use proper sequencing is to create an iterator in SQL Server. The below example shows how this can be done:
-- Truncate the table to have the records inserted
TRUNCATE TABLE sde.pipeline_points
-- Get the number of rows in the looping table
DECLARE @RowCount INT
SET @RowCount = (SELECT COUNT(*) FROM [sde].[INPUTTABLE])
-- Declare an iterator
DECLARE @iterator INT
-- Initialize the iterator
SELECT @iterator = MIN(OBJECTID) FROM SDE.INPUTTABLE
-- Loop through the rows of a table
WHILE @iterator is NOT NULL
BEGIN
DECLARE @id as integer
-- Get OBJECTID value
EXEC sde.next_rowid 'sde', 'pipeline_points', @id OUTPUT;
-- Insert the data while casting the points geometry
INSERT INTO sde.pipeline_points
SELECT
@id,
LATITUDE,
LONGITUDE,
geometry::STPointFromText('POINT('+str(LONGITUDE, 20, 10) + ' ' + str(LATITUDE, 20, 10) + ')', 4326) as SHAPE
FROM [sde].[INPUTTABLE] where objectid = @iterator;
-- Update the iterator value
SELECT @Iiterator= MIN(OBJECTID) FROM SDE.INPUTTABLE WHERE @iterator < OBJECTID
END
This script is also helpful for selecting geometries on the fly from the Lat/Long fields within a table without having to use the Display XY tool in ArcMap.
SELECT *,
geometry::STPointFromText('POINT(' + Str(LONGITUDE, 20, 10) + ' ' + Str(LATITUDE, 20, 10) + ')', 4326) AS shape
FROM database.SCHEMA.table
... View more
10-01-2014
01:11 PM
|
4
|
1
|
1017
|
|
POST
|
Hi Gustavo, probably the easiest way to get all the client libraries required is to download them from the my.esri.com portal. However, they can also be downloaded directly from PostgreSQL. The only issue of downloading them directly from PostgreSQL is that the libiconv-2.dll (for Win32) is not included in the PG binaries, this instead comes from the PostGIS install. If you would like to download the client libraries from the my.esri.com you can use the following steps to download the libraries. Log into my.esri.com Click the My Organizations tab Click Products from the Organization ribbon Click Downloads from the Products list 5. Click View Downloads next to your current version of ArcGIS for Desktop 6. Expand the Additional Products tab to download the correct version of the PostgreSQL client
... View more
09-22-2014
08:07 AM
|
3
|
0
|
993
|
|
POST
|
Yes, that warning is to be expected if the ST_SHAPELIB is not specified for the correct path. This warning can be addressed after creating the geodatabase by configuring the external processes (exproc.ora) for Oracle to point to the ST_SHAPELIB.DLL. Configuring the Oracle extproc to access the geodatabase with SQL: ArcGIS Help (10.2, 10.2.1, and 10.2.2)
... View more
09-19-2014
08:12 AM
|
0
|
3
|
1746
|
|
POST
|
Hi Julie, can you try the following script: #create a new sde connection #List all featureclasses in a geodatabase, including any within feature datasets import arcpy,os from arcpy import env arcpy.env.overwriteOutput = True arcpy.CreateDatabaseConnection_management(out_folder_path="Database Connections", out_name="GIS winauth to gis-server.sde", database_platform="SQL_SERVER", instance="gis-server", account_authentication="OPERATING_SYSTEM_AUTH", database="GIS", version_type="TRANSACTIONAL", version="dbo.DEFAULT") arcpy.env.workspace = r"Database Connections\GIS winauth to gis-server.sde" datasets = arcpy.ListDatasets(feature_type='feature') datasets = [''] + datasets if datasets is not None else [] for ds in datasets: for fc in arcpy.ListFeatureClasses(feature_dataset=ds): path = os.path.join(arcpy.env.workspace, ds, fc) print path I believe the problem with the previous script was that the parameters were looking for the data in the following order: (out_folder_path, out_name, database_platform, instance, {account_authentication}, {username}, {password}, {save_user_pass}, {database}, {schema}, {version_type}, {version}, {date}) Although they are optional parameters, arcpy is expecting a variable there. So another way to complete this is to specify the dictionary parameters for arcpy.CreateDatabaseConnection_management()
... View more
09-18-2014
02:16 PM
|
0
|
2
|
4731
|
|
POST
|
Hi Julie, I don't see the script attached to this message, can you post it again?
... View more
09-18-2014
01:50 PM
|
0
|
0
|
4731
|
|
POST
|
No, if you want to use the Create Enterprise Geodatabase tool with a predefined tablespace for SDE, you can allow the tool to create the user and grant permissions to sde. However, you will need to specify the existing tablespace name in the tool under the Tablespace Name parameter. As long as that tablespace name exists, the tool will assign the SDE user to that tablespace.
... View more
09-18-2014
07:56 AM
|
0
|
5
|
1746
|
|
POST
|
Here is a picture showing the output when DefQ is outside the parameters.
... View more
08-13-2014
06:58 AM
|
1
|
1
|
4761
|
|
POST
|
It looks like you are missing a right parentheses on your "b" variable. #Current b variable
b = sum(row[0] for row in arcpy.da.SearchCursor(fc, 'QUANTITY_SOLID')),DefQ
#This returns both the b variable and the definition query separated by a comma similar to a tuple
#Should be to return a value of b from a search cursor with definition query DefQ
b = sum(row[0] for row in arcpy.da.SearchCursor(fc, 'QUANTITY_SOLID',DefQ))
The original script has the definition query outside the parameters of the SearchCursor tool. Then when the "b" variable is called later on, it is read as a tuple instead of a single string/integer/float/etc. By moving the definition query inside the parentheses, it should return a value "b" from search cursor with definition query "DefQ". This should return a single variable instead of a tuple.
... View more
08-13-2014
06:54 AM
|
1
|
2
|
4761
|
|
POST
|
I'm glad to hear this worked! The reason that it won't work in a File Geodatabase is because it requires the use of a subquery ("Elev_Diff in (select MIN(Elev_Diff) from <featureclass>”) which isn't supported in a File Geodatabase as of yet. One way that this could be worked around is by running the process through Python and finding the minimum value there instead.
... View more
08-06-2014
08:06 AM
|
0
|
0
|
1963
|
|
POST
|
I believe that the issues being faces are related to the geodatabase referenced in G (7_Match_DTM_Assessment.gdb) and used for the FC to FC in B. This is currently a File Geodatabase (.gdb) and needs to be a Personal Geodatabase with a .mdb extension.
... View more
08-06-2014
07:43 AM
|
2
|
2
|
11860
|
|
POST
|
Can you send a picture of your model and the settings of the "Name” variable?
... View more
08-06-2014
07:04 AM
|
0
|
4
|
9881
|
|
POST
|
No problem. Do you get the error when running the model or verifying the SQL expression? If it happens during the verify, this would be expected because the verification does not substitute the value of the inline variable when evaluating an expression. When the tool runs, the value of the inline variable is substituted in the expression and the results are created based on the substituted values. (See link here)
... View more
08-05-2014
06:25 AM
|
0
|
6
|
9892
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 10-09-2025 08:31 AM | |
| 12 | 09-27-2022 06:23 AM | |
| 3 | 03-28-2024 05:12 AM | |
| 3 | 12-20-2023 06:42 AM | |
| 6 | 08-31-2023 05:42 PM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|