Because you imported unicode_literals, you're passing a unicode literal to GDAL which is expecting a string literal.
So, explicitly cast the 'GTiff' arg to a str.
>>> from __future__ import unicode_literals
>>> from osgeo import gdal
Traceback (most recent call last):
The projections differ in the datum shift values for the conversion from Amersfoort datum to WGS84.
The first one is tfm code 4833, and the second is tfm code 15934.
GDAL 2.1.0 uses tfm code 4833, while GDAL 2.2.0 and later uses tfm code 15934. The change was done in https://trac.osgeo.org/gdal/changeset/37081
According to the remarks, 4833 is the latest ...
To get the folder that the currently open MXD is in you can use arcpy.mapping.MapDocument('CURRENT').filePath, this returns '' (an empty string) if the MXD isn't saved and the full path to the current MXD if it is saved.
Using the os.path module you can find the folder the document is in with os.path.dirname, thus os.path.dirname( arcpy.mapping.MapDocument('...
If you want to iterate through large datasets, there's a couple of methods you could use:
QgsFeatureRequest.setFlags(QgsFeatureRequest.NoGeometry) to avoid calling the geometry for each feature;
QgsFeatureRequest.setSubsetOfAttributes() to only call values from a defined field list.
So essentially you would iterate only the fields of interest and their ...
I am going to show how you can replicate arcgis' python enviroment using conda and then plug arcpy to it. This enviroment shall be isolated from arcgis' python so whatever changes do to it, it shouldn't affect arcgis.
The first step is to create an enviroment to enable arcpy at. You can do this with anacoda by typing in the anaconda promt:
conda create -n ...
Use MakeFeatureLayer_management to make a layer from your shapefile. (This layer will be saved in memory, so you won't actually be saving a layer file anywhere, and it will be deleted when the application exits.) Then pass that layer to SelectLayerByAttribute_management:
featureLayer = arcpy.MakeFeatureLayer_management(S_Fld_Haz_Ar, "featureLayer")
Firstly, why do you think the dataset is being read as all 0's? If you're just looking at the output of print(lc) then you're not seeing the whole array just snippets from the edges (3 elements from each end of each dimension by default). In the example below, I print out the array and it just shows the zeroes at each edge of the array, but then I print the ...
One way to do this is with the Append tool (and depending on the amount of common fields among your shapefiles, you may have to modify the field mappings). Pick one of your three shapefiles (or make a copy of it), and append the other two shapefiles to it. Within the tool, select No Test and ensure the three common fields match (right click on field name in ...
You need to pass a string to your derived output parameter.
Ie. arcpy.SetParameterAsText(7, str(outputPDF))
The result from outputPDF = arcpy.mapping.ExportToPDF(mxd, outputPath) isn't something you can pass directly to the output. Alternatively you could have passed outputPath as that is a string.
For Select Layer by Location in_layer and select_features needs to be feature layers, for example created with MakeFeatureLayer (or by adding a feature class to ArcMap and execute code in the Python window using the name of the feature layer from table of contents).
So both "Project\project.DBO.Qo" and poly need to be layers.
I think the issue is that you've created a string of the tuple, rather than mapping the function str to to the tuple. In other words, you're ending up with "(12345, 45678, 910111213)" as a string, instead of ["12345", "45678", "910111213"].
Suggested edit to lines 14-22 (the earlier and later lines look fine):
When I use the parameter 'DGN' as 'dgn', it successfully exports as DGN file in QGIS 2.18.22.
'dgn', ### change 'DGN' into 'dgn'
skipAttributeCreation = True
Things have gotten much easier with GRASS GIS 7.4: there is now "grass-session" to call GRASS GIS functionality from Python.
To install the stable version use:
pip install grass-session
For the usage, see the GRASS GIS Wiki or this example GRASS-GIS-Python session.
your inputs are strings, GetParameterasText is a string value.
convert that variable to an integer...
min_scale_int = int(min_scale)
max_scale_int = int(max_scale)
use your new variable in the rest of your code.
In your code select is a results object.
>>> lyr = arcpy.MakeFeatureLayer_management ("roads", "layer")
>>> type (lyr)
Use the layer name instead.
print "select doesn't exist"
I found out I was actually creating a table view of a table view. The corrected code reads:
import arcpy, os
mxdrep = arcpy.mapping.MapDocument("CURRENT")
dfsrep = arcpy.mapping.ListDataFrames(mxdrep)
#Target folder containing the copied fGDB
dbFolder = os.path.join(projFolderPath, "Databases")
for dfrep in dfsrep:
tablesRep = arcpy.mapping....
First, for QGIS3 it is important to have a proper environment. You'll find a solution in the osgeo4w/bin directory. Inside there is a template for calling python.exe with that environment (it is called python-qgis.bat.tmpl or, if it is already renamed, python-qgis.bat).
Second, a standalone pyqgis script has to "prepare" or init a pyqgis app, analog to a ...
I think it is possible, but is never easy and it maybe requires a deep understanding about programming, QGIS source. Generally speaking, a java program can invoke C/C++ native module(function) through JNI(Java Native Interface). let's suppose you are developing such C++ module(or plugin) . And then the C++ plugin should be built on based on QGIS libraries ...
The question you are asking is quite complex to answer comprehensively, but I can give you some structure and you can fill the gaps. My answer is using arpcy, that comes with ArcGIS. You can achieve something very similar with rasterio (see commented lines)
First of all, I always like to work directly with the numpy arrays. This can be achieved in arcpy by:
Dictionaries are useful in situations when you need to transfer attributes between feature classes based on id.
From what I understand you dont want spatial join, instead use intersect to calculate the intersecting areas.
To add an attribute to the fishnet with the shape area of the intersecting green area and the fishnet cell you can try code below. The (...
Yes. So if you were to print cent_featureclasses, you'd see that it only has the feature class name, not the full path. So if you change the workspace, it is looking for those names in the current workspace. So basically all you have to do is add full path list, like so:
cent_featureclasses = arcpy.ListFeatureClasses()
cent_featureclassesFP = 
for k, v ...
You need to specify an output feature class.
parcelsFC = os.path.join('temp.gdb',JsonDirectoryLocation)
outFc = os.path.join ("temp.gdb", "JsonFeatures")
To get the messages of the Geoprocessing Service, you need to do two things:
Ensure you have a proper message level set on the service. AddMessage = Info, AddWarning = Warning, AddError = Error. (This traverses down, meaning Info will display warnings and errors).
You need to perform GetMessage off the result of your execution.
From your question, you've ...
By using a raster with integer values (1, 100) and one equivalent condition (myarray >= 35, myarray <= 7), following code would work as expected:
from osgeo import gdal, osr
ds = gdal.Open('/home/zeito/pyqgis_data/aleatorio.tif')
band = ds.GetRasterBand(1)
myarray = numpy.array(band.ReadAsArray())
selection = numpy.logical_or(myarray >= ...
This is definitely what you don't want to do but..
When installing your python distribution you can select the option to set it as main python environment. This is definitely something that the Anaconda installer supports.
Alternatively you can manually modify the registry keys pointing to the ArcGIS python executable.
An example of those keys is ...
I'm not sure this is the very best method, but here is what occurs to me. The difficult part of what you are doing is connecting the right feature class to the correct path and shapefile (and this just can't be automated from what I see in the paths you have outlined). Instead of a reading in a text file, you could just define a dictionary above the function ...
I hope you have an answer to this by now, but just in case not I would suggest adding a line after the imports that sets the prefix path. It should look something like os.environ['QGIS_PREFIX_PATH'] = r'C:\OSGeo4W64\apps\qgis'. The code here is for Windows, but it should be similar in macOS. This worked for me.
As commented by @Vince:
There are an infinite number of potential Albers Equal Area
projections. If you want a specific one, you need to specify it, via
file name, integer code, or well known string. Even
"USA_Contiguous_Albers_Equal_Area_Conic" isn't unique at 10.4.1,
because there's also