|
POST
|
Simple answer - you can't use wildcards for python string comparisons, use something like: #assuming you are checking the LAST character for 'a' or 'b'...
if row.PATCH_CODE[-1] in ['a','b']: Complicated answer - you can use wildcards for python string comparisons if you use regular expressions - http://docs.python.org/library/re.html
... View more
07-25-2011
05:24 PM
|
0
|
0
|
597
|
|
POST
|
So is this correct: 1) xmlns is the root? 2) I need to specify the tag + root to get the text like in this ('.//%ssatellite'%xmlns). The .// level of tag nesting. %s converts to string. How does it concatenate the two? 1. No. xmlns is the namespace. The root is {namespace}product 2. If your XML specifies a namespace, you need to use {namespace}tag not just tag. % is a string operator, it is used to replace string format codes (e.g. %s) with one or more values. See http://docs.python.org/library/stdtypes.html#string-formatting for more info.
... View more
07-13-2011
03:00 PM
|
0
|
0
|
1934
|
|
POST
|
Have you tried to use the code snippet from my previous post? xmlns='{http://www.rsi.ca/rs2/prod/xml/schemas}'
for path in [ './/%ssatellite', './/%sbeamModeMnemonic', './/%srawDataStartTime' ]:
node = tree.find(path%xmlns)
print 'node.text:', node.text
print 'node.tag:', node.tag
This prints:
node.text: RADARSAT-2
node.tag: {http://www.rsi.ca/rs2/prod/xml/schemas}satellite
node.text: S6
node.tag: {http://www.rsi.ca/rs2/prod/xml/schemas}beamModeMnemonic
node.text: 2011-04-18T12:32:56.257634Z
node.tag: {http://www.rsi.ca/rs2/prod/xml/schemas}rawDataStartTime
... View more
07-12-2011
04:42 AM
|
0
|
0
|
1934
|
|
POST
|
1. Your example XML is invalid (I assume that's just an error snipping out the example, you have an unclosed "sourceAttributes" element which it looks like you're trying to close with an "imageAttributes" element and you have an open "<" in there as well.) 2. Your XPath expression will only search the first level. Use ".//" to recursively search. 3. Your xml declares a namespace, you need to use it. i.e. xmlns='{http://www.rsi.ca/rs2/prod/xml/schemas}'
for path in [ './/%ssatellite', './/%sbeamModeMnemonic', './/%srawDataStartTime' ]:
node = tree.find(path%xmlns)
print path, node
... View more
07-11-2011
10:05 PM
|
0
|
0
|
1934
|
|
POST
|
I found I can use the built in GRID variables or scalars in ArcGIS 10 with a bit of a hack. It appears that the python arcgisscripting module is still included in Desktop ArcGIS 10, perhaps for backwards compatibility (or perhaps I didn't uninstall 9.3 properly...), so I wrote a little script that uses the SingleOutputMapAlgebra tool, created a script tool and added that to a custom toolbox and then just use that as required. import arcgisscripting
gp = arcgisscripting.create(9.3) #This works in ArcGIS 10!!!
expr=gp.getparameterastext(0)
output=gp.getparameterastext(1)
result=gp.SingleOutputMapAlgebra(expr,output) I've attached a screenshot.
... View more
05-31-2011
08:34 PM
|
2
|
1
|
2152
|
|
POST
|
A simpler method (in Model Builder/Toolbox) would be to use the GetRasterProperties_management tool and specify MEAN as the property to return.
... View more
05-23-2011
08:11 PM
|
0
|
0
|
3286
|
|
POST
|
If you have (or install) gdal, try the gdal_translate utility: http://www.gdal.org/gdal_translate.html. It doesn't export to 1 or 4 bit, 8 bit is the smallest. gdal_translate --ot Byte src_dataset dst_dataset
... View more
05-22-2011
05:00 PM
|
0
|
0
|
1827
|
|
POST
|
Have read of this: floating point issues. It's for python, but it's one of the best floating point representation articles I've come across. Basically don't worry about it.
... View more
05-19-2011
08:07 PM
|
0
|
0
|
659
|
|
POST
|
1. Create a new toolbox and add it to the ArcToolbox tree. Right click on the new toolbox and select Add->Script... Add the path to wget (or a batch file that runs wget) to the "Script File:" text box on the 2nd page of the dialog. Add any arguments on the third page (you can set defaults so you don't always have to type stuff in) and click Finish. 2. Write a Python script that calls wget using the subprocess.Popen() class (or use urllib to download your files directly). This way you can return an output value to ArcGIS.
... View more
05-01-2011
07:18 PM
|
0
|
0
|
1141
|
|
POST
|
You might get a response if you post in another forum, i.e. http://forums.arcgis.com/forums/5-ArcGIS-Desktop-General. This forum is for ArcInfo Workstation, the old command line application.
... View more
04-20-2011
06:30 PM
|
0
|
0
|
407
|
|
POST
|
This looks promising, but I'm still on 9.3 I'll be trying to get this to work, but could use help if anyone feels like translating this. See the 3rd post - (http://forums.arcgis.com/showthread.php?p=45823#poststop) it's for 9.3 and will do what you want with minimal changes. Basically instead of looping through statistic types, loop through rasters and get the mean - ie mean = gp.GetRasterProperties(someraster, 'MEAN') .
... View more
02-03-2011
12:36 PM
|
0
|
0
|
1776
|
|
POST
|
A quick example: from osgeo import gdal, gdal_array
from scipy import stats
import numpy
dataset=gdal.Open(someraster)
x=dataset.GetRasterBand(1).ReadAsArray()
func = stats.norm.pdf(x, loc=m, scale=(s)) #you need to define m & s
sqrtx = numpy.sqrt(x)
#Write the result out - see http://www.gdal.org/formats_list.html for formats you can write to
newdataset=gdal_array.SaveArray(sqrtx,newrasterpath,'GTIFF',prototype=dataset)
newdataset.SetProjection(dataset.GetProjectionRef())
newdataset.SetGeoTransform(dataset.GetGeoTransform())
... View more
01-09-2011
01:38 PM
|
0
|
0
|
611
|
|
POST
|
It can be done. Start looking into GDAL and NumPy. The math module is only for scalars not for arrays/rasters though (NumPy has its own versions though). You won't even need ArcGIS 🙂 I'll try and remember to post some examples when I'm back at work next week. Just be aware that if you have large rasters, you will need to implement your own tiling process (which ArcGIS does behind the scenes for you) as NumPy holds the entire array (raster) in memory.
... View more
01-07-2011
01:16 PM
|
0
|
0
|
611
|
|
POST
|
Perhaps use the SciPy NDImage package to implement your slope algorithm. http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.filters.generic_filter.html i.e
import scipy.ndimage
def CustomSlope(numpy_array):
#Do something
slope = scipy.ndimage.generic_filter(elevation_array, CustomSlope, size=(5,5))
... View more
11-17-2010
03:50 PM
|
0
|
0
|
618
|
|
POST
|
Try running your original script in a separate process from the script that does the looping, passing the directory to process to the original script each loop: #Master script to loop
def runcmd(cmd, format='s'):
import subprocess
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
stdout,stderr=proc.communicate()
exit_code=proc.wait()
return exit_code,stdout,stderr
for dir in <list of directories>:
cmd ='%s %s %s' % (<path to python>, <path to your script>, dir)
exit_code,stdout,stderr = runcmd(cmd)
... View more
10-20-2010
04:26 PM
|
0
|
0
|
766
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM | |
| 5 | 04-22-2025 09:04 PM |