Tag Info

New answers tagged

4

You need to open it as a QgsVectorLayer layer = QgsVectorLayer('/path/to/shapefile_folder/test.shp', 'test', 'ogr') QgsVectorLayer objects have a method called geometryType. If you call that method for your newly created layer : >>> print layer.geometryType() 2 Where 0 is points, 1 is lines and 2 is polygons


3

I guess the "proper" way is to use QGIS' API which I'd hope would expose that. But I don't know how to do that. An alternative is to look without the shapefile itself. The basics of the specification are on Wikipedia: https://en.wikipedia.org/wiki/Shapefile#Shapefile_shape_format_.28.shp.29 What you want is: bytes 32–35 of the main header which dictates ...


0

Here is what I've come up with so far that seems to be doing the job I intended it to do. import arcpy, math, os, sys from arcpy import env # Getting parameters from tool properties excelFile = arcpy.GetParameterAsText(0) outputFileLoc = arcpy.GetParameterAsText(1) outputFile = arcpy.GetParameterAsText(2) YYYYMMDD = arcpy.GetParameterAsText(3) ...


5

You can do this using 2 os.path functions (splitext and basename): import os os.path.splitext(os.path.basename(r'C:\user\shapefiles\polygon.shp'))[0] # returns 'polygon'


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



Top 50 recent answers are included