Tag Info

Hot answers tagged

13

How about something simple like: if len(rasterList) == 0: print ("This directory does not contain any raster data.") else: # Your raster processing code The len() function calculates the length of the returned string/list, so if it returns 0 then you know nothing in the folder matched the criterion (in this case, being a raster). This way, if the ...


12

You could include the Python dictionary of state abbreviation:full-name pairs here states = { 'AK': 'Alaska', 'AL': 'Alabama', 'AR': 'Arkansas', ... } as the Codeblock in Field Calculator, and then use something like the following as the actual calculation: !City! + ", " + states[!State!] I should add that you could perform this ...


9

You can use numpy. See the example below. A numpy masked array can be generated accounting for the no data values. See the numpy help topic for mafromtxt and genfromtxt Below is a small ascii file with a nodata value of -999 ncols 3 nrows 3 xllcorner 0 yllcorner 0 cellsize 1 NODATA_value -999 0 1 2 -999 4 5 6 7 8 ...


5

Take a look at the section on slicing in the Python tutorial. You can grab a range of characters from a string using slicing syntax, e.g. D = int(x[1:2]). For seconds, try S = float(x[5:]). This will grab all the characters starting at index 5 to the end of the string, in the case that you have variable length values for seconds. The !FieldName! syntax is ...


4

You want raster data statistics. See what you are doing in the gui first (for homework.) Then you can use a python window or a script. import arcpy arcpy.CalculateStatistics_management("c:/data/image.tif", "4", "6", "0;255;21")


4

What do you mean by 'generate contours'? Do you have contours as shapefiles and want to display for the selected area only. That can be achieved using OpenLayers CQL filters. If this is not the case, what elevation data do you have? In case you are using DEM, you can check this link : Developers Corner: have your SLD transform raster data into vectors on the ...


4

Sewers are much more often driven by hydraulic considerations, which includes elevations in the z axis. The spatial layout is a close second, which deals with coordinates in the x y axis. So what are the hydraulic constraints going to be? The selection of a Mannings n is by far the most troublesome variable. Having said that, I note that there is a ...


3

I ran the test code below which is near identical to yours. import arcpy mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd") for elm in arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT"): print elm.name if elm.name == "North Arrow": print elm.style elm.style = "ESRI North 1" mxd.save() del mxd What you will notice is ...


3

Qgis wants you to define a projection system to be used in your project. It wants it so if you're going to import something from the "real" plane (remember that the earth is spherical) to know where it should go in the Cartesian plane. There are numerous projection definitions ready to be used that were tailor made as solutions for specific problems. Proj4 ...


3

I'd advise you to look up, research, the travelling salesman problem for some soutions. Here's a link to a way to formulate a solution. In short, this is a tricky subject to get into/understand: TSP solutions


3

Your Describe() is referencing the workspace (a folder) rather than the individual images contained within it. Try this: import os import arcpy arcpy.env.workspace = "C:\\Rasters" # Contains TIFF, IMG, GRID formats filePath = arcpy.env.workspace rasterList = arcpy.ListRasters("*", "ALL") for name in rasterList: desc = arcpy.Describe(filePath + ...


2

You need to cast them to Raster objects first: >>> import arcpy >>> arcpy.Raster('NcLidarClipUTMmeters') D:\Projects\VIESORE\GIS_Data\Testing.gdb\NcLidarClipUTMmeters >>> r = arcpy.Raster('NcLidarClipUTMmeters') >>> r.bandCount 1L >>> t = arcpy.Raster('m1.img') >>> t.bandCount 3L >>>


2

edit - now tested and working - edit - improved code import sys class Ascii_file(object): def __init__(self,file): self.raster_file = open(file, 'r') # Open the file self.max=sys.float_info.min self.min=sys.float_info.max def __minmax(self,value): if value>self.max:self.max=value if ...


2

Imho, "Dijkstra" is not a good hint. What you are looking at is the so-called "Travelling salesman problem". Given a list of cities and their pairwise distances, the task is to find a shortest possible tour that visits each city exactly once. Since a brute-force approach performs with O(n!), they reach their limit pretty fast (WP says 20 nodes is ...


2

I would say you cannot georeference this or use geografical coordinates. It doesn't matter where in the room (and in the world) this turntable lays, right? I think you need to create your own local plane coordinate system, measuring by a ruler the size of the turntable, then referencing (scaling) the image to this distance (presented as a vector line or a ...


2

From the Wikipedia article on Level of measurement: The ratio type takes its name from the fact that measurement is the estimation of the ratio between a magnitude of a continuous quantity and a unit magnitude of the same kind (Michell, 1997, 1999). A ratio scale possesses a meaningful (unique and non-arbitrary) zero value. Here is a good article ...


2

You don't need a search cursor to do what you want. At the moment, you are running a selection on the entire layer for each row you have. So, if you have 1000 rows, you are making a selection on the entire layer 1000 times. Try getting rid of your search cursor and the while statement - just use the select tool. I suggest you read the help page on the ...


1

From everything I have seen, or more correctly not seen, while trying to find a way to change the color of my north arrows and scale bars, it appears it is still not possible to change the type or style of north arrow using arcpy. Also, arcpy.mapping does not allow you to add or remove graphic elements, and cloned elements can only be applied to the mxd ...


1

There are functions to get statistics for a shapefile (as mentioned by @danb). But first you probably need to calculate the length/area first in a field. Create a new field (Add field function) Right click the header of that field --> Calculate geometry. Choose length/area depending on what you need. The field gets populated with length/area values which ...


1

The term for what you are doing is a suitable site analysis and here are links to two approaches: Using vector data Using raster data (needs Spatial Analyst extension) Hope it helps.


1

Since you expressed that you knew some Python, I think you'll want to design a Python add-in. You can create a tool that gives you access to lots of functions that would be useful for selections such as onRectangle()--Occurs when the mouse button is released after the rectangle is drawn on the map


1

There's a few issues: row is undefined, which means that your while loop cannot loop over it. You need to define row = rows.next(), see here. You are missing a parameter for SelectLayerByAttribute(). You need to specify which type of selection you want (new selection, add to current selection, remove from selection). I think you want your search cursor ...



Only top voted, non community-wiki answers of a minimum length are eligible