Script in PyQGIS to create a shapefile

المشرف العام

Administrator
طاقم الإدارة
I'm having some trouble applying my Python skills to develop some scripts in PyQGIS. For me it's far simpler to write it in ArcPy, but then again I wouldn't get that much satisfaction after finishing my project. Trying to work with open source tools as much as possible.

In short, for now I want to write a Python script that takes in a shapefile and from that generates another one with some specific attribute data related to buildings. If I were doing it in ArcPy, my algorithm would be the following: use the MakeFeature Layer_management, then perform a SelectLayerByLocation_management, within the selection select the data you need, and then create another layer with desired data.

How could I this in PyQGIS? One idea, reading the PyQGIS Cookbook, to use .getFeatures(), QgsVectorFileWriter to write the shapefile, but how do I perform the query?

Many thanks!



أكثر...
 
أعلى