POST
|
Works for me. I just realised I left in some code I shouldn't have. Try the below (also attached):. nirs=samples[*,*,7]
nird=data[*,*,7]
d=size(nirs,/dim)
i=where(nirs gt 0)
o=where(nird eq 0)
m=min(nirs)
out=0
help, m
foreach b, bindgen(6) do begin
band=samples[*,*,b]
r=linfit(nirs,band)
band=data[*,*,b]
deglint=long(band - r[1] * (nird - m)+0.5)
deglint =0
if size(out, /n_dimensions) eq 0 then $ ;Image stack doesn't exist yet
out=temporary(deglint) $
else $ ;Concatenate image to stack
out=[[[temporary(out)]],[[temporary(deglint)]]]
endforeach
out=[[[temporary(out)]],[[data[*,*,6]]]]
out=[[[temporary(out)]],[[data[*,*,7]]]]
end
An example using the above code: Before [ATTACH=CONFIG]11237[/ATTACH] After [ATTACH=CONFIG]11238[/ATTACH]
... View more
01-17-2012
01:02 PM
|
0
|
0
|
1198
|
POST
|
Perhaps try the eval function (I haven't tested this): expression = '(Raster(inRaster1) < var1[0]) & (Raster(inRaster2) > var1[1]) & (Raster(inRaster3) <> var1[2]) & (Raster(inRaster4) == var1[3])'
NewRaster=eval(expression)
... View more
01-16-2012
03:02 PM
|
0
|
0
|
304
|
POST
|
Search and ye shall find 😉 http://forums.arcgis.com/threads/14660-Export-raster-statistics?p=74505
... View more
01-16-2012
02:40 PM
|
0
|
0
|
244
|
POST
|
It requires a full ENVI+IDL install, not just the ENVI runtime. It also requires you have enough memory to load the entire image into RAM as I didn't bother writing any sort of tiling code, it was just a very rough hack that I whipped up to meet an immediate need. To use my code: Save the code to a file with a ".pro" extension Start "ENVI + IDL" (not ENVI) Load your WV2 image into ENVI. In the main ENVI toolbar click File-> Export to IDL variable and export the WV2 as variable called "data" Create an ROI of a variety of deep ocean areas In the ROI tool dialog, select File->Subset data via ROIs In the main ENVI toolbar click File-> Export to IDL variable and export the subset as variable called "samples" At the ENVI> command prompt in the IDL workbench, type .r <path to>\<script>.pro i.e .r C:\Temp\deglint.pro After the script completes you can get the image back into ENVI using File-> Import from IDL variable (select the "out" variable)
... View more
01-15-2012
03:35 PM
|
0
|
0
|
1198
|
POST
|
Have a read of this paper: Hedley et al. (2005) Simple and robust removal of sun glint for mapping shallow-water benthos. International Journal of Remote Sensing Vol. 26, No. 10, 2107�??2112. Step by step instructions to implement this method are available for ENVI (not ArcGIS sorry). I use some IDL code from ENVI to do this instead of the above manual method, though I do generate the samples with the ROI tool by hand):
nirs=samples[*,*,7]
nird=data[*,*,7]
d=size(nirs,/dim)
i=where(nirs gt 0)
o=where(nird eq 0)
m=min(nirs)
m=nirs
m = m[(sort(m))[5 * N_ELEMENTS(m) / 100] ]
out=0
help, m
foreach b, bindgen(6) do begin
band=samples[*,*,b]
r=linfit(nirs,band)
band=data[*,*,b]
deglint=long(band - r[1] * (nird - m)+0.5)
deglint =0
if size(out, /n_dimensions) eq 0 then $ ;Image stack doesn't exist yet
out=temporary(deglint) $
else $ ;Concatenate image to stack
out=[[[temporary(out)]],[[temporary(deglint)]]]
endforeach
out=[[[temporary(out)]],[[data[*,*,6]]]]
out=[[[temporary(out)]],[[data[*,*,7]]]]
end
Again note that these methods are for ENVI, not ArcGIS. You could probably reimplement the code in numpy though.
... View more
01-12-2012
01:16 PM
|
0
|
0
|
1198
|
POST
|
For "general slope and aspect" I'd generate an elevation trend surface from your DEM (masked to your polygon): Clip and mask your DEM to the polygon then convert the masked DEM to points, or... Create Random Points constrained by your landslide polygon which you can use to sample the elevation values. Then Generate the elevation trend surface from those points and then calculate slope and aspect from that. Repeat 300 times (batch or script)
... View more
01-12-2012
12:21 PM
|
0
|
0
|
321
|
POST
|
Replace python.exe with pythonw.exe in your subprocess call. Pythonw is a non-console version of the python executable.
... View more
12-28-2011
11:17 AM
|
0
|
0
|
252
|
POST
|
Does your internet connection pass through a proxy that requires authentication? The MODIS Import Tool uses the python urllib module to download the images. The urllib documentation notes that: Proxies which require authentication for use are not currently supported; this is considered an implementation limitation.
... View more
12-26-2011
11:39 AM
|
0
|
0
|
240
|
POST
|
Just make two copies of the parameter variable. >>> param1a=param1b=arcpy.GetParameterAsText(1)
>>> print param1a
Some Parameter
>>> print param1b
Some Parameter
>>> print param1a==param1b
True
>>> param1a='Something else'
>>> print param1a==param1b
False
... View more
12-19-2011
02:37 PM
|
0
|
0
|
215
|
POST
|
fieldvalue=' '.join(fieldvalue.strip().split())
#in case fieldvalue=='', change empty string to space to avoid "Field is not Nullable" error
if not fieldvalue: fieldvalue=' '
... View more
12-19-2011
10:43 AM
|
0
|
0
|
2409
|
POST
|
It is better practice to store the return value from a function/method in a variable if you are going to use it more than once rather than repeatedly calling the function method. param1=arcpy.GetParameterAsText(1)
for i in range(10):
if i >=param1: #eg use a variable instead of calling GetParameterAsText 10x
dosomething()
... View more
12-19-2011
10:12 AM
|
0
|
0
|
215
|
POST
|
Do I loop for rows and cols? Depends on the type of raster you are using. Some rasters are tiled internally and it is much more efficient to access by tiles or blocks. Geodatabase rasters have 128x128 pixel tiles (by default), GRIDS are 256x4 (col then row), tiffs can be tiled or untiled (safest to process one row at a time). Here is some code to process by tile (the commented out stuff is arcpy related that I can't test as I'm not at back work until January). ncols=67000
nrows=58000
cellsize=2
xmin=0
ymax=58000
## ^^ Get all this info from your original raster
tile_size=(128,128) #GDB rasters=(128,128), tif=(ncols,1), GRID=(256,4)
ntiles = 4 #no. of tiles to process at a time
#arcpy.env.Extent=in_raster
#arcpy.env.outputCoordinateSystem=in_raster
#arcpy.env.cellSize=in_raster
#new_raster=arcpy.CreateRasterDataset(out_path, out_name, cellsize, pixel_type,
# spatial_reference)
for row in range(0,nrows,tile_size[1]):
for col in range(0,ncols,tile_size[0]*ntiles):
colend=min([ncols,col+tile_size[0]*ntiles-1])
rowend=min([nrows,row+tile_size[1]-1])
xstart=xmin+(cellsize*col)
ystart=ymax-(cellsize*(rowend+1))
print 'Processing cols',col,':',colend
print 'Processing rows',row,':',rowend
print 'Extracting lower left corner:',xstart,ystart
#array=RasterToNumPyArray (in_raster, arcpy.Point(xmin,ystart), ncols, step)
#Do your processing
#out_raster=NumPyArrayToRaster(array, arcpy.Point(xmin,ystart), cellsize, cellsize)
#arcpy.Mosaic_management(out_raster,new_raster)
... View more
12-18-2011
12:13 PM
|
0
|
0
|
1597
|
POST
|
Sorry, I'm not at work so don't have access to ArcGIS to test an example. I think the mosaic tool will do what you need though: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Mosaic_To_New_Raster/001700000098000000/ or http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000097000000
... View more
12-17-2011
12:14 PM
|
0
|
0
|
1597
|
POST
|
You can specify what part of the raster to extract to a numpy array - RasterToNumPyArray(in_raster, lower_left_corner, ncols, nrows). http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/NumPyArrayToRaster/000v00000130000000/ So you could loop through and process a few rows at a time.
... View more
12-17-2011
01:53 AM
|
0
|
0
|
1596
|
POST
|
That's because your raster is too big to fit in memory. A 67000*58000 (1 band) 8 bit raster is 4GB, 16 bit is 7GB and 32 bit is 14GB... If you must use numpy, you will have to clip out smaller sections/tiles of your raster, convert to numpy array, process each tile separately and then convert back to raster and mosaic. Looking at the commented out section of your code, you don't need to use numpy at all, all those operations can be done in spatial analyst map algebra.
... View more
12-16-2011
12:07 PM
|
0
|
0
|
1596
|
Title | Kudos | Posted |
---|---|---|
1 | 4 weeks ago | |
1 | 07-11-2022 05:26 PM | |
3 | 02-19-2024 01:54 PM | |
1 | 12-11-2023 01:05 PM | |
1 | 12-11-2023 01:10 PM |