Questions tagged [python]

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

Filter by
Sorted by
Tagged with
18
votes
1answer
25k views

GDAL/Python: How do I get coordinate system name from SpatialReference?

In Python, using GDAL, I've extracted a raster's projection as a WKT string as follows: wkt = dataset.GetProjection() # wkt is 'PROJCS["GDA_1994_Transverse_Mercator",GEOGCS["GDA_1994",DATUM["GDA_1994"...
18
votes
3answers
22k views

How to install 3rd party python libraries for QGIS on Windows?

How can I use 3rd party libraries on QGIS plugins on Windows? I've developed a plugin that uses rasterio and numpy for a customer, but he's having problems installing rasterio and numpy. Actually ...
18
votes
8answers
8k views

What software to use for making digital elevation models from UAV aerial imagery?

I have a an unmanned aerial vehicle (UAV, also called a drone) and would like to use it to create a digital elevation model and orthomosaic over a smaller area (10 km2). My platform will be able to ...
18
votes
4answers
13k views

Is there a Python Lib for requesting WMS/WFS and saving as image/PDF?

i am wondering whether there's Python open-source GIS lib which has APIs to support call WMS/WFS from another GIS server (e.g., GeoServer) and then save the response data(WMS Basemap and WFS layer) as ...
18
votes
2answers
12k views

Problem with import qgis.core when writing a stand-alone PyQGIS script

I am trying to write a stand alone python script in windows 7 that uses qgis.core and various other qgis libraries. I have found an old question on this subject here: Writing standalone Python ...
18
votes
1answer
1k views

Calculating Focal Statistics for Special Neighborhood?

I'm looking to calculate focal statistics for each cell of a raster, within a neighborhood of a specified criteria. Background - I have three binary rasters, each representing a single vegetation ...
17
votes
5answers
42k 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 ...
17
votes
9answers
7k views

how to overlay shapefile and raster?

I have a shapefile with polygons. And I have a global raster file. I want to overlay the shapefile's polygons onto the raster grid and calculate the mean raster value for each polygon. How can I do ...
17
votes
4answers
14k views

GeoPandas: Find nearest point in other dataframe

I've got 2 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','...
17
votes
1answer
9k views

Why close a dataset in GDAL Python?

I see quite often in Python GDAL code that people close datasets at the end of their script. Why does it makes sense to close a dataset in Python GDAL? Are there any consequences if I don't do it? ...
17
votes
2answers
4k views

Reprojecting WGS 1984 Web Mercator (EPSG:3857) in Python with GDAL

I am reprojecting rasters in python using GDAL. I need to project several tiffs from geographic WGS 84 coordinates to WGS 1984 Web Mercator (Auxiliary Sphere), in order to use them later in Openlayers ...
16
votes
5answers
4k views

Seeking Python library (other than ArcPy) for geoprocessing such as buffer? [closed]

Excluding ArcPy, is there any python library which can do geoprocessing, such as buffer/intersect, with shapefiles?
16
votes
3answers
14k views

Generating GeoJSON with Python

