Tag Info

Hot answers tagged

5

Here's a go at it. Use Python as the parser and check show Codeblock. Enter this in the top Pre-Logic Script Code box: def getints(field): integers = [] for char in field: try: value = int(char) integers.append(str(value)) except ValueError: break return "".join(integers) And put ...


4

You can't get this information as the Python script will block until the tool has finished running.


4

I am not sure if the following will not do the same thing as dissolve, but if I'm correct, it should not. You can use a SearchCursor() to loop through the polygons, get each polygon's geometry, add these as parts on a new polygon geometry object, and use an InsertCursor() to insert this new record. sc = arcpy.SearchCursor("c:/temp/fishnet2.shp") ic = ...


4

As as there is no support EPSG:6479 (NAD83(2011) / Louisiana South (ftUS)) in PROJ4 (look at the comment of mkennedy) I will illustrate the problem with EPSG:3452, NAD83 / Louisiana South (ftUS) because the problem is the same, the units of the projection. Solution with Pyproj import pyproj southla = pyproj.Proj('+proj=lcc +lat_1=30.7 +lat_2=29.3 ...


4

PROJ.4 strings always want the false easting (x_0) and false northing (y_0) in meters, no matter what the coordinate reference system units are. Change +x_0 to 1000000.0 and you should get the results you want.


4

Apparently RefName never equals your comparison strings. All constant strings includes German characters ä or ü, but you don't use the "u" constant string prefix. Depending on the incoming string's format the comparison might not be what you expekt. You should write if RefName==u"Flächen für die Landwirdshaft" and make sure that RefName also is a correct ...


3

I just found a solution. There is also an active psycop2 connection. When I commit it or close the connection before osm2pgsql runs and open it afterwards again it works. Probably osm2pgsql can't access to the database if this connection is open.


2

For using processing standalone, it must be initiated with an interface. Thus, you can create a dummy iface before calling processing: import qgis app = qgis.core.QgsApplication([], True) import processing class DummyInterface(object): def __init__(self): self.destCrs = None def __getattr__(self, *args, **kwargs): def dummy(*args, ...


2

Well I figured it out. I ran a repair geometry on the input polygon feature class. Problem solved. I should have tried that first!


2

Situations requiring edit sessions: Feature classes participating in a topology Feature classes participating in a geometric network Versioned datasets in ArcSDE geodatabases Some object and feature classes with class extensions I'd say you need to start an edit session, and save the edits before you do the append. The Editor class allows use of ...


2

With your example, polygon is a standard Python dict object that represents a GeoJSON geometry, which only uses standard data types, with no fancy geospatial properties. But you can convert polygon into a shapely geometry, as you have done with shape polygon = shapefile_record['geometry'] shape = shapely.geometry.asShape(polygon) print(shape.bounds)


2

Here is a field calculator method that incorporates itertools.takewhile. While ian's solution writes the new values to a text field, this is suited for writing to a numeric field. import itertools def convert(x): try: return int("".join(itertools.takewhile(str.isdigit, str(x)))) except: pass


2

Yes - to do this I would: Use the extent of the polygon just digitized to Create [a] Fishnet of the same size Use SelectLayerByLocation on the fishnet just created to select those that overlap the polygon geometry that you digitized Use GetCount to count how many of the fishnet cells overlap with the polygon geometry Use an update cursor or CalculateField ...


1

The problem with your solution is that source_srs is not a valid osr.SpatialReference(). If the result of source_epsg is 4269 then: source_srs = osr.SpatialReference() source_srs.ImportFromEPSG(4269) gives a valid osr.SpatialReference() NEW If I understand correctly your question, you want to use Leaflet, and Leaflet expects coordinates and GeoJSON ...


1

there is a flipline tool, though it doesn't seem to allow queries on a feature. it may be that you can provide the tool with a feature layer based on the selected attributes. EDIT: As @JasonT mentioned, the flip tool should honor selections, so perhaps use make feature layer with a SQL clause on the features that should be flipped and pass that layer to ...


1

Based on your variable, you just need to make sure variables and strings are not confused field_1="!field_name1!" field_2="!field_name2!" arcpy.CalculateField_management("Layer", field_0, field_1 + " / " + field_2, "PYTHON_9.3") note that if you have the strings as variables without the "!", it is nicer to use format() field_1="field_name1" ...


1

You are missing the wrapping exclamation marks, try this: arcpy.CalculateField_management("Layer", field_0, '!' + field_1 + '!/!' + field_2 + '!', "PYTHON_9.3")


1

You have embedded the string variable within a string so python sees it as a string. I would suggest you make you code something like: field_0="field_name0" calcString = "!field_name1! / !field_name2!" arcpy.CalculateField_management("Layer", field_0, calcString', "PYTHON_9.3")


1

What you're asking for isn't possible. ArcGIS server supervises the Python process and kills it if it takes too long. It doesn't send an interrupt/break to the Python session so the Python interpreter would never get to that finally block. I know you said it's out of your control, but you may want to beg the administrators of your server to let you tick up ...


1

If you have already created the layers in QGIS and you want to publish them using the same style, I think you should go with QGIS Web Client. Related to the new points, everytime the user load the WebGIS application, a new request will be made to the database and so the information will be always updated.


1

I'm not sure why, it must be some memory issue, but you need to use the full file path to the feature class you are creating the feature layer on. So for fcStops, put the full file path, not just the layer name from ArcMap. I tested it on my machine, and it failed with the same error when I used the layer in the TOC, but worked fine when I used the full ...


1

Then I put every record in the rows of a pandas.DataFrame Why ? If you only want to copy the original attributes (LineString) to the new shapefile (Points), after computing the centroid, you don't need Pandas: import fiona from shapely.geometry import shape, mapping with fiona.open("polyline.shp") as input: # change only the geometry of the ...


1

I did a little more digging and found the answer to my question: instead of using os.system, the correct syntax for storing the result in a variable is: result = os.popen('gdallocationinfo -valonly -wgs84 %s %s' % (lyr, loc)).read()


1

I think you will have to use the subprocess syntax, it is explained in this post: subprocess to call gdal from within python


1

Basically you can treat each band as a separate raster and use it as input of the Composite Band tool. If you want to automate the process, there must be a structure in the name of the bands, like raster.tif\rainfall_year_month. If you have such a structure (at least with the year mentioned) you could use this code (not fully tested): arcpy.env.workspace = ...


1

For those who want to do this in 10.2, this modification of above worked for me: # Import system modules import sys import string import os import arcgisscripting # Create the Geoprocessor object gp = arcgisscripting.create(10.2) # Load required toolboxes... gp.AddToolbox("C:/Program Files (x86)/arcgis/Desktop10.2/ArcToolbox/Toolboxes/Data Management ...


1

I realize this question was closed long ago, but I have some old tools that this was newly a problem for and the SendKeys solution no longer seems to work, so I rolled my own solution after experimenting. It doesn't disable drawing, but creates the performance equivalent of that by disabling layers and reenabling them when done. Having the script run in the ...



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