Tag Info

New answers tagged

2

I believe you can to it with one ogr2ogr command. The following solution should work for all sort of geometries and therefore I tested it with a two-part multipolygon, one of the parts having a hole. Background: With -dialect SQLite GDAL tools can utilize all the SQL functions of Spatialite https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html. ...


0

Finally I found the solution. For navigation-like map could use EPSG:4326 that work with normal latitude/longitude coords system gdalwarp -t_srs EPSG:4326 -te 12.47302 37.55202 13.90263 38.67817 -ts 1024 1024 input.tif output.tif


3

I found it, this dirty hack is not elegant at all but it works great, my command-line solution as follows: ogr2ogr -f CSV tmp.csv your.shp -lco GEOMETRY=AS_WKT -s_srs EPSG:4326 -t_srs EPSG:4326 -overwrite cat tmp.csv | sed -e '1,1d' | tr ',' '\n' | sed 's/[A-Za-z"()]*//g' | tr ' ' ',' | sed 's/^,//' > your.shp.csv One caveat, you just need to avoid ...


1

Have a look at VTBuilder, found here: http://vterrain.org/Doc/VTBuilder/overview.html One of the supported formats is now ESRI ADF.


2

You can set the GDAL_MERGE process up with QGIS using the GUI and that might be a good way to start testing. Also, test on two tiles that are next to each other first. I reckon it's something to do with NODATA. Please post your command in your question so that we can see how you're achieving the merge.


0

Uhmm no, I was trying to do a better explanation of my question. Anyway, I eventually could do it using numpy and GDAL. I needed to get the pixels values within some polygons, so I convert the polygons to rasters and then I could easily perform different masks and calcs. I find this process really easy with arcpy, but no idea of how to do this with other ...


0

Base on your specification, i think ESRI ASCII raster format is the most suitable format. This link explain the basic structure of ESRI ASCII format : http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/spatial_analyst_tools/esri_ascii_raster_format.htm I hope you can figure out how the header and the value can match with your specification ...


0

Looking into your file, it has GCP points, and longitude and latitude subdatasets. But unfortunately the image is interrupted, and for the empty pixels, the coordinate values are also set to NODATA -9999. This makes the GCP interpolation impossible. A save way would be to save the subdataset to VRT format and eliminate the GCP with NODATA values, but these ...


0

Turns out to be a path issue. With the C ogrinfo, I can put the shapefile layer filenames sans path in the OGRVRTLayer. If I then run the C# ogrinfo, it can't find those shapefiles. However, if I put the full path of the shapefiles into the OGRVRTLayer, then both versions successfully read the virtual source.


1

Just worked out how to do this with gdal_calc.py - to get around issues with files with different dimensions (and resolutions) you can use a VRT. gdalbuildvrt -separate combined.vrt dem1.tif dem2.tif gdal_calc.py -A combined.vrt -A_band=1 -B combined.vrt -B_band=2 --calc="A-B" --outfile diff.tif


0

[WARNING: A gratuitous promotion of a product I am involved with] We have been working on exactly this. We have developed an application that has an advanced GUI for GIS (and other) data transformations. This uses GDAL/OGR in the back end. Some information can be found at https://www.geoactive.it Commercial use requires it to be purchased but we do have ...


0

well the winner is to not use the = sign. this works for anyone looking.. ogr2ogr -overwrite -t_srs EPSG:3978 -f "ESRI Shapefile" -dialect SQLite -where "GIVEN_CLASS LIKE 'CLAS% A" dst src indicating dialect + using -where + Like operator.


0

QGIS expects the CRS to either be defined within the dataset or by the user. If it doesn't have this information, it won't know what CRS to render the dataset in as the coordinates within the dataset itself could be rendered using any CRS.


1

Try something like that, where dx,dy are number of indexes: from osgeo import gdal file = gdal.Open( ’file.tif ’) def pixel(dx,dy): px = file.GetGeoTransform()[0] py = file.GetGeoTransform()[3] rx = file.GetGeoTransform()[1] ry = file.GetGeoTransform()[5] x = dx/rx + px y = dy/ry + py return x,y GetGeoTransform() function ...


0

Gdal probably has a handy function. Have you looked at these links? But knowing that the header of the image contains the bounding coordinates and projection information, you could calculate them yourself (not recommended unless you enjoy learning things the hard way). EX: I knew my pixel size was 30m. For point 3,4 from the origin it's simple algebra: 3x30 ...


0

So, I succeed to georeference a tif file with GDAL with the use of 4 gcps (ground control points). To do this reprojection, I use gdal in command line. First, use gdal translate like this : gdal_translate -of GTiff -gcp 0 0 -6.848326 45.501053 -gcp 6862 0 -6.490975 45.501503 -gcp 0 1379 -6.762872 45.377363 -gcp 6862 1379 -6.545354 45.382523 ...


