|
POST
|
Hi Meredith, Are you receiving any errors? When you create the new field, are you creating it as a "TEXT" field? If it is a Long Integer, Short Integer, or Double try the following w/o the quotes around the value: def Reclass(variable1):
if variable1 == 2:
return "50pct"
....
... View more
11-25-2013
10:02 AM
|
0
|
0
|
2048
|
|
POST
|
Yes, the transformation is handled by the env variable arcpy.env.geographicTransformations. This is a semicolon delimited string, so you can specify multiple transformations if needed. Ex: arcpy.env.geographicTransformations = "Arc_1950_To_WGS_1984_5; PSAD_1956_To_WGS_1984_6"
... View more
11-25-2013
08:39 AM
|
0
|
0
|
1457
|
|
POST
|
Hi Michael, You could perform the following: outCS = arcpy.SpatialReference("NAD 1983 StatePlane Pennsylvania South FIPS 3702 (US Feet)")
arcpy.env.geographicTransformations = "NAD_1983_To_WGS_1984_1"
arcpy.Project_management(fc, fc + "_project", outCS)
... View more
11-25-2013
08:18 AM
|
0
|
0
|
1457
|
|
POST
|
Hi Francesco, Remove the underscores in the spatial reference name. Try the following: outCS = arcpy.SpatialReference('WGS 1984 UTM Zone 32N')
... View more
11-25-2013
07:04 AM
|
0
|
0
|
1457
|
|
POST
|
Hi Scott, You can use the 'Copy Raster' tool to extract a single band from a raster dataset. You just need to specify the band after the raster name. Ex: C:\DATA\RASTER\TIFF\aerial2013.tif\Band_1
... View more
11-25-2013
07:00 AM
|
0
|
0
|
2531
|
|
POST
|
Hi Emil, The arcpy.ListDatasets function will list the feature datasets in your geodatabase. If you are looking to create a list of all the feature classes in your geodatabase, try the following: arcpy.env.workspace = "C:\E1B8\Grid_Create_Update_11-2013\CalcMiles.gdb"
fcList = []
#list feature classes in feature datasets
for dataset in arcpy.ListDatasets("*"):
for fc in arcpy.ListFeatureClasses("*", "", dataset):
fcList.append(fc)
#list stand alone feature classes
for fc in arcpy.ListFeatureClasses("*"):
fcList.append(fc)
print fcList
... View more
11-25-2013
06:00 AM
|
0
|
0
|
1644
|
|
POST
|
Hi Peter, Here is some code that zooms to each point, creates a polygon feature class from the extent, then converts the polygon to a raster in a new directory. The code then copies the original photo to the new directory (overwriting the raster previously created), so that it can use the coordinate information, and then defines the projection of the rasters. If you need to change the size of the raster, you can try adding in the Rescale function. import arcpy
from arcpy import env
from arcpy import mapping
env.overwriteOutput = 1
mxd = mapping.MapDocument(r"C:\temp\python\Points.mxd")
df = mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd)[0]
# Create new photo directory
newPhoto = r"C:\Temp\Python\Photos\New Photos"
dict = {}
# Create dictionary of OBJECTIDs and the path to the photo
with arcpy.da.SearchCursor(lyr, ["OBJECTID", "PHOTO"]) as cursor:
for row in cursor:
rasterName = row[1].split("\\")[-1]
dict[row[0]] = rasterName
firstTime = "True"
# Select each point, zoom/pan to the selected point, create a polygon feature class from extent,
# convert polygon to raster dataset
for key in dict:
if firstTime == 'True':
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "OBJECTID = " + str(key))
df.extent = lyr.getSelectedExtent()
XMAX = df.extent.XMax
XMIN = df.extent.XMin
YMAX = df.extent.YMax
YMIN = df.extent.YMin
pnt1 = arcpy.Point(XMIN, YMIN)
pnt2 = arcpy.Point(XMIN, YMAX)
pnt3 = arcpy.Point(XMAX, YMAX)
pnt4 = arcpy.Point(XMAX, YMIN)
array = arcpy.Array()
array.add(pnt1)
array.add(pnt2)
array.add(pnt3)
array.add(pnt4)
array.add(pnt1)
polygon = arcpy.Polygon(array)
arcpy.CopyFeatures_management(polygon, r"IN_MEMORY\polygon")
arcpy.PolygonToRaster_conversion(r"IN_MEMORY\polygon", "OID", r"IN_MEMORY\raster")
arcpy.CopyRaster_management(r"IN_MEMORY\raster", newPhoto + "\\" + dict[key])
firstTime = "False"
else:
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "OBJECTID = " + str(key))
df.panToExtent(lyr.getSelectedExtent())
XMAX = df.extent.XMax
XMIN = df.extent.XMin
YMAX = df.extent.YMax
YMIN = df.extent.YMin
pnt1 = arcpy.Point(XMIN, YMIN)
pnt2 = arcpy.Point(XMIN, YMAX)
pnt3 = arcpy.Point(XMAX, YMAX)
pnt4 = arcpy.Point(XMAX, YMIN)
array = arcpy.Array()
array.add(pnt1)
array.add(pnt2)
array.add(pnt3)
array.add(pnt4)
array.add(pnt1)
polygon = arcpy.Polygon(array)
arcpy.CopyFeatures_management(polygon, r"IN_MEMORY\polygon")
arcpy.PolygonToRaster_conversion(r"IN_MEMORY\polygon", "OID", r"IN_MEMORY\raster")
arcpy.CopyRaster_management(r"IN_MEMORY\raster", newPhoto + "\\" + dict[key])
del mxd
# Clear the selection
arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")
list = []
with arcpy.da.SearchCursor(lyr, ["PHOTO"]) as cursor:
for row in cursor:
list.append(row[0])
# Copy original photo to the new photo directory, replacing the raster created previously
for photo in list:
shutil.copy(photo, newPhoto)
spatial_ref = arcpy.Describe(lyr).spatialReference
# Project each raster
env.workspace = newPhoto
for raster in arcpy.ListRasters("*"):
arcpy.DefineProjection_management(raster, spatial_ref)
... View more
11-25-2013
04:07 AM
|
0
|
0
|
870
|
|
POST
|
Have you considered using a mosaic dataset? A mosaic dataset will allow to quickly catalog your imagery and view it as a seamless mosaic. This will cut your processing time from hours to seconds/minutes.
... View more
11-22-2013
06:10 AM
|
0
|
0
|
927
|
|
POST
|
Can you paste the code you are using? Don't forget to enclose it in CODE tags.
... View more
11-21-2013
06:56 AM
|
0
|
0
|
2150
|
|
POST
|
Hi Joe, The end result will not be what you are looking for. The workflow I provided will only work when the vertices Z values are the same for each line segment. For example, segment one has two vertices and each have an elevation of 37. Since each of your line's vertices are different, the buffer output will have a constant Z value for each vertex based on whether you calculated the min or max elevation for the line shapefile. Attached are the results that you can view in ArcScene.
... View more
11-21-2013
04:09 AM
|
0
|
0
|
2517
|
|
POST
|
Joe, No, the 'r' after the = sign for the env.workspace is not a typo. See here for an explanation. The script will update the original feature class. Would you be able to zip and upload a small sample of your data?
... View more
11-20-2013
05:37 AM
|
0
|
0
|
2517
|
|
POST
|
Yes, you will just need to change the 'shp' variable to the path of your feature class in the MDB. Ex: shp = r"c:\data\mydb.mdb\<feature class name>" You will not want to end the feature class name with a .shp since it is not a shapefile.
... View more
11-20-2013
03:19 AM
|
0
|
0
|
3189
|
|
POST
|
Hi Sachin, Make sure you have the height set to 100% for the <div> containing the map. Example of CSS file: #divMap{
height: 100%;
width: 100%;
} Example of HTML file: <div id="divMap" style="height:100%; width:100%;"></div>
... View more
11-19-2013
11:39 AM
|
0
|
0
|
2150
|
|
POST
|
What type of geodatabase are you using (File, Personal, SDE)? How many feature classes are you working with? One option is to use the Feature Class to Geodatabase tool and within the Environments, set the Z value to 'Disabled'. You could then run this tool again and set the Z value to 'Enabled'. This will write all of the feature classes to a new geodatabase with all Z values set to 0. However, if you have a large geodatabase, need to maintain versioning in SDE, feature classes participate in a replication/topology/network, this will not be practical.
... View more
11-19-2013
07:44 AM
|
0
|
0
|
2293
|
|
POST
|
Hi Emil, When using the 'Select Layer by Attribute' or 'Select Layer by Location' functions, the input needs to a be a layer. Use the MakeFeatureLayer_management function to do this. Ex:
arcpy.MakeFeatureLayer_management("CityGrids.shp", "cityGridsLyr")
arcpy.SelectLayerByLocation_management("cityGridsLyr", "INTERSECT", "thecity", "", "NEW_SELECTION")
... View more
11-19-2013
06:48 AM
|
1
|
0
|
3024
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a month ago | |
| 4 | 05-07-2020 05:14 PM | |
| 1 | 03-25-2026 04:16 AM | |
| 1 | 03-16-2026 01:00 PM | |
| 1 | 12-22-2025 10:39 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|