Tag Info

Hot answers tagged

7

You could skip using ap.Listfiles all together and use a for loop with xrange... for rt in xrange(3609902,3610032): quads = ["%snw.txt"%rt,"%sne.txt"%rt,"%ssw.txt"%rt,"%sse.txt"%rt] print quads for quad in quads: if ap.Exists(quad): # Do whatever...


7

For starters, you could include sw in your wildcard statement (*sw.txt), which presumably would reduce your number of returned records substantially (assuming you have ne, nw, se, etc). Second, now that you're working with a subset of files, use a conditional statement to widdle down your files to your exact needs. Pseudo Code: Set workspace (directory) ...


6

Based on explanation by Roy: toprocess = [p for p in [int(filename[0:7]) for filename in txt_list] if p>=3609902 and p<=3610032]


5

It's input redirection -- just like you can redirect the output of a command into a file,: command > outfile.txt you can redirect the input from a file: command < infile.txt This is the same as: cat infile.txt | command Hopefully helpful!


4

Update: Found one for Notepad++. You might have to tweak it a bit as it might be for an old version of Mapserver. Cheers! You'd have to create your own definition if you insist on using Notepad++. You might want to check mscompanion though. It has a WYSIWYG mapfile editor and you can instantly visualize your changes. You can find the installer at Google ...


4

The syntax for combobox (as well as other controls) is different in VB.NET. You should review the help to see the changes. cmbBox.ListCount --> cmbBox.Items.Count cmbBox.List(l) --> cmbBox.Items.Item(l) cmbBox.AddItem(sItem, l) --> cmbBox.Items.Insert(l, sItem) cmbBox.AddItem(sItem) --> cmbBox.Items.Add(sItem)


3

If you set the extant rectangle to same the point it will recenter but not change the zoom or scale map_post = QgsPoint(x, y) rect = QgsRectangle(map_pos, map_pos) self.canvas.setExtent(rect) self.canvas.refresh() I'm also curious why you are writing to a file and then redrawing that layer. That's pretty expensive if all you want to do is show a GPS ...


3

you can do it with this way: import os import random yourMainFolder = r'C:/out' range1 = 3609902sw range2 = 3610032sw newAry = [] for a in (int(range1[:-2]) - 1, int(range2[:-2] + 1)): newAry.append(str(a) + range2[-2:]) for dirname, dirnames, filenames in os.walk('yourMainFolder'): for subdirname in dirnames: path = ...


3

Type your resolution of raster, not "resolution". Also, don't type +*/= by keyboard. Use raster calculator buttons. Here's how to set the resolution of your raster : Right-click your raster, and click Properties. Go to Source tab. Change Cellsize(X,Y) to set your resolution.


3

If you are using building polygons with points that lie somewhere within the polygon use a spatial join to join each building with the point residing in it. Then calculate your field in the point feature class based on the joined building polygon feature class field of choice.


3

You could try the .NET library Proj.Net. See the Loading a projection by Spatial Reference ID page for how to add in the GB National Grid. Example code from this forum post: CoordinateSystemFactory c = new CoordinateSystemFactory(); ICoordinateSystem target = c.CreateFromWkt("PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB ...


2

The Attribute Assistant allows you to take field values from intersecting or nearby features and put them in specified fields of the created feature. It can be configured to populate fields when a feature is created, or on a selected set of features, and when you update a feature's attributes or position. There is a tutorial here, and a blog post on how I ...


2

If I understand correctly, you want to take an integer field and do some calculations and change the field to a text field, correct? You cannot do that in the field calculator. However, you can do it in the python window. You would be adding another field, moving and converting values, and then deleting and replacing your GRIDCODE field with another that ...


2

Selection by attributes: "field_name" LIKE 'C%' Field_name is attribute that contains your annotations.


2

You can use this structure to loop thru the columns of a table. Dim sCol As String Dim aCol As Alias Dim nCol As Integer For nCol = 1 To TableInfo(sLayer, TAB_INFO_NCOLS) sCol = ColumnInfo(sLayer, "COL" & nCol, COL_INFO_NAME) aCol = sLayer & "." & sCol Next This will loop thru the columns of the table sLayer and store the name in a ...


1

Here's a link to MSDN on Nearest Neighbour queries. Luckily you are using 2012 so the indexes will be used. A query like his should be close to what you want. SELECT pl.ID polyID, pt.ID pointID, pt.Distance FROM Polygon pl CROSS APPLY ( SELECT TOP 1 p.ID, p.SHAPE.STDistance(pl.SHAPE) Distance FROM Point p WHERE p.SHAPE is not ...


1

Got it! line_center = [] featuresC = Center.getFeatures() for elem in featuresC: xy1 = elem.geometry().asPoint() center = QgsPoint(xy1) line_center.append(center) print line_center line_ends = [] featuresO = Outer.getFeatures() for elem in featuresO: xy2 = elem.geometry().asPoint() ends = ...


1

I can see 2 issues in you script: You're missing the second join_field parameter in arcpy.JoinField_management. Refer to the tool's page for the correct syntax: JoinField_management (in_data, in_field, join_table, join_field, {fields}) If you work with shapefiles and dbf tables, you should add the .shp or .dbf extension to your inputs. For example your ...


1

I guess it very much depends on how you want to use the data and the level of accuracy required. Without the full address it is going to be difficult for you to work out which vertical street postcode to assign (if at all), but then if all you have is the street name then one could argue that you don't necessarily need to concern yourself with selecting the ...


1

Anyone with more info can edit this answer. The edcommunity has a sample app, but no downloadable code. As per KHibma the clip and ship will probably work. If you aren't clipping the Edcommunity Sketch-A-Map app uses a draw widget to export.


1

If you like Python, how about the titlecase module? http://muffinresearch.co.uk/archives/2008/05/27/titlecasepy-titlecase-in-python/ It's decent, and works for English. Of course there will always be exceptions or gray areas (see my comment under the question above).


1

I'm pretty sure the answer lies in setting the zIndex (map.setLayerZIndex or layer.setZIndex). I believe the features of the vector layer are treated differently and the zIndex value is magnified though I couldn't confirm this in the code: Z_INDEX_BASE: { BaseLayer: 100, Overlay: 325, Feature: 725, Popup: 750, Control: 1000 }, Try ...


1

This is how I solved the problem: import psycopg2 import re def replace(matchObj): # Group 0 is all groups, group 1 is the first match contained in # parentheses. Group 2 is the whole float value. value = float(matchObj.group(2)) value = value - 360 return matchObj.group(1) + str(value) + " " def main(): # connect to postgresql ...


1

The proj.4 library might be of assistance, but it is written in C, rather than C#. There is a C# wrapper for it here.


1

Have you tried using getFeaturesByAttribute() instead of getFeature()? The former looks up using attributes (I think this is what you are trying to do), while the latter looks up using properties.


1

you can use getFeatureBy method: var lyr = new OpenLayers.Layer.Vector("test"); var ft = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(10, 10), {scientific_name:'hydro'}); map.addLayer(lyr); lyr.addFeatures([ft]); var features = lyr.getFeatureBy('scientific_name', 'hydro'); and for highlighting them with scientific name you ...



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