1

Finally I managed to run ecw plugin inside geoserver version 2.7.2 Downloaded libecw source from http://meuk.technokrat.nl/libecwj2-3.3-2006-09-06.zip Applied this patch https://github.com/makinacorpus/libecw/blob/master/Source/C/NCSUtil/NCSPrefsXML.cpp.rej Ran ./configure, make and sudo make install commands to build. Override generated libs over ...


1

Use gdal_polygonize.py, ogr2ogr and ogrinfo in a loop. On linux (not tested): final=merged.shp for f in *.tif; do name=$(basename $f .tif) shp=${name}.shp gdal_polygonize.py $f -f "ESRI Shapefile" $shp ogrinfo $shp -sql "ALTER TABLE $name ADD COLUMN name character(30)" ogrinfo $shp -sql "UPDATE $name SET name='$name'" if [ -f $final ...


3

Use the ASCII to Raster tool. import arcpy arcpy.ASCIIToRaster_conversion("/path/to/file.asc", "/path/to/output.tif", "INTEGER") Note: A GeoTIFF is just a TIFF file with some extra metadata tags, and the only file extension that should be used for TIFFS in ArcGIS is .tif, not .tiff or .geotiff.


2

I'm not sure what NOAA thinks are the right coordinates, but I have no problem loading the file into QGIS, or reprojecting it to WGS84 with gdalwarp: QGIS uses this custom projection string: +proj=lcc +lat_1=25 +lat_2=25 +lat_0=25 +lon_0=265 +x_0=0 +y_0=0 +a=6371229 +b=6371229 +units=m +no_defs You can use the same string with pyproj.Proj(). where you ...


0

In case the question asked was still relevant, I managed to install Python-Gdal on Ubuntu 14.04 (Trusty) simply using: apt-get install python-gdal


1

Image Boundary plugin did not work for me either, therefore I used the same approach with GDAL. Nevertheless it only worked for me after changing the first step to: step 1: gdalwarp -srcnodata 0 -dstalpah -of GTiff foo1 foo2 I am working with Landsat8 band (where no data=0) and when using the -dstnodata function I get: band1 with no data = 'no data' ...


0

As @user30184 suggests, convert your shapefile to json and at the same time reproject it to WGS84 with: ogr2ogr -f GeoJSON -s_srs epsg:2180 -t_srs epsg:4326 wojeowdztwa.json wojewodztwa.shp Then, define the projection in your script like this: var projection = d3.geo.mercator() .center([21, 52]) .scale(2000) .translate([width / 2, height / ...


1

Openlayers and leaflet usually render tiles in World Mercator EPSG:3857. So you have to reproject your source file into that projection using gdalwarp, then start the tiling.


0

Projection matters more than format. If you are not getting enough precision, switch from a UTM projection to something centered more around you area. And if you try float64, you'll do better, but my guess it that you are then shaving yaqs for your use case. If you really want to preserve exact numbers, scale elevation and use ints.


2

I guess you have to swap the coordinates. It should be longitude latitude order. 45°E is not within UTM 32N (and within the extent of your source file), but 10°E will be. Apart from that, the manpage says: -te xmin ymin xmax ymax: set georeferenced extents of output file to be created (in target SRS by default, or in the SRS specified with -te_srs) ...


0

According to the source code, this is a problem that has been fixed in GDAL 2.0. Whether it has or not, you can get around it by pre-filling the new raster with you preferred nodata value: outFileRead=driver.Create(outFilePath,X,Y,1,dataType,options) tmp = gdal.AutoCreateWarpedVRT(outFileRead, src_wkt, dst_wkt) b = outFileRead.GetRasterBand(1) ...


5

Step 1 Make bit rasters for each of the unique classes. This can be a 1-band rasters for each class, or a single raster with a band for each class (e.g. GeoTIFF). If using GTiff, you can use the creation option NBITS=1 to conserve space. You may also want to consider twobit rasters to store three-valued logic where the third (e.g. 2) is NODATA, which would ...


3

Try the IEEE 754 Converter http://www.h-schmidt.net/FloatConverter/IEEE754.html. Read the note: Rounding errors: Not every decimal number can be expressed exactly as a floating point number. This can be seen when entering "0.1" and examining its binary representation which is either slightly smaller or larger, depending on the last bit. You can ...


5

Reading Rasters by block can be done in rasterio and I'd argue it's easier than in GDAL. There is even a tutorial on windowed read/write over at GitHub. Let's take a look at the read functions arguments, which allows you to set a window to read data from: def read(self, indexes=None, out=None, window=None, masked=False, boundless=False): """Read ...


0

Eventuall I use this code from rasterio examples: import numpy as np import rasterio import subprocess # Register GDAL format drivers and configuration options with a # context manager. with rasterio.drivers(): # Read raster bands directly to Numpy arrays. # with rasterio.open(r'mypath\band1.img') as src: rs = src.read() ...


0

Presumably one of the parameters to CopyDatasetInfo is None. Did you verify that dsOut is not None? You could save your results as Float32, or you could scale them back to 0-255 to save as Byte, or scale them to some other integer range. It depends on what you want to do with the result, and how much information you can afford to lose.


0

Assumed that you use python to call GDAL library.. first of all, you have to find which cell (column and row) on your raster data contains those lat/long coordinate. Then look at that cell's value as height. It will be easier if you use numpy array to represent raster's height value. You can write this python's code : import os from osgeo import ogr, ...


1

NAD83(CSRS) (which is based on ITRF96(1997.0)) is not a simple transformation away from WGS84. It's anchored to the North American plate, which is rotating counter-clockwise, and uplifting -- in some places rapidly -- due to isostatic rebound. Proj doesn't know anything about this. It can transform from geographic to geocentric and UTM, and it can shift from ...


1

You were are actually converting from EPSG:4917 (ITRF96), not EPSG:4326 (WGS84). See the TRX online utility from NRCan to do this conversion: Unfortunately you cannot use PROJ.4 to convert ITRF projections; see enhancement ticket #154. If you were using WGS84 in place of ITRF96, then your steps with pyproj were fine. However, if you need ITRF96, then ...


0

I have the same experience. The algorithm is really slow for huge rasters, although quite fast for smaller ones. There is one possible workaround: Split huge raster file into smaller files by gdalwarp (using -te to define extent for each file): gdalwarp -te 12.08 48.5 12.5 51.1 original_file.tif part1.tif Polygonize each of them into separate ...


1

As @StevenKay mentioned, quotes on the GeoJSON should be escaped with preceding backslash. pgsql2shp -f tiles.shp -h <host> -u <user> -P <pass> <database> "SELECT id, the_geom FROM <table> WHERE ST_GeomFromGeoJSON('{ \"type\": \"Polygon\", \"coordinates\": [ [ [ -92.472398018272358, 18.086381878379395 ], [ -92.472398018272358, ...


3

The dataset is getting dereferenced when you return only the band from your function. The solution is to return the dataset from your function. From the GDAL Python Gotchas page: Python crashes if you use an object after deleting an object it has a relationship with Consider this example: from osgeo import gdal dataset = ...


1

You can get GDAL 1.10 from http://download.osgeo.org/gdal/1.10.1/ and compile it the same way as you did with 1.9. BTW, GDAL 1.11.2 is the current stable version, and installing QGIS on a vanilla lubuntu 15.04 includes that GDAL version. So if you remove (delete the self-compilation and sudo apt-get purge the packages) all GDAL and QGIS stuff, then ...


2

It's possible to do this conversion with gdalwarp(i think), but it would be way easier to do it using cs2cs cat ~/Desktop/coords.csv| sed 's/,/ /' | cs2cs +init=epsg:26912 +to +init=epsg:4326 -f '%.6f'


0

You can use cs2cs (part of the proj4 project). You an also load them into QGIS and "Save As" to another coordinate system.


0

I had the same issue. It was related to the flags in cmake. My purpose was not related to GRASS 7 so I just had to desactivate it. My line for compiling is similar to below (I didn't provide all the options just the ones related to GRASS) cmake -DWITH_GRASS=OFF -DWITH_GRASS7=OFF .. You need to do before a make clean You can also check if your ...


2

Draw the area(s) you want to hide from the image and save as vectors into shapefile or other format if you prefer. Then use the gdal_rasterize utility http://www.gdal.org/gdal_rasterize.html which burns fixed, non-transparent pixels into your image and removes permanently image data below the polygons. Here is an example. The map is a RGB tiff image with ...


2

self.coordTransform = self.coordinateTransformation(4326,3309) It looks like you have your source and destination coordinate systems mixed up.


1

For Internet People in the Future: an ubuntu upgrade had interfered with the source-built gdal install. i am unsure what exactly was being referenced wrong, but removing the repo gdal package and rebuilding gdal seems to have removed the error.


1

To solve my issue, I had to use the debug option in the command ogr2ogr --config CPL_DEBUG ON -f GFT "GFT:access=<authorization token>" ~/countries.shp The returned output was Shape: DBF Codepage = LDID/87 for countries.shp Shape: Treating as encoding 'ISO-8859-1'. OGR: OGROpen(france.shp/<persistent_session_code>) succeeded as ESRI Shapefile. ...


2

Looking at GDAL autotests, I see only the refresh token is defined. As far as I understand the code, the access token will be automatically got from the refresh token (since the access token is apparently renewed from the refresh token, so it is not practical setting its value directly). So try to undefine the access token ("GFT:" as connection string), and ...



Top 50 recent answers are included