|
POST
|
Thank you all. First of all, The file for the FTP server I have checked is no longer there or may have been moved; however, I tweaked and change to a different file to test it. The script is working now . If you compare the scripts I post earlier and the change I made.... I would like to Thank to Owen Earley for pointing me to the missing "else". That worked ! # Import modules
import ftplib
import os
import socket
from ftplib import FTP
HOST = "ftp.nifc.gov"
DIRN = "Incident_Specific_Data/ALASKA/DataRequests/"
FILE = "AK_UIA_polygon_data.gdb.zip"
# Create a block to connection or not
try:
f = ftplib.FTP(HOST)
except (socket.error, socket.gaierror), e:
print "ERROR: cannot reach" % HOST
else:
print '"***Connected to host "%s"' % HOST
# to log in anonymously
try:
f.login()
except ftplib.error_perm:
print "ERROR: cannot login anonymously"
f.quit()
else:
print '***Logged in as anonymous'
# To change to the directory in DIRN
try:
f.cwd(DIRN)
except ftplib.error_perm:
print 'ERROR: cannot CD to" "%s' % DIRN
f.quit()
else:
print '***Changed to "%s" folder' % DIRN
# Use the FTP Directory to retrieve KMZ
try:
f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write)
except ftplib.error_perm:
print "ERROR: cannot read file" % FILE
os.unlink(FILE)
else:
print "***Downloaded %s to CWD" % FILE
# Disconnect from FTP
f.quit()
... View more
03-15-2015
04:29 PM
|
0
|
0
|
3919
|
|
POST
|
# Import moduels
import ftplib
import os.path
from ftplib import FTP
HOST = 'ftp.nifc.gov'
DIRN = '/incident_Specific_Data/ALASKA/Fire_Perimeters/20090805_1500'
FILE = 'FirePerimeters_20090805_1500.kmz'
# Create a block to connection or not
try:
f = ftplib.FTP(HOST)
except (socket.error, socket.gaierror), e:
print 'ERROR: cannot reach "%s"' % HOST
print '*** Connected to host "%s"' % HOST
# to log in anonymously
try:
f.login()
except ftplib.error_perm:
print 'ERROR: cannot login anonymously'
f.quit()
print '*** Logged in as "anonymous"'
# To change to the directory in DIRN
try:
f.cwd(DIRN)
except ftplib.error_perm:
print 'ERROR: cannot CD to "%s"' % DIRN
f.quit()
print '*** Changed to "%s" folder' % DIRN
# Use the FTP Directory to retrieve KMZ
try:
f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write)
except ftplib.error_perm:
print 'ERROR: cannot read file "%s"' % FILE
os.unlink(FILE)
else:
print '*** Downloaded "%s" to CWD' % FILE
# Disconnect from FTP
f.quit() Here is the full code Thanks.
... View more
03-15-2015
10:40 AM
|
0
|
4
|
3919
|
|
POST
|
# Use the FTP Directory to retrieve KMZ
try:
f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write)
except ftplib.error_perm:
print 'ERROR: cannot read file "%s"' % FILE
os.unlink(FILE)
else:
print '*** Downloaded "%s" to CWD' % FILE
Do they seem right to you ? This is from the book Programming ArcGIS 10.1 with Python cookbook. When I ran it in Pyscripter 2.5.3.0 and it gave me the error : Traceback (most recent call last): File "C:\ArcpyBook\Appendix2\ftp.py", line 45, in <module> f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write) File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 398, in retrbinary self.voidcmd('TYPE I') File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 248, in voidcmd self.putcmd(cmd) File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 178, in putcmd self.putline(line) File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 173, in putline self.sock.sendall(line) AttributeError: 'NoneType' object has no attribute 'sendall'
... View more
03-15-2015
09:43 AM
|
0
|
6
|
8730
|
|
POST
|
While this is a good tempting to use it on your personal computer it is a good to have; however my computer is under the Government so we are not allowed to download these programs on them. We were able to recovery it by requesting our IT department to restore it.
... View more
03-14-2015
08:03 PM
|
1
|
0
|
1646
|
|
POST
|
Do you have a good website that give the examples ?
... View more
03-14-2015
10:09 AM
|
0
|
1
|
6596
|
|
POST
|
What does it mean hardcorded ? I am trying to get a grasp of what it means ? Thanks
... View more
03-14-2015
09:27 AM
|
0
|
9
|
10351
|
|
POST
|
I am not sure if you are aware that there is another good site for you to read... it is called GIS Stackexchange where everyone share their GIS problems. I looked it up for your similiar situation and found a lot of good information... The website is Geographic Information Systems Stack Exchange Type Mosaic Dataset Good luck.
... View more
03-09-2015
08:11 AM
|
0
|
1
|
814
|
|
POST
|
@Dan Patterson Sorry, this code came from the book I am working on from Eric Pimpler's ebook "Programming ArcGIS 10.1 with Python cookbook. That book was in 2013 Yes I find a lot of errors in that book however I tried to tweak some of the codes but was not able to figure it out and I thought there must be a way around to correct it..
... View more
03-08-2015
09:12 PM
|
0
|
1
|
2499
|
|
POST
|
You should be able to use this method... might want to look at here Image Management Workflows | ArcGIS Resource Center Honestly, it is an awkward workflow but I had to work on it for many hours until I understand how it works... Like I said I did work on NAIP for New Mexico and i was able to get it right..it took me to figure it out about three days... I have asked others here on the GeoNet and only few people repsond me back... Do you have background in Erdas or Envi ?
... View more
03-08-2015
09:08 PM
|
0
|
3
|
2197
|
|
POST
|
Before I ask you further, how many aerial images and what will you be using them for ?
... View more
03-08-2015
08:58 PM
|
0
|
5
|
2197
|
|
POST
|
import arcpy, sys
workspace = sys.argv[1]
featureclass = sys.argv[2]
try:
arcpy.env.workspace = workspace
fields = arcpy.ListFields(featureclass)
for fld in fields:
print fld
except:
print arcpy.GetMessages()
The error I am getting is : >>> Traceback (most recent call last): File "C:\ArcpyBook\Appendix1\ListFields.py", line 3, in <module> workspace = sys.argv[1] IndexError: list index out of range >>>
... View more
03-08-2015
03:15 PM
|
0
|
5
|
6182
|
|
POST
|
Hi friend, Have you consider using Mosaic Dataset ? I'd start working with two first and then add two more to give you an idea. More information can be found here :ArcGIS Help 10.1 I just worked on this with NAIP I am working on for the whole state of New Mexico 2009, 2011,2012, and 2014.
... View more
03-07-2015
08:41 AM
|
0
|
7
|
2197
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a week ago | |
| 1 | 04-08-2026 10:11 AM | |
| 1 | 09-01-2022 03:43 PM | |
| 1 | 09-28-2020 09:34 AM | |
| 2 | 09-24-2025 09:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|