Tag Info

Hot answers tagged

12

This is a Programmers Competency Matrix. As far as I know there are no such standardized rating systems for GIS scripting, but I might suggest modifying this one - the Programming heading/matrix would be the most relevant and needs little modification to make it relevant to GIS as most of the same principles apply. The nice thing about a matrix like this is ...


11

The principle is simple if you have R installed and is usable in command line. You can create and/or execute a R Script from QGIS using Processing in QGIS version 2.0 or Sextante in version 1.8): see: Setting “R Folder” Path in QGIS Sextante Port your R scripts to QGIS using SEXTANTE QGIS with R: Working with the SEXTANTE plugin and others


9

If the intent of your application is to provide the user a simplified view when identifying features then I would suggest just turn off all the other fields within the layer properties that you do not want to show. When the user identifies a feature, they will only see info for the two that are turned on. This can be done by: Right click layer in the ...


8

Remember that all of ArcGIS' Python stuff dealing with strings starting in 9.3 uses Unicode objects, which will make your life quite a bit easier because encoding becomes less of a big deal in the data. You'll still need to think about it in your scripts, but if you use UTF-8 in any Python source you write outside of dialogs in Arc*.exe ArcGIS will handle it ...


7

Since step three is a manual editing of features based on looking at the NDVI image I would recommend creating two separate scripts. For doing what you've done already and also adds the NDVI image into ArcMap (part of step 1) and creates the feature class (step 2) That runs after you are done with your third step.


7

I think the short answer is NO. In arcpy you would typically "Describe" an object to get a handle on its properties. It appears there is no way within arcpy to find out the version the toolbox was saved in. If anyone knows of a way then please shoot me down in flames so I can learn from your wisdom! But you could fudge it this way: In ArcCatalog right ...


6

If you were to use a script it could calculate all the fields at once. If you were to use the field calculator you'd have to run it on each field you want to update (5x). The following script will update your Dom fields in order of the values of your landcover fields. If several fields have the same value, each field name will be appended as per your ...


6

Should be: stringvariable = "banana" arcpy.CalculateField_management("c:\point.shp", "SUBDIRECT", "'" + stringvariable + "'", "PYTHON") If you double quote stringvariable, Python won't interpret it as "banana". Also, You have to quote the string for the field calculator to work.


5

You will find the borders in degrees in the enclosed html file. gdalinfo can give you the same values, but these are the corners of the tif including the legend, not the map canvas you are interested in. Unfortunately, the map is in a lcc projection, and thus the borders do not follow the exact degree of latitude and longitude, and are not even rectangular. ...


5

ArcInfo Macro Language (AML) is old in ESRI Terms though it is possible to run .amls in ArcGIS 10.0 if you have the right requirements: It's possible to use ARC Macro Language (AML) files in the ArcGIS Desktop environment by creating a new geoprocessing script tool. If you have an ArcInfo license and ArcInfo Workstation installed, you can add a custom ...


4

As far as I understand, you want to make Thematic Mapping with python and svg. you can find very good tutorial here about How to Make a US County Thematic Map Using Free Tools. i hope it helps you...


4

A script implementation of this would be relatively straightforward: Create random points for subset A, creating points α. Buffer α by distance A, creating polygon buff1. Use Erase to remove buff1 from erase0 (input polygon), creating polygon erase1. Create random points for subset B, based on erase1, creating points β. Buffer β by distance B, creating ...


4

You mean for a geoprocessing script? Not easily. You can create your own dialog stylesheet and do some XSLT and Javascript programming to customize the controls, but all of that is super painful and not really worth the trouble. I'd recommend just living with the fact that it's as wide as the screen.


4

This is an issue with how python works. When you import a module, it will search for it in the built-in modules, the paths in sys.path and finally, the current working directory (Python Module Search Path). You've already noticed that adding your second script to the same directory as the toolbox will allow your first, embedded script to import it. This is ...


4

You are trying to use a Layer object as a name for the field and since it is not a string, you get an error message. Your option is to use a layer name (as you see it in the TOC): mxd = arcpy.mapping.MapDocument("current") list_layers = arcpy.mapping.ListLayers(mxd) for lyr in list_layers: arcpy.AddField_management(lyr,lyr.name,"DOUBLE",12,2) or to ...


4

