Tag Info

Hot answers tagged

3

You could loop through the the Layers panel to check if the layer exists or not by the name before assigning: layers = QgsMapLayerRegistry.instance().mapLayers().values() foundLayer = False for layer in layers: if layer.name() == 'my_layer': inputLayer = QgsMapLayerRegistry.instance().mapLayersByName("my_layer")[0] foundLayer = True if ...


3

Here's some quick-and-dirty Python code that works on a simple shapefile layer: # Get the currently selected layer inLayer = iface.activeLayer() # Get its list of fields inFields = inLayer.dataProvider().fields() # Convert its geometry type enum to a string we can pass to # QgsVectorLayer's constructor inLayerGeometryType = ...


2

I think you are seeing that particular error message from this line of your code: arcpy.KMLToLayer_conversion( r"C:\Project\gis\layers" ,r'C:\Project\gis') arcpy.KMLToLayer_conversion expects a file as its first parameter (KML or KMZ) but you are giving it a folder name. You could try concatenating the contents of your filename variable, with the ...


2

It only took ESRI five years to realize that killing off ArcScripts was one of their more stupid decisions....ArcScripts was easy, simple and just searched for what you wanted...it was one of the things that made ESRI products the best. Trying to find anything on ArcGIS Resource Center was always a nightmare. Now it's back! New Beta here: ...


2

QGIS has created a function called format_number to address this. You simply do format_number(12345,0) to get 12,345.


2

Raster Calculator is an option but limits what you can do. When using arcpy, you must convert your raster dataset to a raster object to perform map algebra. When defining the parameters in a python toolbox, it may be sufficient to change the data type to GPRasterLayer or GPRasterDataset. Otherwise, just cast the path of the raster to a raster object with ...


1

I think the module your looking for is pyshp. if it isn't installed, open your osgeo shell and enter easy_install pyshp


1

You can have multiple layers (or shapefiles) with different attributes. It sounds like from your description that you want to do a JOIN - which is basically connecting a number of layers together by a common attribute. So you could, for example, have a single layer which is joined to a number of other layers by using the name attribute. Then that layer will ...


1

Your approach is calling either this or that for every single field in the attribute table. That might mess things up. Instead try field_names = [field.name() for field in self.layer.pendingFields()] if 'elevation' in field_names: do this else: do that


1

So I've found out what was it ! I added into the code a column with city names to add as labels on the map. But it only contain a small number of them, and Qgis probably don't like Null values that much... After replacing them with zeros the importation of the .xlsx files went smoothly ;) !


1

The two top answers by @SCW and @Mike Toews are great. The site listed by Mike is for unofficial binaries - which was very useful when 64 bit GDAL was not readily available (as per the time he wrote his reply), but it has been now for some time. I have added this alternative answer here as, although I have mentioned it many times, it still keep cropping up ...



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