|
POST
|
Hi Chris, How do you determine which raster needs to be subtracted from which? Do the rasters have identical names in each directory?
... View more
11-17-2011
02:13 AM
|
0
|
0
|
3392
|
|
POST
|
You can edit the fields 'XOffset', 'YOffset', and 'Angle'. The X/YOffset field will adjust the position, and the Angle field will adjust the rotation.
... View more
11-16-2011
10:57 AM
|
1
|
0
|
729
|
|
POST
|
Are you working with an XY Event layer (ie right-click on spreadsheet > Display XY Data)? You can export the event layer to a feature class/shapefile by right-clicking on the event layer > Data > Export Data. Then you can edit the feature class/shapefile. When editing, right-click with the edit tool in the data view and you will see 'Absolute XY'. You can enter the coordinates here and the point will be added.
... View more
11-16-2011
03:32 AM
|
0
|
0
|
788
|
|
POST
|
Hi Chris, Are you looking to subtract one raster from 724 other rasters? You can accomplish this using a python script. Below is an example: import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\Rasters"
arcpy.CheckOutExtension("spatial")
lstRasters = arcpy.ListRasters("*")
for raster in lstRasters:
outMinus = arcpy.sa.Minus(raster, r"C:\data\raster\TIFF\example1.tif")
outMinus.save(r"C:\temp\python\Rasters" + "\\" + raster + "_minus.tif")
print "Successfully subtracted raster" What the above script is doing is selecting all rasters within the 'env.workspace' directory. Then it is subtracting the 'C:\data\raster\TIFF\example1.tif' raster from each one, and finally saving the new raster to the 'C:\temp\python\Rasters' directory with '_minus.tif' appended to the original name.
... View more
11-16-2011
02:47 AM
|
0
|
0
|
3392
|
|
POST
|
You can create a feature layer from the 'rasterfile' with a query specifying '"VALUE" = 1'. Then clip the points from the feature layer rather than the rasterfile.
... View more
11-16-2011
02:00 AM
|
0
|
0
|
1097
|
|
POST
|
Hi Kendra, I too get confused with syntax for queries, especially for fields. You can refer to the following link for help with syntax: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm
... View more
11-15-2011
07:42 AM
|
0
|
0
|
1454
|
|
POST
|
Hi Anthony, Here is an example on how to do this. What the script does is iterate through a shapefile called 'Grid' and adjusts the MXDs extent to each feature in the GRID shapefile, and then exports the map to a JPG based on that extent import arcpy
from arcpy import env
from arcpy import mapping
env.workspace = r"C:\temp\python"
mxd = mapping.MapDocument(r"C:\DATA\Philadelphia.mxd")
fc = "GRID.shp"
count = str(arcpy.GetCount_management(fc))
x = 1
while x < int(count) + 1:
rows = arcpy.SearchCursor(fc, "OID = " + str(x))
for row in rows:
xmin = row.shape.extent.XMin
ymin = row.shape.extent.YMin
xmax = row.shape.extent.XMax
ymax = row.shape.extent.YMax
df = arcpy.mapping.ListDataFrames(mxd)[0]
newExtent = df.extent
newExtent.XMin, newExtent.YMin = xmin, ymin
newExtent.XMax, newExtent.YMax = xmax, ymax
df.extent = newExtent
mapping.ExportToJPEG(mxd, r"C:\temp\python\JPEG_" + str(x) + ".jpg")
print "successfully printed JPG"
x += 1
... View more
11-14-2011
10:04 AM
|
1
|
10
|
2460
|
|
POST
|
Hi Bjorn, You could automate the procedure of finding which zone each raster falls in. Each install of ArcGIS includes reference data in the directory 'C:\Program Files (x86)\ArcGIS\Desktop10.0\Reference Systems'. There is a UTM.shp located here and you can use this to determine each zone for each TIFF. Here is an example on how to do this: import arcpy
from arcpy import env
env.overwriteOutput = True
prjFile = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"
spatRef = arcpy.SpatialReference(prjFile)
# list each raster and extract coordinates
env.workspace = r"C:\temp\python\rasters"
lstRasters = arcpy.ListRasters("*", "TIF")
for ras in lstRasters:
rasName = ras.split('.')[0]
lat_lon = rasName.split('_')[1]
if 'N' in lat_lon:
lat = int(lat_lon[1:3])
else:
lat = int(lat_lon[1:3]) * -1
if 'W' in lat_lon:
lon = int(lat_lon[4:]) * -1
else:
lon = int(lat_lon[4:])
# Create a point based on the coordinate values
point = arcpy.Point(lon, lat)
UTMfc = r"C:\TEMP\Python\UTM.shp"
# create an empty point feature class with a field called 'Name'
env.workspace = r"C:\temp\python\test.gdb"
arcpy.CreateFeatureclass_management(env.workspace, "LatLon", "POINT", "", "", "", spatRef)
arcpy.AddField_management("LatLon", "Name", "TEXT")
# Populate the feature class with the coordinate value and the raster name
rows = arcpy.InsertCursor("LatLon")
row = rows.newRow()
row.Name = rasName
row.Shape = point
rows.insertRow(row)
del row, rows
# Perform an intersect to find which zone the raster falls in
arcpy.Intersect_analysis(["LatLon", UTMfc], "Intersect", "", "", "POINT")
rows = arcpy.SearchCursor("Intersect")
for row in rows:
print str(row.Name) + " is in zone UTM" + str(row.Zone)
arcpy.Delete_management("LatLon")
arcpy.Delete_management("Intersect") You could probably append some additional code onto this to project the raster based on the zone it falls within.
... View more
11-14-2011
05:28 AM
|
0
|
0
|
7005
|
|
POST
|
Hi SpringsGirl, I believe your queryString is incorrect. You will want the query to be: "NAME" = 'North Central' instead of "NAME" = "North Central" Try changing your queryString to: queryString = '"' + nameField + '" =' + "'" + currentPatrolZone + "'"
... View more
11-14-2011
01:59 AM
|
0
|
0
|
1454
|
|
POST
|
Hi Luke, You could do something similar to the code below. You will just need to update it for a shapefile rather than a feature class: import arcpy, os
from arcpy import env
env.overwriteOutput = True
env.workspace = r"C:\temp\python\test.gdb"
fc = "Cities"
count = str(arcpy.GetCount_management(fc))
x = 0
y = 1000000
z = 1
while x < int(count):
where = "OBJECTID > " + str(x) + "AND OBJECTID <= " + str(y)
arcpy.MakeFeatureLayer_management(fc, "Cities_FL", where)
arcpy.CopyFeatures_management("Cities_FL", "Cities_" + str(z))
x += 1000000
y += 1000000
z += 1
... View more
11-11-2011
03:46 AM
|
0
|
0
|
806
|
|
POST
|
Hi Lucas, Sorry, I mis-read your previous post. You can update from meters to DD using the 'arcpy.UpdateCursor' function. With cursors, you have the ability to set a working coordinate system. Ex: import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"
fc = "Cities_Meters"
prj = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"
spatRef = arcpy.SpatialReference(prj)
env.geographicTransformations = "NAD_1983_To_WGS_1984_1"
rows = arcpy.UpdateCursor(fc, "", spatRef)
for row in rows:
geom = row.shape
row.POINT_X = geom.centroid.X
row.POINT_Y = geom.centroid.Y
rows.updateRow(row)
del row, rows Since I am switching datums from NAD_83 to WGS_84, I needed to apply a geographic transformation. You will need to update 'row.POINT_X' and 'row.POINT_Y' with the fields you want to store the DD values. Also, here is how you can do this using the field calculator: def func():
fc = "Cities_Meters"
prj = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"
spatRef = arcpy.SpatialReference(prj)
arcpy.env.geographicTransformations = "NAD_1983_To_WGS_1984_1"
rows = arcpy.UpdateCursor(fc, "", spatRef)
for row in rows:
geom = row.shape
return geom.centroid.X func() With the field calculator you will have to run it for each individual field, and change 'geom.centroid.X' to 'geom.centroid.Y' for the appropriate field.
... View more
11-09-2011
02:35 AM
|
0
|
0
|
997
|
|
POST
|
You can create a new field of type text and then run the following within the field calculator: Pre-logic Script Code def dd2DMS(dd):
if dd > 0:
deg = int(dd)
min = int((dd-deg) * 60)
sec = (((dd - deg) * 60) - min) * 60
return str(deg) + " " + str(min) + "' " + "%.4f" % sec + '"'
if dd < 0:
deg = int(dd)
min = int((dd-deg) * 60 * -1)
sec = (((dd - deg) * 60 * -1) - min) * 60
return str(deg) + " " + str(min) + "' " + "%.4f" % sec + '"' [FIELDNAME] = dd2DMS(!POINT_X!)
... View more
11-08-2011
08:13 AM
|
0
|
0
|
997
|
|
POST
|
Can you try using the 'time' module to see if you have any improvement in performance? import arcpy, time
now = time.localtime(time.time())
mxd = arcpy.mapping.MapDocument(r"C:\TaxMapPages_DDP.mxd")
print time.asctime(now)
ddp = mxd.dataDrivenPages
print time.asctime(now)
... View more
11-08-2011
07:17 AM
|
0
|
0
|
2113
|
|
POST
|
You can create another feature layer with the 'where' clause to select the individual county: import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"
env.overwriteOutput = True
county = "Counties"
hospitals = "Hospitals"
# Create feature layers for the selection
arcpy.MakeFeatureLayer_management(county, "county_FL", "POP2000 > 999999")
arcpy.MakeFeatureLayer_management("county_FL", "county_FL2", "NAME = 'CHESTER'")
arcpy.MakeFeatureLayer_management(hospitals, "hospitals_FL")
# Find all hospitals within counties with a population >= 1,000,000
arcpy.SelectLayerByLocation_management("hospitals_FL", "INTERSECT", "county_FL2")
# Create a feature class from the selection
arcpy.CopyFeatures_management("hospitals_FL", "hospitals_selection")
... View more
11-08-2011
04:36 AM
|
0
|
0
|
1025
|
|
POST
|
Hi Peter, It appears that if the raster has any rotation, the columns and rows will include the 'NoDATA' areas which will give you more pixels when multiplying the columns and rows together using the Describe function. You can sum the COUNT field using a Search Cursor and appending the values to another list. The below should work: import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
env.workspace = r"C:\temp\python\rasters"
env.overwriteOutput = True
lstRasters = arcpy.ListRasters("*")
for raster in lstRasters:
outTimes = Times(raster, 100)
outTimes.save(r"C:\temp\python\outTimes.tif")
intRas = Int(r"C:\temp\python\outTimes.tif")
intRas.save(r"C:\temp\python\intRas.tif")
arcpy.BuildRasterAttributeTable_management(r"C:\temp\python\intRas.tif", "Overwrite")
list2 = []
rows = arcpy.SearchCursor(r"C:\temp\python\intRas.tif")
for row in rows:
list2.append(row.getValue("COUNT"))
totalpixels = sum(list2)
list = []
pixValue = 3.25 * 100
rows = arcpy.SearchCursor(intRas, "VALUE > " + str(pixValue))
for row in rows:
list.append(row.Count)
print float(sum(list)) / float(totalpixels)
del row, rows
arcpy.Delete_management(r"C:\temp\python\intRas.tif")
arcpy.Delete_management(r"C:\temp\python\outTimes.tif")
... View more
11-04-2011
02:45 AM
|
0
|
0
|
910
|
| Title | Kudos | Posted |
|---|---|---|
| 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 | |
| 1 | 01-20-2026 04:04 AM |
| Online Status |
Offline
|
| Date Last Visited |
16 hours ago
|