|
POST
|
Are all of your bil files correctly georeferenced and on the WGS84 datum? If so, follow the code template given by Jake above. The WKID for WGS_1984_UTM_Zone_37N is 32637, so, rather than listing the entire text for the projection, I would use the WKID to create a spatial reference object for use in the Project function. Thus :
import arcpy
from arcpy import env
env.workspace = r"Your path to the data here"
srOut = arcpy.SpatialReference(32637)
for raster in arcpy.ListRasters("*.bil"):
arcpy.ProjectRaster_management(raster, raster + "_project.bil", srOut)
See the examples here : http://resources.arcgis.com/en/help/main/10.2/#/Project_Raster/00170000007q000000/ Cheers and good luck, Neil
... View more
01-16-2014
01:27 AM
|
0
|
0
|
3575
|
|
POST
|
There is a GetCellValue function that can be used in python to query values in a raster, but it is quite slow. And there maybe really fast ways of doing this using numpy arrays. But why not use RasterToPoint, then process the resulting point attribute table. Can't remember if R2P will export all 4 bands or if you would have to do each band separately. If the raster is very large, it will of course give you a very large number of points to process. Cheers and good luck, Neil
... View more
01-13-2014
12:29 AM
|
0
|
0
|
2933
|
|
POST
|
If NPP and ZforCDF are rasters on disk, shouldn't they be referenced to Raster objects before all that long calculation? Like :
NPP = arcpy.Raster(r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\LFP_GLOBAL_Python\OUTPUT.gdb\NPP")
etc
... View more
12-24-2013
03:18 AM
|
0
|
0
|
2562
|
|
POST
|
Jon, I think this is a 2 stage process. Make the contours then use 3d analyst / 3d features / Feature to 3d by attribute. The Z value will be "Contour". Then you will have a true polylineZ. Cheers, Neil
... View more
12-20-2013
08:59 PM
|
1
|
0
|
938
|
|
POST
|
Have you tried using print NPPEquation just to see exactly what is being returned by the GetParametersAsText. It should work, but only if NPPEquation is exactly "Min NPP1" Not much, I know but good luck, Neil
... View more
12-20-2013
05:32 AM
|
0
|
0
|
1039
|
|
POST
|
The 3d analyst / Functional Surface / Add surface information tool will take your polyline and add info from a surface. One of the options is "Average slope". You can only add a surface statistic for each feature (like minZ, maxZ, slope etc.) If you need finer control you would probably have to dump the line vertices out to points then add the surface information to that. Good luck, Neil
... View more
12-19-2013
11:36 PM
|
0
|
0
|
1310
|
|
POST
|
You need to project your data from GCS to a flat projected coordinate system. http://resources.arcgis.com/en/help/main/10.2/index.html#//003r0000000q000000 Your biggest problem here will be to select a suitable PCS for your analysis. This will depend on what you are doing with the data. You may have to consider splitting up the data into continental sized bits and projecting each one separately. Cheers, Neil
... View more
12-16-2013
09:05 PM
|
1
|
0
|
8068
|
|
POST
|
James, tested this code :
# test sa.sample
import sys, os, arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
InputFGDB = "c:/Data/ESRI-SA/ArcForums/TestData.gdb"
env.workspace = InputFGDB
RasList = arcpy.ListRasters()
print RasList
inPnts = "SamplePnts"
outTab = "in_memory/sampTbl"
Sample(RasList, inPnts, outTab, "NEAREST")
env.workspace = "in_memory"
tbl = arcpy.ListTables()[0]
recs = arcpy.GetCount_management(tbl).getOutput(0)
print "Table {} records {}".format(tbl, recs)
listFields = arcpy.ListFields(tbl)
for f in listFields:
print f.name
which gave me this....
>>>
[u'IP_bi', u'RES_bi']
Table sampTbl records 200
OBJECTID
SamplePnts
X
Y
IP_bi
RES_bi
>>>
So no errors on my side. No answer for you, sorry. Cheers, Neil
... View more
12-11-2013
11:04 PM
|
0
|
0
|
1083
|
|
POST
|
This succeeds if FGDB is on disk:
ws_output = r'\\NetworkPath\GDB\Conc2.gdb'
elevrasname = "tabElev"
outelevtab = ws_output + "\\" + elevrasname
arcpy.sa.Sample(rasters, transect_in, outelevtab)
This fails:
outelevtab = "in_memory"
elevrasname = "tabElev"
outelevtab = ws_output + "\\" + elevrasname
arcpy.sa.Sample(rasters, transect_in, outelevtab)
James, in your second bit of code, outelevtype is being assigned twice and there is no assignment for ws_output. So perhaps that second bit should be...
ws_output = "in_memory"
elevrasname = "tabElev"
outelevtab = ws_output + "\\" + elevrasname
arcpy.sa.Sample(rasters, transect_in, outelevtab)
I also find it is better to use that os.path.join(var1, var2) construct to piece variables together to make paths. Cheers, Neil
... View more
12-10-2013
08:48 PM
|
0
|
0
|
1083
|
|
POST
|
I have also been struggling to get a tile package up to my online account. I have a tpk which is ~50Mb. Yesterday I used the "Share Package" tool to upload it. Left it running for ages, but noticed that the progressor bar would get to about 80%, then it would mysterious start again. No idea if it was doing different parts of the process or it was actually resetting itself. While this was happening my bandwidth was totally chewed up, so it was sending something somewhere. Eventually cancelled it after 3hrs. Any advice? Cheers, Neil
... View more
12-04-2013
12:37 AM
|
0
|
0
|
840
|
|
POST
|
Firstly I would dump shapefiles and get the data into a geodb. A shapefile with 2mill records might be getting close to its max size (the *.dbf part), 1Gb I think, may be wrong. That error message is usually when the geometry part is getting out of kilter with the attribute part, one doesn't match the other and is normally fatal for shapefiles. Cheers, Neil
... View more
12-03-2013
09:01 PM
|
0
|
0
|
1769
|
|
POST
|
Thanks Xander. My initial confusion about accessing the RAT table is functions like ListTables reveal no RATs. So its there but its not there sort of thing. But having all the raster parameters available with a Raster object is also quite handy, without having to go through a Describe object. Yes, I see that if the permanent Raster is supplied to the da.SearchCursor, it reads the RAT fine. Just a slight bit of inconsistency revealed here. Cheers, Neil
... View more
12-02-2013
01:24 AM
|
0
|
0
|
2727
|
|
POST
|
Last week I answered a query about Null / Not Null counts in a raster. As an aside there I asked about accessing the RAT from a raster. After a bit of searching I have found the solution, its not quite what I expected. Import the modules, navigate to my gdb containing the rasters, create a raster object "Ras1" and validate that it does indeed have a RAT.
>>> import sys, os, arcpy
>>> from arcpy import env
>>> env.workspace = "c:/Data/Python/NumPyArrays/ZimDem.gdb"
>>> arcpy.ListRasters()
[u'DemFill', u'FlowDir', u'DemFill_hs', u'Ras2', u'Ras3', u'Dem', u'Dem_hs', u'FlowD', u'Ras', u'FlowD_Temp', u'Dem_MaxUpstreamElevation', u'Temp', u'Dem_DD', u'CreateConsta1', u'XMapFinal', u'YMapFinal']
>>> arcpy.ListTables()
[]
>>>
>>> Ras1 = arcpy.Raster("FlowD")
>>> Ras1.hasRAT
True
Try to use da.SearchCursor to list the RAT.
for r in arcpy.da.SearchCursor(Ras1, ["VALUE", "COUNT"]):
print r[0], r[1]
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
for r in arcpy.da.SearchCursor(Ras1, ["VALUE", "COUNT"]):
RuntimeError: 'in_table' is not a table or a featureclass
So the da.SearchCursor method, errors out because Ras1 is a raster object, not a table. Fair enough you might think. However, then try the "old" SearchCursor...
rows = arcpy.SearchCursor(Ras1, "", "", "VALUE; COUNT")
>>> for r in rows:
v = r.getValue("VALUE")
c = r.getValue("COUNT")
print v, c
2 4254.0
4 4093.0
8 1572.0
16 3615.0
32 4112.0
64 9199.0
128 6344.0
>>>
So the old SearchCursor doesn't mind that the input is a raster object, and lists the Value; Count list no probs... How odd is that? Cheers, Neil
... View more
12-01-2013
09:54 PM
|
0
|
2
|
7321
|
|
POST
|
Wouldn't SA tools, Local, Cell Statistics do what you want to do. Cheers, N
... View more
11-29-2013
05:06 AM
|
1
|
0
|
2747
|
|
POST
|
Chenay, wanted to reply earlier but the connection went down with the storms. Try this bit of python :
import sys, os, arcpy
from arcpy import env
from arcpy.sa import *
if arcpy.CheckExtension("Spatial"):
arcpy.CheckOutExtension("Spatial")
else:
print "No SA licence"
exit
HomeDir = "c:/Path to directory here/"
fgdb = "Name of your fgdb.gdb"
InData = os.path.join(HomeDir, fgdb)
env.workspace = InData
env.overwriteOutput = True
ListRast = arcpy.ListRasters()
for r in ListRast:
print "Processing", r
Ras = arcpy.Raster(r)
NullRas = IsNull(Ras)
NCol = NullRas.width
NRow = NullRas.height
NCell = NCol * NRow
Mean = NullRas.mean
NNull = Mean * NCell
print "{} % Null {}".format(r, NNull / NCell * 100)
Works for me... As a matter of interest, I tried to find out how to access a raster attribute table in python, but didn't come up with anything. Could Steve Lynch or Xander or some other genius enlighten us. Cheers, Neil
... View more
11-28-2013
06:34 AM
|
1
|
1
|
2747
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-08-2015 11:28 PM | |
| 1 | 12-20-2013 08:59 PM | |
| 1 | 05-14-2014 10:38 PM | |
| 1 | 12-16-2013 09:05 PM | |
| 1 | 05-31-2019 02:50 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|