I want to programmatically create a GeoJSON file using polygons from a shapefile but adding attributes from my own application. This is easily done for a shapefile: def create_data_dayer(self,...
16
votes
4answers
4k views

Python module to delete SHP features (without Desktop GIS installed)

I have a piece of software (not Arc) that runs nightly on a non-production machine which updates shapefile features from an external database. Periodically I would like to delete all of the features ...
16
votes
4answers
10k views

Get all vertices of a polygon using OGR and Python

I'm having a little trouble with the Python OGR API. What I am trying to do is get all the coordinates of each vertex of the outer ring of a polygon. This is what I have so far: import osgeo.ogr ...
16
votes
3answers
1k views

Geotransformation for polar stereographic?

I'm currently working to import CANGRID climate data (provided as Surfer Grid ascii, ".grd" files) into ArcGIS. The grid is 95 rows by 125 columns in size.Metadata provides lat/lon of origin (lower ...
16
votes
1answer
2k views

How can I utilize NumPy arrays to optimize big data geoprocessing?

I'm interested in learning how to utilize NumPy arrays to optimize geoprocessing. Much of my work involves "big data", where geoprocessing often takes days to accomplish certain tasks. Needless to ...
15
votes
8answers
31k views

How to get X Y coordinates and cell value of each pixel in a raster using Python?

I'm really new to Python and I would like to know whether there is a quick method to get cell values of a raster pixel by pixel and the coordinates (map X Y coordinate of centre of each pixel) using ...
15
votes
5answers
9k views

How can I programmatically get the path of “Python.exe” used by ArcMap

I am working with an add-in of ArcMap in C#. From C# code, I have executed some Python scripts. Now, to run those script, I have hard-coded python path. But this is not portable. So, I want to get the ...
15
votes
2answers
7k views

Polygon overlay with Shapely

I'm trying to capture all the non-overlapping polygons indicated below using Shapely (given polygons A,B & C). Moreover, I'm hoping to do so without iteration, testing for intersect etc. The ...
15
votes
6answers
4k views

Pure Python Library for Geometry Operations

Does anyone know of a pure Python (no C or Java dependencies) library for doing geometry operations such as buffer, union, intersects, etc? I'm looking for something that is Google AppEngine ...
15
votes
3answers
1k views

Ecological geospatial conundrum

I am looking for a different, more elegant solution to a spatial statistics problem. Raw data consists of an x-y coordinate for each individual tree (i.e. converted to a point .shp file). Although ...
15
votes
4answers
8k views

Smoothing/reinterpolating raster with GDAL?

Short: I want to change the resolution of a raster and smooth the gray ramp like shown in the images bellow. The preference is to use GDAL, PIL or Numpy. Description: I'm kriging points into rasters ...
15
votes
1answer
2k views

How to see what lines have changed in an updated Shapefile?

I'm using my county's GIS data to update the roads in OpenStreetMap. I have a copy they published last year and one that was just published, and I'd like to find all the LineStrings that have either ...
14
votes
4answers
29k views

Define Workspace for SDE Connection in Python

How do we define SDE Connection for workspace in Python Scripting?
14
votes
5answers
8k views

Recommended programming language for remote sensing?

I am beginning studies that hopefully will lead to a long career as a remote sensing specialist. I am currently working with ArcGIS for some applications and learning ENVI for others. I have ...
14
votes
2answers
8k views

Get field names of shapefiles using GDAL

I use GDAL in Python for importing shapefile. I want to know the field names for the file, my current way is: fields = [] for i in range(1, layer.GetFeature(0).GetFieldCount()): field = layer....
14
votes
2answers
27k views

Converting projected geoTiff to WGS84 with GDAL and Python

Apologies if the following question is somewhat stupid, but I am only VERY new to this whole GIS thing. I am trying to convert some projected geoTiff images to WGS84 using gdal in python. I have ...
14
votes
2answers
19k views

How to calculate the bounding box of a geojson object using python or javascript?

I have django app with leaflet on the frontend and I need to calculate the bbox of a geojson object so that I can pass the coordinates to map.fitBounds() I have tried some libs as well as trying the ...
14
votes
2answers
11k views

How to draw polygons from the python console?

I've been visiting and revisiting the page on geometry handling in the PyQGIS Cookbook: http://documentation.qgis.org/2.0/en/docs/pyqgis_developer_cookbook/geometry.html but can't seem to figure out ...
14
votes
7answers
3k views

How to implement value-by-alpha map in GIS?

I've been doing some background reading about cartograms recently and stumbled upon interesting alternative - value-by-alpha maps. Concept is described in more details here and full paper is ...
14
votes
1answer
7k views

Converting Twitter tweets into points?

I've been doing some research on using R to datamine twitter, but I haven't really found an answer or a decent tutorial for my question. I'm interested in pulling tweets from twitter with a certain ...
14
votes
3answers
20k views

gdal ImportError in python on Windows

Trying to import gdal for Python 2.7.3 on Windows XP: >>> import gdal Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-...
14
votes
3answers
5k views

Converting LAS file to numpy array?

I have begun learning how to manipulate LAS data in python and wanted to see how others handle LAS files. I would like to read the points (I am using a numpy array), and filter out classes 1 and 2 (...
14
votes
1answer
951 views

Watermarking photos using geotag and creating shapefile from coordinates?

I have geotagged photographs and I would like to place a watermark of the photos location on the front for easy reference as well as creating a shapefile from the coordinates. Does anyone know of ...
14
votes
1answer
687 views

How to use GDAL with PyPy?

I am trying to optimize my python code using pypy. While I am able to import most libraries and run succesfully, I am not able to import GDAL libraries. The same libraries when imported in Python 2.7 ...
14
votes
1answer
475 views

Python increasing the filesize of my .mxd

I have a geoprocessing script that runs the following.. arcpy.AddMessage("TEST...") Yes just one line of code. A blank .mxd starts at 391kb for me as I run my script and save the filesize increases....
14
votes
1answer
4k views

Getting pixel values at single point using rasterio

To get a single pixel value at a point in a raster using rasterio, there is an example here: https://github.com/mapbox/rasterio/pull/275 However, is there a direct API within rasterio (and not the ...
14
votes
5answers
17k views

Clustering trajectories (GPS data of (x,y) points) and mining the data

I've got 2 questions on analyzing a GPS dataset. 1) Extracting trajectories I have a huge database of recorded GPS coordinates of the form (latitude, longitude, date-time). According to date-time ...
14
votes
1answer
1k views

Creating nanoscale DEM with GDAL

A bit of a strange question perhaps, but let me give you a breif explanation of the background before my actual questions: Atomic force microscopy (AFM) is a method that, in short (and to my limited ...
14
votes
0answers
1k views

Converting raster (array) to NetworkX graph and do * search? [closed]

I want to use a slope-raster for a a_star path analysis in NetworkX. I am using Python for this project. My test raster looks like this First I read in the raster with GDAL input_raster = "slope5....
13
votes
2answers
11k views

Area in KM from Polygon of coordinates

I have polygons from coordinates in (python shapely) 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)) ...
13
votes
4answers
23k views

What's the difference between vincenty and great circle distance calculations?

Python's geopy package features two distance measurements techniques: Great Circle and Vincenty's formulae. >>> from geopy.distance import great_circle >>> from geopy.distance ...
13
votes
6answers
9k views

How do I iterate through every cell in a continuous raster?

See this link for more details. The Problem: I want to loop through a continuous raster (one that has no attribute table), cell by cell, and get the value of the cell. I want to take those values ...
13
votes
1answer
9k views

Import shp to Postgis using Python and ogr

I just export a Postgis Table to shp using this tips but I'm not able to import a shp to Postgis using the same library(ogr). Any idea? Thanks a lot f.
13
votes
2answers
12k views

How to get field names in pyqgis 2.0

I am trying to change an plugin from QGIS 1.8 to 2.0. In the 1.8 version I create a table of the field names like this: layer = vlayer provider = layer.dataProvider() feat = QGSFeatrue() allAttrs = ...
13
votes
4answers
4k views

Looking for a pythonic way to calculate the length of a WKT linestring

I was quite unsatisfied with Calculating Length of Linestrings in WGS84 in Miles. It kept me wondering if there is a more convenient, Pythonic way to calculate the length of a WKT linestring according ...
13
votes
3answers
8k views

Understanding use of spatial indexes with RTree?

I'm having trouble understanding the use of spatial indexes with RTree. Example: I have 300 buffered points, and I need to know each buffer's intersection area with a polygon shapefile. The polygon ...
13
votes
4answers
3k views

Python resource for remote sensing? [closed]

I am looking for a good resource (MOOC, book, etc..) to teach Python for remote sensing applications. I am already familiar with http://www.rsgislib.org/ - are there any other resource out there for ...
13
votes
3answers
9k views

Gdal: clipping a raster with another raster

I'm writing a simple utility to crop batches of multi-band geotiff raster files to the same (smaller) area. Using gdalwarp, I can easily crop a file using a single-polygon clipping shapefile: ...