Tag Info

Hot answers tagged

4

I think your question is pure Python rather than GIS but I put together a simple Python script called test.py below to prove that it can be easily done. import arcpy arcpy.CreateFeatureclass_management("C:/temp","test.shp") I placed test.py in C:\temp and used Windows Explorer to double-click it. A DOS window appeared for about 10-15 seconds, and then ...


4

Your syntax is correct. However, yes, your data type for the field you are calculating to is incorrect. The function returns a Boolean string, TRUE or FALSE. You need to have a text field you are calculating on/into. This is explained in the specific error message you are getting. View it by going to Geoprocessing > Results, and expanding Current Session, ...


4

Figured it out. Boy that was easy! >>> import arcpy ... ... fc = "C:\Users\PythonTesting.gdb\My_File" ... f1, f2, f3 = "EDITOR", "COUNTY", "OBJECTID" ... clause = arcpy.AddFieldDelimiters(fc, f3) + "= 1" ... for row in sorted (arcpy.da.SearchCursor (fc, [f1, f2], clause)): ... print ("{0}_{1}".format(row[0], row[1])) ... name ...


3

In qgis you can use the mmqgis plugin to geocode addresses. How to use this plugin can be found here: http://michaelminn.com/linux/mmqgis in the chapter Geocode Tools


3

I assume that you are using ArcGIS field calculator def CalcD(level): if 1.5 <= level <= 4.5 : return level * 9 else: return level CalcD(!Level_water!)


3

Don't manually concatenate paths. It leads to errors and makes your code non-portable to other OS's. Use os.path.join instead. For example, replace any instance of projectGDB = path + projectName + ".gdb" with : projectGDB = os.path.join(path, projectName + ".gdb") I believe this will solve your problem, since "F:\GIS\TEST" doesn't end in a path ...


3

The problem may be in how you concatenate the variables to create projectGDB. What you're endiing up with for projectGDB is "F:\GIS\TESTTEST.gdb" Notice there's no slash between the path and the gdb name. I'd suggest using os.path.join(path, projectName + '.gdb') to set projectGDB. Alternately, you could add a slash in front of projectName manually. Also, ...


2

You can do this by looping through the shapefile first with a SearchCursor, creating a dictionary item for each "Key" field, where the value is a list of the "Accuracy" field values. Then loop through again with a UpdateCursor, compare with the maximum accuracy value from the dictionary, and delete the row as appropriate. import arcpy # Create dictionary d ...


2

Years and Months behave differently in several ways that make your expression work for years, but break for months. Any set of year ranges that are positive will work with the original years expression. No set of ranges across multiple years alone can select just dates from a given month. For months you have to set an overall range of all dates regardless ...


2

You've forgotten to add cur.updateRow(row) in the end of the loop, to save changes.


2

You could consider exporting to an XML workspace document via the Export XML Workspace Document GP tool. You can input a geodatabase and then all objects including any behavioural ones will get exported. The problem with Copy Features and FC to FC is that they leave the behavioural objects behind (i.e. networks, topology, etc.). May not be relevant for ...


2

I have used this script in the past (Warning, does not copy any topologies, relationship classes, etc): import arcpy, os def ExportSDEtoGDB(sde_gdb, out_loc, out_name, gdb_type='File Geodatabase'): ''' Creates a copy of an SDE Geodatabase to either a File or Personal Geodatabase. This will copy all tables, rasters, and feature ...


1

The reason is probably in ArcMap unable to recognize a NoData value set by the IDW tool as either 3.40282e+038 or -3.40282e+038. I'd recommend using SetNull tool for these two values on the result and see if that gets rid of any senseless values (should set them correctly to NoData). If not, a flaw in the input data might be present (I'm unsure if IDW ...


1

If you are using Django (GeoDjango), look at vectorformats, which will produce GeoJSON that you can use directly in Google Maps -- we are using this in production, on a decent sized database, millions or rows and complex polygons, and it works really well. If you want to query Postgis directly, use ST_AsGeoJSON as @underdark says, but note, you need to do a ...


1

Don't code, use ST_AsGeoJSON — Return the geometry as a GeoJSON element.


1

This code will do the trick I think. It looks for any line with $PHOTO_NUM, and when it finds one it checks three lines below with the use of the linecache module. If $TERRAIN_HEIGHT : is found three lines down, the script performs a cursor to find the replacement value, and calculates the index of the line to do the replacement in. Once this index is ...


1

We can adjust the Field Calculator Code Block to achieve the effect you are looking for. The following assumes that your target field is a Text Field, and has enough length to hold the value produced by the Field Calculation. For example, if we want to prefix our incremental count with the word "Object": Expression: autoIncrement("Object") Expression Type: ...


1

Not really a answer but a valid workaround: because the CreateLayer() method accept a SRS as parameter, one can create a new empty layer with the correct SRS and then fill it with the features from the input layer: import ogr driver = ogr.Open(input_file).GetDriver() datasource = driver.Open(input_file, 0) input_layer = datasource.GetLayer() dest_srs = ...


1

I calced !Shape.isMultipart! to a Text field and it filled it with 'TRUE' and 'FALSE'. The output type is string, not numeric, so only a Text field will work.


1

I would confirm as @Vince suggests if your input datasets have spatial indices. If your inputs are Shapefiles then these by default do not have spatial indices and need building. Another suggestion that will speed up your code is to replace the cursor you are using with a cursor from the da module as described here.


1

The long execution time is relatively normal. I had a script which I ran from the Python window inside ArcMap and that took more than two hours. I realized that when I converted the script to a script tool, the execution time went down to 12 minutes. A script tool is like a toolbox. You connect your script to the tool. You will need to add a few lines in ...


1

Similar to what the other posters have said. Use arcpy.da.searchcursor and use the where clause. You can then set the where clause to be "where accuarcy > 80" or whatever you want. check out this resource http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001r000000


1

You could try to install everything from packages first, then add the hdf5 libs and re-build gdal with that. All other ways (except self-compiling all) will end in the problems you discovered.


1

You have this problem because the field names to be used when you have a join are not the original field names. If you don't need the join anymore, you can use the "remove join" tool. If you do need the values from the joined table, you must include the table name in the field name, like this : !table_name.field_name! If you want to make sure of the ...


1

By using the new Layer tree (aka legend or Toc) added by Martin Dobias since QGIS v.2.4, you can load a raster layer to any position of the ToC following these steps: Get a reference of the layer tree root = QgsProject.instance().layerTreeRoot() Create the raster layer object from PyQt4.QtCore import QFileInfo fileName = "/path/to/raster/file.tif" ...



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