Questions tagged [python]

Python is an open source interpreted programming language used in many GIS programs.

Filter by
Sorted by
Tagged with
141 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?
user avatar
  • 27.5k
106 votes
14 answers
173k 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. ...
92 votes
26 answers
127k 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 ...
user avatar
  • 1,021
84 votes
9 answers
176k 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, ...
user avatar
  • 951
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 ...
user avatar
  • 50.3k
63 votes
2 answers
161k 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, ...
user avatar
  • 1,361
61 votes
9 answers
57k 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'...
user avatar
  • 1,211
54 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 ...
53 votes
6 answers
69k 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 ...
user avatar
  • 579
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 ...
user avatar
  • 733
44 votes
3 answers
38k 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'...
user avatar
41 votes
3 answers
27k 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, ...
user avatar
  • 413
40 votes
5 answers
67k 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 ...
user avatar
39 votes
9 answers
56k views

How to set all pixels with value <= 0 to "nodata" in DEM raster?

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 ...
user avatar
  • 7,695
39 votes
6 answers
52k 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 ...
user avatar
  • 1,837
39 votes
10 answers
51k views

Generate points that lie inside polygon

I have polygon feature and want to be able to generate points inside it. I need this for one classification task. Generating random points until one is inside the polygon wouldn't work because it's ...
user avatar
  • 399
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 ...
user avatar
  • 1,837
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: ...
user avatar
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 ...
user avatar
  • 50.3k
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 ...
user avatar
  • 8,442
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
62k 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 ...
user avatar
  • 787
33 votes
5 answers
98k 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 ...
user avatar
33 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 ...
user avatar
  • 471
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 ...
user avatar
  • 1,368
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
4 answers
36k 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 ...
user avatar
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 ...
user avatar
  • 50.3k
30 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 ...
user avatar
  • 859
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
3 answers
23k 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 ...
user avatar
  • 1,386
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 ...
user avatar
  • 22.2k
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 ...
user avatar
  • 309
29 votes
2 answers
30k 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?
user avatar
  • 1,614
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 ...
user avatar
29 votes
8 answers
54k 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 ...
user avatar
  • 8,442
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.
user avatar
  • 1,766
28 votes
8 answers
28k 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 ...
user avatar
  • 441
28 votes
3 answers
49k 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 ...
user avatar
28 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 ...
user avatar
  • 2,626
26 votes
3 answers
12k 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).
user avatar
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....
user avatar
  • 728
26 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 ...
user avatar
  • 263
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 ...
user avatar
  • 35.4k
25 votes
4 answers
27k 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 ...
user avatar
  • 2,973
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, ...
user avatar
  • 50.3k
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 ...
user avatar
  • 39.9k
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
33k 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)....
user avatar

1
2 3 4 5
221