Tag Info

Hot answers tagged

5

# I know I repeat myself. Any idea to avoid it ? Move secteur = row.secteur outside the if/else statements (before if nbrow > 0:). Move rows = arcpy.SearchCursor(pochoir) inside the for loop (after for fc in fcList:) I think that you aren't accessing the geometry properly. Reference Reading Geometries and Working with geometry in Python. # tells ...


4

if you use the Kyng Chaos version: 1) First solution with the PYTHONPATH variable: Add qgis to the PYTHONPATH (terminal) $ export PYTHONPATH=/Applications/Qgis.app/Contents/Resources/python You can add this line to your .bash_profile Then in Python # Import qgis from qgis.core import * ...


4

Here is the code that should work for you: import arcpy mylist = ['A4126','A4190'] print str(tuple(mylist)) tempFeat_1 = r"C:\ArcGIS\Default.gdb\AR_postalcodes" tempFeat_2 = r"C:\ArcGIS\Default.gdb\AR_postalcodes_sel" qry = """POSTCODE IN {0}""".format(str(tuple(mylist))) arcpy.Select_analysis(tempFeat_1, tempFeat_2, qry) A couple of comments: ...


3

The rows of the pochoir cursor can only be read once with a for loop. You need to recreate the cursor for each new feature class. Therefore the code needs to be modified to: arcpy.env.workspace = r"Z:\Documents\SIG\tests\synthese_tocorrect.gdb" fcList = arcpy.ListFeatureClasses() pochoir = r"Z:\Documents\SIG\tests\decoupe.shp"#Clip layer with multiple ...


2

1. Connect to Catalog cat = Catalog("http://localhost:8080/geoserver/rest","admin", "geoserver") 2. Get some layers and styles lyrs = [list of layers] stls = [list of styles] 3. Create the group layer lg = cat.create_layergroup(groupname) 4. Add the layers and styles to the group layer lg.layers = lyrs lg.styles = stls 5. Save the group ...


2

For this, you need to create new ogr features and save them to the layer and not simply create geometries ( geom1.AddPoint(linkpoint[0],linkpoint[1]), feature1.SetGeometry(geom1)), with dataSource.SyncToDisk() at the end (SyncToDisk() might be helpful to ensure that a particular feature is flushed to disk but it is not necessary here, look at the script). # ...


2

If you happen to have all the featureclasses you want to convert in a map document, you could just run the Consolidate Map tool on that MXD. Make sure to check the "convert data to file geodatabase option". Inside the output folder will be one or more fgdbs (depending on how many source pgdbs held the original features). If you don't have an MXD with all ...


2

Depends on how you installed QGIS. I downloaded it from qgis.org and this is where its Python packages are: $ pwd /Applications/QGIS.app/Contents/Resources/python $ python -c "import qgis; print qgis.__author__" Martin Dobias If that's not the same for you, use the find utility to look for core.so.


2

Creating a layer file for your clip shapefile and using selection would be how I would accomplish this task. Remember that when a geoprocessing tool is used it will only perform the process on selected features. In the below script, I first create a feature layer from the clip shapefile, to allow for selection. I then iterate through each feature class to be ...


2

Doesn't the third example script in the link you mentioned do exactly what you want in a single table? # Import system modules import arcpy # Set environment settings arcpy.env.workspace = r"C:/data/Habitat_Analysis.gdb" # Set local variables intable = "FIELD_NAME" outtable = "C:/output/output.gdb/TABLE_OUTPUT" # casefield = "Name" Not used stats = [] # ...


1

Python lacks the isNumeric condition for the string. The best I could find is to use try/except on the int of the value (the crash 'n burn approach): def FindLabel ( [STREETNAME] ): nVal = "" # set to an empty string just in case there's no numbers for part in [STREETNAME].split(): # breaks the string down to words and then steps over them as a ...


1

I would use a SearchCursor wrapped in a generator to get the summed fields. This is the full workflow: List all of the fields Create a function with a SearchCursor wrapped in a generator Loop through the fields Limit the fields to only those that are necessary with logic and implement the function import arcpy, os fc = ...


1

Have a look at the ListFields function. Note, you'll want to limit your results to numeric only fields, otherwise, you might get an error. So, you may want to use something like the following: int_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "Integer") to get a list of all integer fields. then small_int_fields = ...


1

In the absence of a python parser your only real option is: replace(ltrim(replace( [field] ,"0"," "))," ","0") This assumes that you don't have any spaces inside your text, if you do then you need another two replaces: replace(replace(ltrim(replace(replace( [SourceFC] ," ","~"),"0"," "))," ","0"),"~"," ") Again, assuming that you have no ~ characters ...


1

I'm assuming that you are using ArcGIS 10.1 for Desktop or later, but this may also work with 10.0. Open up the Properties of your layer to the Labels tab. Make sure Label features in this layer is ticked on Change the Parser to Python. In the Expression area, if your field is called Name and your data is stored in a file geodatabase feature class, type: ...


1

Take a look at the Feature Class To Geodatabase (Conversion) tool. This should hopefully do what you need. You can right click the tool and batch export a number of items.


1

I do this by creating routes from the lines using the Create Route tool to get the lines with common ID attributes (like a river name) all combined together and oriented in a single direction. Then extract the FROM and TO end points of the original lines into separate point feature classes with the Feature Vertices to Points tool. I use the Locate Features ...


1

In your solution you mix geometries and predicates of ogr and Shapely With Shapely only (intersection(), intersects()) from shapely.geometry import Point, LineString, mapping geom1 = LineString([(0, 0), (0, 1)]) geom2 = LineString([(1, 1), (-1,-1)]) intersection = geom1.intersection(geom2) # geo_interface -> GeoJSON mapping(intersection) {'type': ...


1

THe short answer is: I can;t see a way. However, changing attributes on a feature is time consuming at times (I have have a hard time figuring out why it happens). Thus, this should speed up your code a bit: pr.addAttributes( [QgsField(aName, QVariant.Double) ] ) attrs={} #------ # Add Values to Triangle Features in Values ...


1

You have to use the 32-bit version of python. I know this is an old post but someone might stumble on it looking for an answer. See https://geonet.esri.com/thread/94637.



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