Tag Info

New answers tagged

0

"FATAL ERROR: packing type 40 not supported" wgrib2 was compiled without support for jpeg2000 compression (packing 40). You tried reading a grib record that was compressed with jpeg2000.


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


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


0

I picked up this book about a year and a half ago (Python Scripting for ArcGIS) and found it to be very good as it is geared toward ArcGIS. I had picked up some other Python books from the library and found them hard to relate back to GIS. I do not have a programming background, but this book was quite helpful in going over the basics as well as info ...


0

The easiest way to do this is by importing the path where gdal_merge.py is located, in my case, /usr/bin/ -- substitute with the path to gdal_merge on your system, which, obviously, could be a Windows path too. import sys sys.path.append('/usr/bin/') import gdal_merge as gm You will now have to build up an array for sys.argv, as if you were calling ...


-1

Can you use Spatial Join to stamp the IDs into the polygons?


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


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


0

This excellent Example using the WGrib Utility will show you how to do it. ( See the first answer ). It also gives information on how to use GDal to convert to a Tiff format as well.


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

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


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


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.


0

I would suggest Grass GIS. The v.net package is a pretty powerful tool. Grass can be a bit tricky to get going on but with a tutorial or two you should be OK. You will also need to interpret the matrix result that will be ~200 by ~200 with the distances. Export to excel, import with Python, etc. and do what needs doing with it. ...


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


0

QgsSpatialIndex only knows about the bounding boxes. You will need to get the actual geometries to find the real nearest neighbour. I have done it like this in the NNJoin plugin: # Find a nearest index entry to myPoint (QgsPoint) nearestindexid = self.spIndex.nearestNeighbor(myPoint, 1)[0] # Get the feature in the layer (self.myvectorlayer) that is # being ...


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


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


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

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


4

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


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!


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


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

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)


0

QGIS offers these proj strings for NAD83 Louisiana South (ftUS): EPSG:3452 EPSG:3457 EPSG:3553 +proj=lcc +lat_1=30.7 +lat_2=29.3 +lat_0=28.5 +lon_0=-91.33333333333333 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs EPSG:102282 (from ESRI) +proj=lcc +lat_1=29.3 +lat_2=30.7 +lat_0=28.5 +lon_0=-91.33333333333333 ...


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.


1

to accomplish what your code is doing, # reclassify raster values equal 16 to 7 using Numpy temp = numpy.equal(raster, 16) numpy.putmask(raster, temp, 7) another, perhaps more intuitive way is: # reclassify raster values equal 16 to 7 using Numpy temp = raster == 16 #gives you a numpy array of bools with same shape raster[temp] = 7 #or a short cut ...


1

For QGIS 2.4 (not sure about 2.0.1) you can specify a Python file if you start QGIS from the command line. Type: qgis --help You will see something like: GIS - 2.4.0-Chugiak 'Chugiak' (exported) QGIS is a user friendly Open Source Geographic Information System. Usage: /usr/bin/qgis.bin [OPTION] [FILE] OPTION: ... [--code path] run the given ...


0

Difficult to tell what all your extra code is doing, but these two lines, executed in the Python console, select and highlight the first two features in the active layer: l=iface.activeLayer() l.setSelectedFeatures([1,2])


1

This article on the marching squares algorithm outlines the general algorithm. Here is a good implementation, in various languages, though sadly not Python. Having said that, the algorithm basically just operates on arrays in loops, so ought to be reasonably easy to port. I have used the Java version to do contours and can confirm that it works, in the ...


0

I think your only option here is to create a custom global function in which you pass in the toolID as a parameter and then assign a default value to that tool in order to reset it. I haven't tested this and am just writing it off the top of my head, but it should nudge you in the right direction: def resetTool(toolID, defaultValue): toolID.value = ...


0

you can use batch hegtool, read this: http://newsroom.gsfc.nasa.gov/sdptoolkit/HEG/HEGFAQ_CLI.html and this: http://newsroom.gsfc.nasa.gov/sdptoolkit/HEG/HEG_Batch_job_Help.htm


1

In the end I wrote the following script that solved my problem. The script converts raster pixels with a specified value to vector lines. For example the blue pixels (value = 0) are converted to vector lines. There is definitly room to improve the script, as you can see in the result image. The script can be found and edited here. Raster Image Raster ...


1

The cause of the problems seems obvious now but didn't get to me because of all the small changes and trial and error analysis made on the way: Setting PYTHONHOME and PYTHONPATH (seemingly only PYTHONPATH) caused to program to terminate on startup without errors. Deleting them solves the problem. I was fooled by the fact that QGIS as well as other programs ...


3

As you are working with GRASS 7, you can use (look at Workshop pygrass: modules): 1) grass.scriptwith the run_command(), read_command(),parse_command() functions or in pure Python from grass.script import core as grass region = grass.parse_command('g.region', flags='p') {'ellipsoid: international': None, 'zone: 0': None, 'north:131321.2037345': None, ...


1

you could automate this with a loop in Python. Arcpy uses "lazy computing, so this will be evaluated when you save. import arcpy from arcpy.sa import * imList = glob.glob("your_path/*.jpg") outraster = raster(imList[0]) i=0 for im in imList: if i>0: outraster += raster(im) i+=1 outraster.save("outputname")


0

If I understand you correctly, you could use os.walk and remove the folder from dirnames. Python docs show an example of this, similar to what fluidmotion has but within the traversing itself. import os from os.path import join, getsize for root, dirs, files in os.walk('python/Lib/email'): print root, "consumes", print sum(getsize(join(root, name)) ...


2

Here is an example that does roughly what you ask for. The main parameters are the geotransform array that gdal uses to describe a raster location (position, pixel scale, and skew) and the epsg code of the projection. With that, the following code should properly georeference the raster and specify its projection. I did not test this much, but it seemed to ...


0

Okay, I found my own solution not as straight forward as phloem's but it works: Make a new table which contains a field with values identical to those of a field in the original table but in reverse order (back to front) Copy this new table (so you can repeat the procedure) Join the field which contains the values you want to calculate the decreasing ...


0

maybe a bit clunky, but it seems you could try something like if os.path.split(os.path.dirname(f1))[-1]!='resultfolder': os.remove(f1) so that after glob returns a full path, this would strip off the last directory of the path and compare it with 'resultfolder' - if the directory is different, it would remove the file


2

You could do this if you have the Raster Interpolation plugin installed using Plugin Manager. from rasterinterpolation.core.rasterinterpolator import RasterInterpolator rastLayer = iface.activeLayer() interpolator = RasterInterpolator(rastLayer,0,1) a= interpolator.linear(QgsPoint(10.662629, 76.225421)) print a Note: i don't really know what the above ...


3

gdal_merge.py -o output.tif `ls *.tif` The back ticks mean execute whatever is inside the back ticks before the main command, so this will find all tif files in current directory, which will then be used as the input to gdal_merge.py. Instead of backticks, you can also use the $(command) syntax, ie, gdal_merge.py -o output.tif $(ls *.tif) is ...



Top 50 recent answers are included