Code below is working, but after opening - there are No features in shp file. What can be a problem?

import osgeo, os
from osgeo import ogr, gdal

shpFile = r'C:\Users\ReBurns.shp'

driver = ogr.GetDriverByName('ESRI Shapefile')

ptsDS = driver.Open(shpFile)
ptsLayer = ptsDS.GetLayer()

#Passing criteria  to select polygons:    
myQuery = 'Area_ha > 39000.00'
print ptsLayer

#Save selected features to disk 
outds = driver.CreateDataSource(r'C:\Users\ReBurns111.shp')
outlyr = outds.CopyLayer(ptsLayer,'ReBurns111.shp')

Got error:

Traceback (most recent call last):

  File "<ipython-input-167-1e169b0c7c9c>", line 44, in <module>
    outlyr = outds.CopyLayer(ptsLayer,'ReBurns111.shp')

AttributeError: 'NoneType' object has no attribute 'CopyLayer'

No selected files, but how to pass selected by criterias?

closed as off-topic by Midavalo, Andre Silva, PolyGeo Apr 24 '16 at 0:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – Midavalo, Andre Silva, PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You read and write the same file? Does it work if they are different? – underdark Apr 23 '16 at 22:14
  • No actually I just change output name, If they different it does not work also. – Adams Apr 23 '16 at 22:29

Actually it works, just need to wait few minutes after code exercise.

Not the answer you're looking for? Browse other questions tagged or ask your own question.