37 votes

Using OSGeo4W shell with Python 3

There's no need to edit batch files (and break python 2.7 in the process) or set environment variables manually. Just run py3_env which sets the shell up for Python 3 automatically, then run python3. ...
user avatar
  • 52.8k
18 votes
Accepted

Using OSGeo4W shell with Python 3

There is a not well documented command build into OSGeo4W Shell which sets the shell up to python3 as Luke mentions py3_env Basically it sets your PYTHONHOME and the correct PATH. Then you can call ...
user avatar
  • 2,049
17 votes
Accepted

What's the difference between QgsPoint, QgsPointXY and QgsGeometry.fromPointXY(QgsPointXY()) in PyQGIS?

QgsPoint is a point class which supports Z (3D) and M values. (What are Z and M?) x, y, z, m = 10, 10, 20, 5 QgsPoint(x, y) # 2D # <QgsPoint: Point (10 10)> QgsPoint(x, y, z) # 3D # <...
user avatar
15 votes
Accepted

Differences between OSGEO GDAL and GDAL python bindings?

As documented in https://pypi.org/project/GDAL/ plain "gdal" is deprecated and you should not use that for writing any new code Additionally, there are five compatibility modules that are ...
user avatar
  • 52.5k
13 votes
Accepted

Getting bounding box from Point type GeoDataFrame to getting data from Osmnx

