Why isn't my heat layer valid and I don't get a .tif in this location (this location exists 100%)? Code below:
output = "D:/QGIS_Project_New/heat_map_last.tif"
heat = QgsRasterLayer(output, "Heatmap")
QgsMapLayerRegistry.instance().addMapLayers([heat])
if heat.isValid() is True:
print "Layer was loaded successfully!"
else:
print "Unable to read basename and file path - Your string is invalid"
I get the "Unable.." print, why is that?
EDIT:
So my code for loading layers is working:
highway_layer = QgsVectorLayer("D:/Tomas/QGIS_Project_New/points_highway.shp","Highway","ogr")
if highway_layer.isValid() is True:
print " HIGHWAY Layer was loaded successfully!"
else:
print " HIGHWAY Unable to read basename and file path - Your string is invalid"
But when I try to create and save a layer on this location it is not working. Also I'm using Python Console in QGIS.
highway_layer = QgsVectorLayer("D:/Tomas/QGIS_Project_New/points_highway.shp","Highway","ogr") if highway_layer.isValid() is True: print " HIGHWAY Layer was loaded successfully!" else: print " HIGHWAY Unable to read basename and file path - Your string is invalid"
And I get " HIGHWAY Layer was loaded successfully!"
I'm running the code from the qgis python console.
– John Doe Apr 18 '19 at 14:58Check: Source of code(Page 272): http://www.green-forums.info/greenlib/geolibrary/Lawhead%20J/QGIS%20Python%20Programming%20Cookbook.%2020%20%2852%29/QGIS%20Python%20Programming%20Cookboo%20-%20Lawhead%20J.pdf
– John Doe Apr 18 '19 at 17:03Please help with my further issue:
https://gis.stackexchange.com/questions/319254/kernel-density-estimation-weighting-factor?noredirect=1#comment519881_319254
– John Doe Apr 18 '19 at 17:10