Write a Geo-processing model / python script....

2292
2
10-26-2015 09:37 AM
JosephLing
New Contributor II

Hi all,

I wish to find out how I can write a geo-processing model / pythin script for following two requirements?

1) To export the feature class into MDB file format. The MDB file shall contain the longitude and latitude of the feature class.

                The attributes of the feature class are as follow:

                                a) OBJECTID

                                b) SHAPE

                                c) BASE_ID

                                d) PARA1

                                e) PARA2

                                f) SET1

                                g) SET2

2) To import the MDB file into geodatabase.

                The fields of the MDB file are as follow:

                                a) UNI_ID

                                b) UNI_DESC

                                c) PARA1

                                d) PARA2

                                e) PARA3

                                f) LONGITUDE

                                g) LATITUDE                                                     

Note : The LONGITUDE and LATITUDE is in WGS84 projection.

Appreciate if anyone can help.

0 Kudos
2 Replies
FreddieGibson
Occasional Contributor III

Are you asking how to take a geodatabase feature class and export it to a table within a personal geodatabase or pure access database? I would assume based on the fields you've listed in requirement two that this would have to be a table within a pure access database because 1) a personal geodatabase wouldn't allow you to call the OID field UNI_ID and 2) the specifications lack a SHAPE field.

Depending on your experience with python this workflow will vary. If I had to execute this I would use cursors to dynamically reproject the data and then use 3rd party libraries, such as pyodbc, to execute INSERT statements to load the records into the Access database.

SearchCursor (arcpy.da)

http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/searchcursor-class.htm

Python ODBC library

https://code.google.com/p/pyodbc/wiki/GettingStarted

You'll want to note with the cursor that you can specify the spatial reference. This will allow you to project the data on-the-fly without having to create additional output. There are also other tools available that would allow you hydrate fields with these values without having to create additional data.

If you were writing to a geodatabase (personal, file, or enterprise) or flat-file that esri supports writing to you could easy use an Insert Cursor to upload the data. If you're really using an Access Database I would assume that writing to it would be unsupported and would most likely corrupt it because the software would try to treat it like a personal geodatabase and add our repository tables to it.

The alternative to this workflow would be the manual approach, which you could automate some of the steps.

  1. Project the data to WGS84 and add the XY Coordinates or calculate the values against the source data.

    Project (Data Management)
    http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/project.htm

    Calculate Field (Data Management)
    https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field.htm

    Convert Coordinate Notation
    http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/convert-coordinate-notatio...

  2. Load data into table
DanPatterson_Retired
MVP Emeritus

And to add to Freddie's comments, if you can perform the tasks manually using tools in Arctoolbox, you can get the basis for a script and/or model by examine the contents of the Results window (Customize, Results from the menu).  It will obviously serve as a companion to the script snippets within the help topics.

A quick tour of geoprocessing—Help | ArcGIS for Desktop

0 Kudos