I just realized that I can use Point geometry, for example: point = arcpy.Point(x, y) ptGeometry = arcpy.PointGeometry(point) Then I can use that in a Select by Location arcpy.SelectLayerByLocation_management("Layer", "CONTAINS", ptGeometry) I didn't know I could use the ptGeometry in a Select by Location.


4

Set it as a File type. You can use parameter validation to ensure the file extension is ".pdf" or as @blah238 notes, use the filter option to restrict file type to pdf.


4

Make your expressions as triple quoted strings - nice and clean! For File geodatabases: """CRIME_INDX <= 0.02""" """NAME = 'California'""" For personal geodatabases (.mdb): """[CRIME_INDX] <= 0.02""" """[NAME] = 'California'"""


3

In order to use select layer by location (or attribute), you need to operate on a feature layer. Then you can use SQL to select by FID. You place this in a loop that loops over the number of entries in the attribute table. MakeFeatureLayer can be also used to select by attributes. Just make sure to delete the layer after using it to get ready for the next ...


3

Try the following changes: # Batch Aggregate raster tool import arcpy, os from arcpy import env from arcpy.sa import * env.workspace = r"C:\rasters" out_workspace = r"C:\rasters\agg" rasters = arcpy.ListRasters() for raster in rasters: outAggreg = Aggregate(raster, 10, "MEAN") outAggreg.save(os.path.join(out_workspace, raster + "_agg.tif"))


3

For that, you need; to import the files (shapefiles, raster) in GRASS GIS use the adequate modules You can use Bash or Python from: the Command Console or the Python Shell of the Layer manager the GRASS shell (Python here, but you can also use R) the Mac shell (Python, here, but you can also use R) To use bash scripts, see Shell ...


3

Not that difficult overall, it all depends on your platform of choice and the events you have to hook into. Python has some powerful API hooks for creating a GUID/UUID that you can attach to the end of your DB insert or update method to update the record.If you are using ESRI as your framework, the Global ID is a prebuilt option you can use as well.


3

There is a good answer on SO that translates Cyrillic to Latin. Here is the logic: symbols = (u"абвгдеёзийклмнопрстуфхъыьэАБВГДЕЁЗИЙКЛМНОПРСТУФХЪЫЬЭ", u"abvgdeezijklmnoprstufh'y'eABVGDEEZIJKLMNOPRSTUFH'Y'E") tr = {ord(a): ord(b) for a, b in zip(*symbols)} def cyrillic2latin(input): return input.translate(tr) E.g. cyrillic2latin(u'Москва') ...


3

If you look at this Stack Overflow question, you'll see that it's not a good idea to use the triple quotes method to "pass over" your code. Just comment it out. Instead of prepending a #, most editors offer a shortcut to double comment (##), so that way true comments about your code won't be removed when you undo the bulk comment. It's much faster to ...


3

If you are creating a script tool in a regular toolbox, when defining the tools parameters, for the parameter you want to pass as a list, set the "MultiValue" property to Yes. The multiple values will get passed to your script as a semi-colon separated string. To use as a list in your python script, split the string on the semi-colon, i.e: ...


3

I'm not by a computer where I can try this within ArcMap, but try: wf_expression = '"AGE_18_64"' + " >= " + str(wf_value) or, using str.format(): wf_expression = '"AGE_18_64" >= {0}'.format(wf_value) Try that if wf_value is supposed to be a number in the sql query (you don't generally need to enclose numeric values in quotes). If however it ...


3

There appears to be a solution on your duplicate post on the Esri forums: You just need to delete this part (first three lines of the script): Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> I think the author of this tool meant to ...


2

Maybe you're interested in Kartograph.py. You could use it from command line or as a python module. OpenStreetMap should be a good data source for wikipedia maps as well as Natural Earth data or open data portals.


2

This bit of code might help you programmatically carry out steps 3 and 4. It will load a composer template from file and export a map to jpeg by creating a atlas. It will require some tweaking but should get you started. def quick_export(self, ref, stype, scale): # Add all layers in map canvas to render myMapRenderer = ...


2

I wrote the reply at the same time as blah238 so I modified it consequently. The problem is more complex because you need to: "learn" the structure of the XML file to extract the data as: lat="35" lon="-180" from the location tag = the vertices of the polygon (y, x); rebuild the polygon in a text format with: text or list: (-180, 35), (-170, ...



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