1

Is there a model already built for this simple process? Can ModelBuilder do this?

  1. Export feature to shapefile
  2. Delete fields
  3. Rename shapefile
  4. Post to FTP site
  5. Run this process every Friday

It would be way easier if something like this was already built.

3 Answers 3

8

You can accomplish steps 1-3 by simply using Feature Class to Feature Class (Conversion) with a field map that omits the undesired fields and by specifying the desired output feature class (shapefile) name.

For posting to an FTP site you have a number of options but I would suggest creating a script tool that uses Python's ftplib module to upload the file(s).

I would also recommend zipping the files using the zipfile module before uploading them since a shapefile consists of multiple files and can become easily corrupted if even one file is missing, is easier to work with a single file, and needless to say it will have a smaller file size.

To schedule something like this to run weekly you could execute a batch file or a Python script within a task created with the Windows Task Scheduler.

1
  • 1
    blah238 method works and +1 for the zipping up which saves upload time too.
    – Mapperz
    May 23, 2012 at 13:37
3

To help you along the ftp script would look something like this:

import sys, os
def Send(source_directory_path, input_list, ftpOutputPath):
  try:
    from ftplib import FTP
    #establish the FTP connection
    ftp = FTP('ftp.yourserver.com')
    ftp.login("yourlogin","yourpswd")
    #move to the right output diretory
    ftp.cwd(ftpOutputPath)
    #copy the files from the list to the output directory
    for i in input_list:
      #stor is the ftp command, i is the item in the list
      sendThis = 'STOR ' + i
      fullPath = os.path.join(source_directory_path, i)
      f = open(fullPath, 'rb')
      ftp.storbinary(sendThis, f)
      f.close()
    #close the connection politely
    ftp.quit()
  except:
    sys.exit()
0

You might need to write some custom python script and import some FTP libraries in order to do this. The script could be incorporated into your model. I don't think there is a way to have model builder run the process weekly. However, if you were to create the entire process in python, you could schedule a task to run automatically.

Just a question regarding your workflow, why not rename the shapefile in the export process?

I don't have a pre-made model to do this, but the fun is in building it yourself.

1
  • In the Feature Class to Shapefile tool, it is designed for exporting multiple features and does not allow for renaming the output shapefile. (it can export one feature however it is still in the same multi-feature format and doesn't have a rename option) :( May 22, 2012 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.