Tag Info

Hot answers tagged

12

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


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


8

You can call the GP tools in two ways: arcpy.%toolbox%.%toolname% or arcpy.%toolname%_%toolbox% Both are calling the same function, so there is no difference. It is a matter of taste; I always call functions in the arcpy.Buffer_analysis format because I seem to read the name tool faster in this way (I see first the toolname, and often seeing the ...


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

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


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


4

You don't need to create a Tool to run the AML. If you have ArcInfo installed follow these steps. copy the aml to that same folder as your DEM open a cmd window cd to the folder where your DEM is located enter arc enter &r tri.aml yourdem outputdem


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

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

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

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

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'"""


4

In general, workflows that you would like to automate I would recommend first doing it manually. Once you have that logic understood (what tools to use when), then yoiu could create a model/python script. For this case here would be the general model workflow (assuming you are using ArcGIS): Use Make XY Event Layer tool to create the GIS layer Use Add ...


4

It works in the python window because JHJ is likely a layer in the map and therefore can be reference in your script as "JHJ". When run outside of Arcmap, you need to tell arcpy where to look. Here are just a few ways you can do this (untested, but it should give you a few ideas): 1) jhj = ...


3

My solution to this problem was to use the extensions available for the Arcpy Addin Toolbar. I added an extension that listens for an edit session to begin or end. I have all of my buttons on the bar set to :self.enable = False" to start with and then these buttons are then either enable or disabled by starting or stop an edit session. class ...


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

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


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


3

The problem with the code you have is that you are trying to convert an ArcMap Map Document into into a string and then you supply the string for the arcpy.mapping.ListDataFrames function. I usually handle this by: 1) Using the ArcMap Document data type for the input parameter. 2) Referring to the mxd file path as an Map Document object. mxd_raw = ...


3

As you suspect arcpy.analysis.Buffer and arcpy.Buffer_analysis are two equivalent ways to run the same tool.


3

The attached (untested) script takes the name of a feature class, splits it by "_" and uses that as a basename for the join operations. The general idea is to use: basename = fc.split("_")[0] which converts, for example, abc_clip_diss to abc Then, you can use that basename to create new variables with os.path.join(): inFeatures = os.path.join(ws, ...



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