Hot answers tagged

69

Just to elaborate on the comment on the above answer that It appears that the uninstall option no longer exists in the osgeo4w.exe installer. As of today, there is an option to uninstall but you have to play chicken as if you're going to install because the uninstall option doesn't appear until quite late in the install process. I ran C:\OSGeo4W64\bin\...


47

OSGeo: OSGeo is an umbrella organisation (Foundation) that supports many Open Source GIS Projects. Some of the more well known ones are: QGIS, GeoServer, and OpenLayers. Being part of OSGeo gives a project some support, through assistance with governance, and potentially funding. But it also gives a project some legitimacy and assurance. Being part of ...


13

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 included but provide notices to state that they are deprecated and will be going away. If you are using GDAL 1.7 bindings, you should update your imports to ...


11

The issue is resolved. The issue was I misread the documentation. On a second read, the rasterio.mask documentation clearly states that polygons should be a list of GeoJSON-like dicts. I found the following snippet of code to generate those lists from this answer: geoms = [feature["geometry"] for feature in shapefile] Here is the the full code that is ...


9

To cut an image (tif file) by using GDAL python library, and without gdalwarp utility, you need to find row and column raster indexes of top point [p1=(minX, maxY)] and bottom point [p2=(maxX, minY)]. The formulas, based in your code, are: i1 = int((p1[0] - xOrigin) / pixelWidth) j1 = int((yOrigin - p1[1] ) / pixelHeight) i2 = int((p2[0] - xOrigin) / ...


8

Get the package from NuGet and then you need to call static methodGdalConfiguration.ConfigureGdal() from GdalConfiguration.cs/vb at startup to set process environmental variables. Call GdalConfiguration.ConfigureOgr() if you want to use OGR as well.


8

Look at the OSGeo: Open Source Geospatial Foundation site. You will see that they support Desktop applications (GRASS GIS, QGIS,...), Web Mapping projects (OpenLayers, GeoServer,MapServer ...), Geospatial Libraries (GDAL/OGR, GEOS, PostGIS,...) , ... OSGeo4W is simply a binary distribution of these libraries/softwares for Windows environments (OSGeo4W ...


8

Install the python missing module: yaourt -S python-gdal Then install the pip package: pacman -S python-pip and install the missing modules using: pip install MissingModuleName


7

When you start with a Python module, there are several solutions to find the available functions. One of them is dir: geom = feat.GetGeometryRef() print dir(geom) ['AddGeometry', 'AddGeometryDirectly', 'AddPoint', 'AddPoint_2D', 'Area', 'AssignSpatialReference', 'Boundary', 'Buffer', 'Centroid', 'Clone', 'CloseRings', 'Contains', 'ConvexHull', 'Crosses', '...


7

The python module glob is used to get all file names according to the pattern that you give it. The documentation for glob can be found here. Within your script you would use glob like this: in_directory = r'C:\Data' files_to_process = glob.glob(os.path.join(in_directory, '*.tif') for data_path in files_to_process: raster_dataset = gdal.Open(data_path, ...


6

See the cookbook print(geom.GetGeometryName())


6

I found a perfect answer for my question in a post I found in Alex Tereshenkov's blog. The post contains a python script for printing the FGDB's domains in python interpreter: from __future__ import print_function import json import xml.etree.ElementTree as ET import ogr gdb_path = r'C:\GIS\data\Adv.gdb' ds = ogr.Open(gdb_path) res = ds.ExecuteSQL('select *...


6

There is a fairly large list of OSGeo Docker images here that are built on a variety of different base images. The page also contains information on the source, whether or not the image is on Docker Hub, and commentary on the project goals and status (e.g., under testing, works/doesn't work). One of these Docker images should fit your needs, or at least ...


5

Might add to the above entries with my current complete-removal workflow: Delete C:\OSgeo4w64 Delete C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OSGeo4W Delete C:\Users\%USER%\documents\grassdata Delete C:\Users\%USER%\AppData\Local\QGIS There will also be a shortcuts folder on your desktop to delete. There may be other app-specific folders to ...


5

There is nothing in your Question to suggest that you need to perform a conversion. Instead, I would try: point = osgeo.ogr.Geometry(osgeo.ogr.wkbPoint) point.SetPoint(0, 112.73091137, -7.2377761) The original values look like they are from a projected coordinate system whereas you appear to be receiving Twitter data in a geographic coordinate system but ...


5

This sounds like you have multiple python installations, and GDAL is installed on one and not the other. Try the following (which I have based upon this). Create a text file within your python installation site packages folder C:\Python27\Lib\site-packages called usrlocal.pth. In this text file insert one line giving the path to your second python ...


5

Try this, pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`


5

If the data is now in your database you can use ST_MakePoint or ST_GeomFromText to construct a geometry object from your x and y columns, e.g.: --ST_SetSRID is also used here as ST_MakePoint will construct a point with an unknown SRID select ST_SetSRID(ST_MakePoint(x,y),26913) from data or: --Here, you have to concatenate your x and y values to form a WKT ...


5

I don´t wan to be punctilious with the code, but you don´t need to loop all the features, the shapefile always store only one geometry type: # get the data layer layer = datasource.GetLayer() # get the first feature feature = layer.GetNextFeature() geometry = feature.GetGeometryRef() print(geometry.GetGeometryName()) Greetings


5

I solved this problem by installing via Python PIP pygdal package. Firstly you need to check Gdal version installed on the machine, and install proper pygdal. $ gdalinfo --version GDAL 2.1.3, released 2017/20/01 $ pip install "pygdal>=2.1.2,<2.1.3"


5

I tested your code and stripped the problem down to the paths you are using. The error seems to be the forward slashes (/) that confuse your windows python installation. You should use backslashes on windows and use them as escaped symbol (eg. double backslash \). I updated your code with the paths of my system (an OSGeo4W64 installation), you can change ...


5

I had the same problem and solved it by: removing both /Library/Frameworks/GDAL.framework and /Library/Frameworks/GEOS.framework downloading the old QGIS 3.0 installer from here and installing only GDAL_complete, not QGIS itself. after that, downloading the latest unified installer (3.4.3-2 as of writing, same page above) and runing the setup again. ...


5

You need to open the second file in update mode, then dereference it to save and close it. roads = gdal.Open('road_lines.tiff', gdal.GA_Update) roads.SetProjection(prj) del roads # save, close Another method to apply a projection to a GeoTIFF file is to use the geotifcp utility.


5

Domains will be supported in GDAL 3.3 and they are already available in the current development version (the "main" branch). See https://gdal.org/drivers/vector/openfilegdb.html#vector-openfilegdb Field domains (GDAL >= 3.3) Coded and range field domains are supported. The domain support has been added into FileGDB and OpenFileGDB drivers and ...


4

Go to the Python GDAL/OGR Cookbook 1.0 documentation and you'll have the answers to all your questions: from osgeo import ogr driver = ogr.GetDriverByName('ESRI Shapefile') shape = driver.Open('my.shp') layer= shape.GetLayer() # the crs crs = layer.GetSpatialRef() and you can also create a projection file if the shapefile does not ...


4

I see this: and my options in the OSGeo4W Setup ('advanced install') that are probably relevant were:


4

You weren't requesting the first feature, you were requesting a feature with an FID of "0" and your WFS doesn't have a feature with an FID of "0". Why: The ogr.Layer.__getitem__ method which allows element and slice access, calls the ogr.Layer.GetFeature method. GetFeature fetches a feature by its identifier, not by its position. This is intentional, so ...


4

1) I just don't know how to convert .geojson file to .shp. This is a one of the bases of ogr Python. If you have a geometry, it is very easy to convert it to a shapefile # geojson is GeoJson Polygon from osgeo import ogr output = "geojson.shp" driver = ogr.GetDriverByName('ESRI Shapefile') if os.path.exists(output): driver.DeleteDataSource(output) ...


4

1) In the first case, we have only the points and we need to construct a grid (regular or irregular) by interpolation. 2) In the second case, the raster is already a grid (regular) but Matplotlib only knows the x,y dimension of the image that you can plot from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm ...


4

Thanks very much @sgillies, I solved the problem as such: def geom_type(): shapefile_location = r"E:\Cameron\Python\GDAL\SHP\Cadastral_Parcels\Parcels.shp" shapefile = ogr.Open(shapefile_location) layer = shapefile.GetLayer() for feature in layer: geometry = feature.GetGeometryRef() print(geometry.GetGeometryName()) ...


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