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 ...


6

Plain and simple: the bottleneck if you are dependent on software as a tool will always be the software; and the bottleneck for advancing the state of the art for software will always be software developers. If you are not a programmer and you use software to solve problems at work, you will always be beholden to this simple and often annoying arrangement. ...


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

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 ...


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 ...


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

If you want to measure distances, you first have to georeference your image of the turntable to "transform" the pixel coordinates of your turntable image into real world coordinates. After that, you can use the measuring tool of QGIS.


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 ...


2

@PaulRamsey wrote a very good blog article that described how Pierce County, WA integrated open source with closed source software. He also gave a presentation called "Open Source for IT Managers" (if you don't want to watch the whole thing, start at 42:35), which describe some of the cost savings, and issues, of using both closed and open source. In many ...


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 ...


1

You can save your SQL data to a .csv file. ArcGIS has a tool named "Make XY Event Layer" that maps X,Y columns from a csv or other table to an Layer. You can then Copy the Point Layer to a Shapefile. This tool works with any ArcGIS license level.


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

i think you need to set "layer CRS" too


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 ...


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

Try the Summary Statistics tool. Set your case field to be the column that represents the different areas.


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

Have a look at my (former) course https://www.e-education.psu.edu/geog585/ especially lessons 7 & 8 to get you started.



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