You can use the total_bounds property for this. Small example: In [83]: from shapely.geometry import Point In [84]: import geopandas In [86]: import random In [87]: df = geopandas.GeoDataFrame({'...
user avatar
  • 3,428
11 votes
Accepted

Installing external Python packages in QGIS 3

I encounter that problem after installing QGIS 3, too. Therefore, I install Python packages in following way: Copy python3.dll and python36.dll in (QGIS_PATH)/bin folder to (QGIS_PATH)/apps/Python36/ ...
user avatar
10 votes
Accepted

Split the column into several and unpivot the columns

You can use "Split features by character" tool. uri = r"C:\impression_plan\mini\RSFFicheCanalisation.shp" layer = QgsVectorLayer(uri, "", "ogr") new_layer = ...
user avatar
9 votes

Distinguishing Python version when using IDLE with ArcGIS Pro and ArcGIS 10.x for Desktop architecture?

This is not exactly what you asked for, but a workaround could be to add both IDLE instances to your Send To context menu option. open %APPDATA%\Microsoft\Windows\SendTo choose > New > Shortcut ...
user avatar
  • 20.5k
8 votes
Accepted

Distinguishing Python version when using IDLE with ArcGIS Pro and ArcGIS 10.x for Desktop architecture?

That's all controlled from the registry. You could open the registry and find HKEY_CLASSES_ROOT\\Python.File\\shell\\Edit with Idle and re-name that folder to something like Edit with Idle 2.7 You ...
user avatar
  • 15.4k
8 votes

Python 3 support in QGIS?

Python 3.6 has landed in QGIS 2.99:
user avatar
  • 82.1k
8 votes

Using Python 3.x in ArcGIS?

To address @CodyBrown comments here: I don't know how this is opinion based. I am asking whether ESRI has plans to move to Python 3x in the near future or not. As answered below by James and ...
user avatar
  • 15.4k
8 votes

Using OSGeo4W shell with Python 3

If you want to make the change permanent you can modify the batch file OSGeo4W.bat located in your QGIS (or OSGEO) directory and just add: call "py3_env" below the line calling call "%~dp0\bin\...
user avatar
  • 351
8 votes
Accepted

Python shapely intersection with buffer in meter

Shapely knows nothing about your units. Therefore, when you call polygon.buffer(0.2), shapely will buffer the coordinates in polygon by 0.2 units. In your case, these are not meters, but degrees. If ...
user avatar
  • 2,785
7 votes
Accepted

Fill color not showing appropriately in folium?

According the documentation, when you're creating a CircleMarker object the fill parameter defaults to False. Try explicitly setting it to True in your code: #... for lt, ln, el in zip(lat, lon, ...
user avatar
  • 3,895
7 votes
Accepted

Why does osr.SpatialReference return different values in python2 and 3?

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, ...
user avatar
  • 75.1k
7 votes
Accepted

Ipyleaflet map object doesn't display in Jupyter Notebook but it gets created

I just tried to install ipyleaflet with Jupyter 5.2.3: conda install -c conda-forge ipyleaflet and also didn't get a map. I then tried registering the extension with: jupyter nbextension enable --...
user avatar
  • 3,897
7 votes
Accepted

Explaining pyproj to_epsg min_confidence parameter?

This is a great question and I will do my best to answer. To begin, the init style syntax is deprecated (https://pyproj4.github.io/pyproj/stable/gotchas.html#init-auth-auth-code-should-be-replaced-...
user avatar
  • 5,827
7 votes
Accepted

Merging a geodataframe and pandas dataframe based on a column

You should specify a common key using on parameter. I removed merged_ prefix for legibility. df = spatial_df.merge(tab_df, on='mukey', how='left') # df = tab_df.merge(spatial_df, on='mukey', how='...
user avatar
6 votes
Accepted

Starting Python Shell Window of IDLE for use with ArcGIS Pro?

You can start the Python IDLE GUI from the Start Menu using the ArcGIS Pro Python command prompt. Start Menu > All Programs > ArcGIS > ArcGIS Pro > Python Command Prompt This will open a command ...
user avatar
  • 29.2k
6 votes
Accepted

Using Python 3.x in ArcGIS?

This summer Esri was saying that ArcGIS Pro will go Python 3. The legacy ArcGIS Desktop will stick with Python 2.x as long as it can. I believe there are a bunch of Python 3 migration ArcGIS Pro ...
user avatar
  • 870
6 votes

Installing external Python packages in QGIS 3

This happened to me as well and I had both QGIS 2.14 and 3.8 installed then. I fixed the pip install issue in my OSGeo4W shell by uninstalling QGIS2.14 from my computer and re-installing QGIS3.8. If ...
user avatar
  • 61
6 votes
Accepted

geoserver.catalog.FailedRequestError: Tried to make a GET request to http://localhost:8080/geoserver/workspaces.xml but got a 404 status code

It appears that gsconfig-py3 is less relaxed about the format of the base URL than gsconfig was. If it doesn't end / it doesn't think to add one for you. so cat = Catalog("http://localhost:8080/...
user avatar
  • 75.1k
6 votes
Accepted

Polygon from QgsPoints - QGIS 3.8 python

In the line of the @BERA comment, this solves the problem in QGIS 3.8: The points must be created with 'QgsPointXY' (instead of 'QgsPoint'). The polygon must be created with 'fromPolygonXY' (instead ...
user avatar
6 votes
Accepted

Converting ArcGIS Spatially Enabled Dataframe to GeoJSON

Neither the API documentation nor dir(pd.DataFrame.spatial) has any indication that there is a to_geojson() method. So there is no direct way to do this as far as I know. However, instead of using ...
user avatar
  • 1,316
5 votes

Where can I find GDAL Python bindings for Python 3.4?

If you are on Windows you could give the precompiled wheels by Christoph Gohlke a try, he has a stable 1.11 with bindings for Python 3.4 listed. If you are on Linux your best bet is compiling from ...
user avatar
  • 9,470
5 votes
Accepted

How to let ogr/gdal CreateLayer() create a `geom` field instead of `wkb_geometry`?

As you can see from http://gdal.org/python/osgeo.ogr.DataSource-class.html#CreateLayer, CreateLayer support also "options" which are "None" by default. The papszOptions argument can be used to ...
user avatar
  • 52.5k
5 votes

geopandas can't import

Had the same problem and ended with installing python3 with anaconda, and then installed geopandas with conda install -c conda-forge geopandas conda-forge is community curated packaging for python ...
user avatar
  • 151
5 votes

Using OSGeo4W shell with Python 3

Please make sure that py3_env to initiate the python with OSGEO Shell is not working. The right command is pythonw if you have the current version of QGIS (3.20).
user avatar
5 votes

ArcPy Calculate Field Management with Variable

Your expression shouldn't include variable names. You're writing: "(+DemoField+ * !TractPercent!) / !BufferPOP!" but it should be: "(!{}! * !TractPercent!) / !BufferPOP!".format(DemoField.name)
user avatar
  • 4,068
5 votes
Accepted

Visualizing GPS points on interactive map

You can visualize your data on a map using folium. Please visit Documentation. (You must also have/install jupyter package. Installing Jupyter Notebook) Then this script displays your data on an ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible