|
POST
|
I did the same thing what you suggest. I can try and run it from Python window but Pyscripter should be able to recongize it. Can I run this script from Pyscripter rather than in python window ?
... View more
02-09-2015
10:56 AM
|
0
|
1
|
2065
|
|
POST
|
Here you go: mport arcpy.mapping, os mxd = arcpy.mapping.MapDocument (r"E:\workspace\Test.mxd") arcpy.env.workspace = r"E:/workspace/images/" df = arcpy.mapping.ListDataFrames(mxd)[0] df.scale = 40000 gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0] arcpy.SelectLayerByAttribute_management(gridlayer, "NEW_SELECTION") for row in arcpy.SearchCursor(gridlayer): df.panToExtent(row.shape.extent) arcpy.RefreshActiveView() filename = "E:/workspace/images/" + \ str(row.getValue("PageNumber")).zfill(4) + ".tif" arcpy.mapping.ExportToTIFF(mxd, filename, df, df_export_width= 65000, df_export_height=30000,geoTIFF_tags=True) ## arcpy.mapping.ExportToTIFF(mxd, filename, df, df_export_width= 1280, \ ## df_export_height=440, geoTIFF_tags=True) print arcpy.GetMessages()
... View more
02-09-2015
10:33 AM
|
0
|
3
|
2065
|
|
POST
|
I am having an syntax error from Pyscripter here and not sure why but I have a shapefile at the top of the TOC list which is the first and should be number zero when writing a listlayers as a zero but I still get the error . The error is : Traceback (most recent call last): File "C:\Student\python\GeoTIFF.py", line 16, in <module> gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0] IndexError: list index out of range Take a look here the sytanx:: gridlayer = arcpy.mapping.ListLayers(mxd,'JERGRIDINDEX', df,)[0]
... View more
02-09-2015
10:13 AM
|
0
|
13
|
6442
|
|
POST
|
I have a question about Pyscripter in which I am trying to understand. Suppose if I set up a script within Pycripter and hit the run button to check for any errors. You know if you copy the script from somewhere and paste it in Pyscripter and run it and sometimes Pyscripter does not understand but if you save it and load it in Python Window it would run fine. Why are they both different ? Here is the example: Traceback (most recent call last): File "C:\workspace\GeoTIFF.py", line 12, in <module> mxd = arcpy.mapping.MapDocument("CURRENT") NameError: name 'arcpy' is not defined I understand that the error is because Pyscripter does not understand CURRENT because it is the way that Python window understands it. Message was edited by: Robert Pollock
add the e after past = paste
... View more
02-08-2015
09:28 AM
|
0
|
1
|
4587
|
|
POST
|
Okay I finally figured it out ! Apparently the book on Chapter 7 has some errors in it as I was trying to work on them in Pyscripter and Python Window and got it worked ! This HAS nothing to do with the del cur I had to re-read the instructions and found that the chapter mention to delete two hardcoded THAT should be include in the python script ! phew ! This is the correct coding. #Script to Import data to a feature class within a geodatabase import arcpy, os arcpy.env.workspace = "C:/ArcpyBook/data/Wildfires/WildlandFires.mdb" f = open("C:/ArcpyBook/data/Wildfires/NorthAmericaWildfires_2007275.txt", "r") cur = arcpy.InsertCursor("FireIncidents") try: # the output feature class name outputFC = arcpy.GetParameterAsText(0) # the template feature class that defines the attribute schema fClassTemplate = arcpy.GetParameterAsText(1) #Open the file to read f = open(arcpy.GetParameterAsText(2), 'r') arcpy.CreateFeatureclass_management(os.path.split(outputFC)[0],os.path.split(outputFC)[1],"POINT", fClassTemplate) lstFires = f.readlines() cur = arcpy.InsertCursor(outputFC) cntr = 1 for fire in lstFires: if 'Latitude' in fire: continue vals = fire.split(",") latitude = float(vals[0]) longitude = float(vals[1]) confid = int(vals[2]) pnt = arcpy.Point(longitude, latitude) feat = cur.newRow() feat.shape = pnt feat.setValue("CONFIDENCEVALUE", confid) cur.insertRow(feat) arcpy.AddMessage("Record number " + str(cntr) + "written to feature class") cntr = cntr + 1 except: print arcpy.GetMessages() finally: del cur f.close()
... View more
02-07-2015
08:04 AM
|
0
|
0
|
2037
|
|
POST
|
Where do I find this information in an IDE ? Would Pyscripter show the avaiable variable to replace the cur ?
... View more
02-06-2015
08:19 PM
|
0
|
1
|
2037
|
|
POST
|
Thank you. That is what I thought so. Does that mean ESRI took out the cur sytanx ? Ok, I will look into that as what you suggest. I have googled it as well but did not find it. I tried cursor and it came back an error...
... View more
02-06-2015
02:35 PM
|
0
|
1
|
2037
|
|
POST
|
This is what I wrote from the book Programming ArcGIS 10.1 with Python Cookbook wrote by Eric Pimper and it is on Chapter 7th. #Script to Import data to a feature class within a geodatabase import arcpy, os arcpy.env.workspace = "C:/ArcpyBook/data/Wildfires/WildlandFires.mdb" f = open("C:/ArcpyBook/data/Wildfires/NorthAmericaWildfires_2007275.txt", "r") try: # the output feature class name outputFC = arcpy.GetParameterAsText(0) # the template feature class that defines the attribute schema fClassTemplate = arcpy.GetParameterAsText(1) #Open the file to read f = open(arcpy.GetParameterAsText(2), 'r') arcpy.CreateFeatureclass_management(os.path.split(outputFC)[0], os.path(outputFC)[1]), "point", (fClassTemplate) lstFires = f.readlines() cur = arcpy.InsertCursor(outputFC) cntr = 1 for fire in lstFires: if 'Latitude' in fire: continue vals = fire.split(",") latitude = float(vals[0]) longitude = float(vals[1]) confid = int(vals[2]) pnt = arcpy.Point(longitude, latitude) feat = cur.newRow() feat.shape = pnt feat.setValue("CONFIDENCEVALUE", confid) cur.insertRow(feat) arcpy.AddMessage("Record number" + str(cntr) + "written to feature class") cntr = cntr + 1 except: print arcpy.GetMessages() finally: del cur f.close() The error showed here Traceback (most recent call last): File "C:\ArcpyBook\Ch7\InsertWildfires.py", line 34, in <module> del cur NameError: name 'cur' is not defined
... View more
02-06-2015
02:24 PM
|
0
|
7
|
6105
|
|
POST
|
Is that for shapefiles only ? What about geodatabases ?
... View more
02-05-2015
01:59 PM
|
0
|
1
|
2004
|
|
POST
|
Is there a way for me to run a tool or script to call how many vertices of a file geodatabase polygon ?
... View more
02-05-2015
12:31 PM
|
0
|
5
|
6012
|
|
POST
|
Hi all , I am trying to write a code how to retrieve imagery from the server as a add data however I am not sure using the "layer" is the right word to call it. Writing in Pyscripter showed me the syntax check is ok however; it brings up another error saying Runtime Error: Object.Create Object cannot open map document (_base.py) What I am trying to do here is to have MapDocument open and run the script to call and add the imagery to ArcMap without having to manually add them . import arcpy, os import arcpy.mapping as mapping mxd = mapping.MapDocument("CURRENT") df = mapping.ListDataFrames(mxd) layer = mapping.Layer(r"S\Las Cruces SSO\NAIP_2009") mapping.AddLayer(df,layer,"AUTO_ARRANGE") del mxd
... View more
01-29-2015
10:53 AM
|
0
|
0
|
3801
|
|
POST
|
Xander Bakker - Yes, I've explored the Pyscripter and read the information right before you answered my question. Now, I can see why the difference between the two. Now I can see why how cool Pyscripter is !!!!
... View more
01-25-2015
02:27 PM
|
0
|
1
|
685
|
|
POST
|
One more other question. Which one should i write the code in the Pyscripter ? The python interpreter below or the top with the module ?Xander Bakker
... View more
01-25-2015
01:57 PM
|
0
|
3
|
685
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-01-2022 03:43 PM | |
| 1 | 09-28-2020 09:34 AM | |
| 2 | 09-24-2025 09:48 AM | |
| 1 | 09-22-2025 08:29 AM | |
| 1 | 09-17-2025 12:58 PM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|