Questions tagged [python]
Python is an open source interpreted programming language used in many GIS programs.
11,119
questions
143
votes
5
answers
28k
views
Accessing ArcObjects from Python
I would like to be able to script some things that are not exposed via arcgisscripting or ArcPy.
How do I access ArcObjects from Python?
106
votes
14
answers
174k
views
Installing GDAL with Python on Windows
Can anyone explain how to install GDAL/OGR with Python on Windows?
I have Windows Vista and I have tried following the information on the website and it does not seem to bind the *.exe files for me.
...
93
votes
26
answers
129k
views
Python GDAL package missing header file when installing via pip
I asked this question on Stack Overflow before I realised this site existed. As this site it more appropriate, I'll ask it here too.
I'm trying to install gdal from pip pip install gdal inside a ...
85
votes
10
answers
180k
views
Converting projected coordinates to lat/lon using Python
This site returns
Point:
X: -11705274.6374
Y: 4826473.6922
when you search with the first key value of 000090, as an example. I assume that this is a spatial reference.
I am looking for instructions, ...
76
votes
12
answers
15k
views
Alternatives to using ArcPy
I seem to use ESRI's ArcPy site package for virtually all of my Python geoprocessing. To ESRI's credit, these are an incredible suite of tools that can help accomplish a great deal. However, I would ...
66
votes
2
answers
167k
views
Reading shapefile in Python
My question is an extension of Vertical lines in a polygon shapefile. Kindly refer to that question first.
What you will see is a method of generating vertical lines with respect to the bounding box, ...
61
votes
9
answers
58k
views
Finding nearest point in other GeoDataFrame using GeoPandas
I've got two geodataframes:
import geopandas as gpd
from shapely.geometry import Point
gpd1 = gpd.GeoDataFrame([['John',1,Point(1,1)],['Smith',1,Point(2,2)],['Soap',1,Point(0,2)]],columns=['Name','ID'...
55
votes
6
answers
70k
views
How to call gdal_translate from Python code?
Is it possible to use some gdal API to call gdal_translate from Python code? I do not mean simply executing the gdal_translate.exe from the file system, but rather call it somehow in code so I do not ...
55
votes
3
answers
27k
views
Smoothing polygons in contour map?
Here is a contour map for which all the polygons of levels are available.
Let ask how to smooth the polygons keeping all vertices preserved in their exact locations?
Indeed the contour is made on ...
49
votes
17
answers
36k
views
Learning Python programming with generic GIS goals in mind?
In your opinion, what is the best book/site to learn Python with GIS goals in mind?
By "best", I mean:
not very long (book)
easy to understand (book/site)
good practical examples (book/site)
For ...
46
votes
1
answer
33k
views
Getting pixel value of GDAL raster under OGR point without NumPy?
I am working on a computational model of the abundance of wild pollinators across a landscape. The model itself is complete, and I am now struggling with a post-processing step.
I have my GDAL ...
44
votes
3
answers
40k
views
Transforming Shapely Polygon and MultiPolygon objects
Is there an easy way of transforming Shapely objects (namely, Polygons and MultiPolygons) from one projection to another without having to dig around and extract coordinates by hand?
In fact, I don'...
41
votes
3
answers
28k
views
Is it possible to look at the contents of Shapefile using Python without an ArcMap license?
I wondered if it is possible to look at the contents of a shapefile using Python without having and ArcMap license. The situation is that you can create shapefiles from many different applications, ...
40
votes
5
answers
68k
views
How to write Shapely geometries to shapefiles?
Can someone demonstrate a simple way to write geometry data-structures from shapely into shapefiles? I am particularly interested in polygons with holes and linestrings. It would also be beneficial to ...
39
votes
6
answers
53k
views
How to get raster corner coordinates using Python GDAL bindings?
Is there a way to get the corner coordinates (in degrees lat/long) from a raster file using gdal's Python bindings?
A few searches online have convinced me that there is not, so I have developed a ...
38
votes
8
answers
57k
views
Setting all pixels with value <= 0 to "nodata" in DEM raster [closed]
I have a DEM raster with pixel values between about 3000 and -0.0003.
I need to set all pixel with a value of 0 and smaler (<=0) to "nodata" (for later raster calculations and to reduce the ...
38
votes
5
answers
60k
views
Writing numpy array to raster file
I'm new to GIS.
I have some code that converts infrared images of Mars into thermal inertia maps, which are then stored as 2D numpy arrays. I've been saving these maps as hdf5 files but I'd really ...
38
votes
4
answers
29k
views
Simple thematic mapping of shapefile using Python?
I wish to visualize geographical data in Python, without using ArcGIS/ArcPy, and make a map.
On the internet I found how to make a thematic map using Python:
Here is some code that I tried:
...
37
votes
3
answers
27k
views
What is the proper syntax and usage for ArcGIS "in_memory" workspace?
I am unclear how best to use the in_memory workspace in ArcGIS. The best resource I have found on the subject is from ESRI on Using in-memory workspace. Unfortunately, the help section is not very ...
37
votes
7
answers
24k
views
Nearest neighbor between point layer and line layer? [closed]
I've asked this question several times on stackoverflow and irc between #qgis and #postgis and I also tried to code it or implement it my self in postgis with no real answer.
Using programming (most ...
35
votes
4
answers
42k
views
Python Script examples for geoprocessing shapefiles without using arcpy
I would like to use a Python script that is not based on arcpy to do things like query a shapefile by attributes, create new layer from selection, and calculate areas of a polygon and convert ...
34
votes
4
answers
63k
views
Fully load raster into a numpy array?
I have been trying to check my filters on DEM raster for pattern recognition and it is always resulting in missing last rows and columns(like..20).
I have tried with PIL library, image load. Then with ...
34
votes
10
answers
17k
views
How do I develop my GIS programming skills?
I would like to develop my GIS programming skills, where do I start? People say learn C++ or Python but where can I learn this in a geographic context? Tutorials or anything would be very helpful, as ...
33
votes
5
answers
100k
views
Finding if two polygons Intersect in Python?
I'm looking for an algorithm, a high level solution, or even a library which can help me determine if two polygons intersect, in Python.
I have the vertices of the two polygons (These are single part ...
32
votes
3
answers
24k
views
Creating polygon grid using GeoPandas
I'm working with a GeoDataFrame of points and I need to create a grid of rectangular polygons.
I know how to have bounds of the GeoDataFrame with gdf.geometry.bounds. Now using this information and ...
32
votes
4
answers
68k
views
Shapely not installing correctly
I am trying to run Shapely on a new machine, and tried both installing it from source, using the installer on its webpage, and using pip install shapely. Every reference I try to make from the library ...
31
votes
10
answers
16k
views
Seeking Python tools/modules/add-ins for GIS?
With ArcGIS 10, Python has become the de-facto scripting language for ESRI. While leading Open source software like QGIS, GeoServer, PostGIS all supports Python. Thus it became important to know/learn ...
31
votes
2
answers
32k
views
Joining (concat) list of similar dataframes in geopandas?
I have a list of dataframes, all of the same structure and all are polygons.
How can I add them all together using geopandas?
31
votes
6
answers
21k
views
Installing QGIS3 on Mac?
Kyngchaos installer is not finding python3. I installed python3 using HomeBrew and is not located at /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/bin/python3.6
How do I ...
31
votes
4
answers
38k
views
Getting polygon areas using GeoPandas
Given a GeoPandas's GeoDataFrame containing a series of polygons, I would like to get the area in km sq of each feature in my list.
This is a pretty common problem, and the usual suggested solution in ...
31
votes
6
answers
4k
views
How to buffer raster pixels by their values?
The pixels to the left represent tree locations and their associated crown radii (i.e. pixel values ranging from 2 - 5). I would like to buffer these raster pixels by their crown radius value. The ...
30
votes
9
answers
3k
views
Value of a Python programming course
I am considering upping my programming skills by taking a python geoprocessing course through ESRI. Before I part with the hefty registration fee, I would like to get your opinion on the value of 24 ...
30
votes
5
answers
8k
views
OpenSource Remote Sensing Tools for Classifying Roofs
with envi image processing and classification tools, you can get roofs from images with some spectral value and then you can convert it some vector data for your app.
in python with OpenCV which have ...
30
votes
2
answers
7k
views
Using OGR and Shapely more efficiently? [closed]
I'm looking for some suggestions about how to make my python code more efficient. Normally efficiency doesn't matter for me but I am now working with a text file of US locations with over 1.5 million ...
29
votes
2
answers
4k
views
Creating sector lights in QGIS?
I'm using QGIS 2.18. I need to create sector lights for navigational purposes on a map.
I have the light sector data as fields giving becon_id, start degree, end degree and color in a shapefile with ...
29
votes
8
answers
56k
views
Returning lat and long of centroid point with GeoPandas
I would like to return the lat, lon or x, y from the point object in the following series as I plan to link them with an API I built that links OSM and NetworkX. The centroids will be added as new ...
29
votes
5
answers
29k
views
Using ogr2ogr to convert GML to shapefile in Python?
I am trying to convert a GML to an ESRI shapefile using ogr2ogr utility in a python script.
I have successfully installed the GDAL/OGR package via osgeo but I am now struggling to find/understand ...
29
votes
3
answers
38k
views
Clipping raster with vector layer using GDAL
I have installed GDAL using the Osgeo installer. How can I clip a raster layer with a vector layer programmatically? Is there any GDAL API available which can help me with this? I am using Python.
28
votes
8
answers
29k
views
Calculating area in km² for Polygon in WKT using Python
I have polygons in WKT that looks like this
POLYGON ((24.8085317 46.8512821, 24.7986952 46.8574619, 24.8088238 46.8664741, 24.8155239 46.8576335, 24.8085317 46.8512821))
I would like to calculate the ...
28
votes
3
answers
50k
views
Converting GeoJSON to Python objects? [closed]
New to the site, and to geoJSON, and to python.
My goal is to read in a file with geoJSON data, and use it to generate shapes to be used in an application that is using python scripting. Python ...
27
votes
3
answers
23k
views
Accessing feature classes in file geodatabases using Python and GDAL
I am trying to access a vector dataset in a ESRI File Geodatabase using Python + GDAL.
I have successfully compiled GDAL with the file geodatabase API. The FileGDB driver is working correctly since ...
26
votes
3
answers
13k
views
Finding all neighbors using GeoPandas
I am wondering whether it is possible to identify all neighbors to each polygon using only Python (with e.g. GeoPandas) in the same way that can be done with Python in QGIS (Find neighbors polygon).
26
votes
4
answers
28k
views
Filter by bounding box in GeoPandas
I have a GeoPandas DataFrame in EPSG:4326 and I'd make a new DataFrame consisting of all the rows that fall within a certain bounding box.
First I get the bounding box that I care about (which is ...
26
votes
3
answers
15k
views
Is it possible to get the EPSG value from an OSR SpatialReference class using the OGR Python API?
When reading a layer from a OGR PostGIS connection I can get the SpatialReference of the layer, but is it possible to get the EPSG value? Is there any documentation on this?
For example:
lyr = conn....
26
votes
1
answer
2k
views
What does the adoption of Python by NVIDIA for GPGPU mean for GIS?
Today NVIDIA announced support for the Python language on its flavor of GPGPU (CUDA).
Manifold GIS uses CUDA to enable some accelerated raster operations but it is not a programmable environment and ...
25
votes
6
answers
34k
views
What LiDAR processing tools are available in Python?
I have been using FUSION and the command line FUSION Lidar Toolkit (LTK) to process LiDAR data. A broad Google search ("Lidar Python") yielded libLAS and pyLAS as Python LiDAR libraries, however, ...
25
votes
5
answers
29k
views
Adding attribute field to existing Shapefile via Python without ArcGIS
I have a Python script that adds an attribute field to a Shapefile if doesn't exist. This is easy to do with ArcGIS (graphically or via Python), but I'm looking for something that doesn't depend on ...
24
votes
4
answers
19k
views
Adding GeoPandas Dataframe to PostGIS table?
I have a simple GeoPandas Dataframe:
I would like to upload this GeoDataframe to a PostGIS table. I have a Database setup with the PostGIS extension already but can't seem to add this Dataframe as a ...
24
votes
4
answers
2k
views
Recommend topics to be included in a Computer Science for Geospatial Technologies course
I will be instructing a course at the local university titled Computer Science for Geospatial Technologies. This is an introductory course meant to introduce computer science concepts to geospatial ...
24
votes
2
answers
34k
views
How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?
I'm new to GIS and having a basic beginner problem. I've got data in the form of a geopackage .gpkg from GADM.org. I can read in and use the data without problem using Geopandas (via built-in Fiona)....