Why not work globally ?
calculate the distances between all points
union the resulting lines pointx - pointy with a distance < 14m
I will use Shapely, much easier for resolving these kinds of problems.
You must iterate through all pairs of points to calculate the distance once (as distance point1-point2 = distance point2-point1). There are many ...
I modified the original code a little bit to avoid some confusion when defining the RasterCenter function, since the argument named raster used in def RasterCenter(raster) and the variable named raster used in raster = arcpy.Raster(raster) within the function can cause confusion and make things not working properly. I modified parsing the path when reading ...
As GDAL supports writing to X,Y,Z (CSV) ascii, you could use gdal_translate:
gdal_translate -of xyz -co ADD_HEADER_LINE=YES -co COLUMN_SEPARATOR="," input_raster output.csv
To avoid writing NoData values to your output you can write the output to stdout then pipe to grep/findstr to filter it before writing to your csv:
gdal_translate -q -of xyz -co ...
If you look at the example on the man page for ST_PixelAsPolygons you will see how you can access the geometries using table_alias.geom syntax (similar in spirit to how ST_Dump works to turn a set or records into individual rows). Following on from that example, you can pass (gv).geom to the ST_AsGeoJSON function, eg,
Not automatization (strictly speaking), but one good helper tool would be Gimp Selection Feature plugin.
It enables us to access Fuzzy selection tool of Gimp 2.10, and returns a polygon layer taken from the area you have chosen.
When I tested it on your posted image, Threshold value set at 60.0 was good at differentiating the blue river and surrounding ...
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 ...
Try using rasterio, which uses GDALFPolygonize on float arrays.
import numpy as np
from affine import Affine
from shapely.geometry import shape
# triangular array
ar = np.tri(5, dtype='f')
for shp, val in rasterio.features.shapes(ar, transform=Affine(1, 0, 0, 0, -1, 5)):
print('%s: %s' % (val, shape(shp)))
You can't use GDALFPolygonize with the GDAL python bindings without modifying the source code and recompiling as it isn't exposed in the GDAL swig interface.
Note: as at Feb 2016, GDALFPolygonize IS exposed in the GDAL SVN trunk source, but is not in either of the latest releases (1.11.4/2.0.2).
To polygonize your raster, you will need to convert from ...
I came across a thread Smoothing a 2-D figure. The answers make reference to this paper Chaikin's algorithm for curves
For a given polygon with vertices as P0, P1, ...P(N-1), the corner cutting algorithm will generate 2 new vertices for each line segment defined by P(i) and P(i+1) as
Q(i) = (3/4)P(i) + (1/4)P(i+1)
R(i) = (1/4)P(i) + (3/4)P(i+1)
So, your new ...
As previously commented, you may accomplish all your task using R exclusively; in the following code, a raster is created and then filtered to values above the threshold, all other values will become NA, then the pixels are masked to the lines. Raster works now in recent versions with both sf and sp objects, the code uses the latter kind.
As mentioned in the comments by @Knightshound, you seem to lack some experience in GIS. Still, i'm going to answer your question so you get some of this experience you need.
What you want to do is Polygonize, in the Raster menu/Conversion/Polygonize (Raster to Vector), but you'll quickly realize it doesn't produce what you expect ;)
ArcGIS has a Raster to Polygon tool that will do this for you. It's in the conversion toolbox.
I suspect there's a better way to approach your problem, but it's hard to say without knowing more about your analysis.
Try this way with GDAL:
import os, sys
from osgeo import gdal
from osgeo import gdalconst
# get the arguments
InRaster = sys.argv
OutCSV = sys.argv
# open the raster and get some properties
ds = gdal.OpenShared(InRaster,gdalconst.GA_ReadOnly)
GeoTrans = ds.GetGeoTransform()
ColRange = range(ds.RasterXSize)
RowRange = range(ds.RasterYSize)
Rather than converting that image to vector, you should get the OpenStreetMap data from Mapzen:
Bring that into QGIS and check out what data is there, and then start to style it as your raster map is styled.
Now it worked for me as @RoVo suggested before. The problem were the no-data values in my input raster. I changed these not with gdal_translate as @AndreJ suggests (in comments of answer above), but with GRASS r.mapcalc.
Here the modules that I used:
Replace all no data values:
I found a solution using USGS landcover dataset and gdal_sieve . The raw dataset looks like this:
And using gdal_sieve led to that:
Which is exactly what I wanted :) . Now I "just" have to choose pretty colours.
Your question is very broad but try some kind of segmentation, for example GRASS i.segment. Your raster is probably to high resolution. I tried with 1 m and 5 m:
Convert to lines
The combination of input parameters are infinite.
Why don't you crop again with your clipper after vectorizing? That way any combined polygons derived from your raster layer will match your original clipping layer. If you don't want to add an extra step you can vectorize the entire raster layer then clip to vector layer (though this could take more computation time).
Any other option I can think of would ...
The final batch file, based on Logan Byers answer, which I managed to get working on a Windows machine.
I should note that I had to amend the output of gdal2xyz.py. For some reason the version I had (installed with FWTools 2.4.7) would not accept the -csv option as valid syntax and you can see it is omitted from the code below. I had to open the gdal2xyz....
The data was in float, so I found after some research it needs to be converted into integer first. Using Raster Calculator I used the following syntax to convert into new raster layer. It created an attribute table and I can convert it into vector data now.
The algorithm is trying to create polygon geometries for each elevation value.
The common case is that there are many single pixels that must be transformed into polygons with the size of the pixel.
Also, adjacent and edge pixels may form invalid geometries.
In general, a polygonization of a DEM is not what we want, and usually the solution is to ...
To complement the comment above, there is a number of ways that you may want to tackle this issue - most can be run from within QGIS. As mentioned above, the GRASS GIS tool i.segment is a very powerful tool.
In addition, another option is the segmentation tools (e.g. otbcli_Segmentation) available in the Orfeo Toolbox, which are described in detail here. ...
The following solution assumes that you have a GeoTiff with raster values, which you want to filter based on a threshold (e.g. 50) and convert the resulting pixels to an ESRI Shapefile for later use.
#read in raster
inputimage <- raster('input_raster.tif')
##check the image in R
You can use Menu Raster / Converstion / Vectorize raster layer (screenshot 1). On the output layer, apply Select Features by Expression… and insert "DN" = 0 to the expression editor (screenshot 2), thus selecting all polygons where the raster value is 0: these are the ones you want to delete. Now delete the selected features and you are left just ...
The Esri FLT data format stores its data identically to an Esri BIL file, which GDAL does support:
GDAL_Translate -of EHdr -ot Float32 ....
Then all you need to do is change the extension from bil to flt and edit the header - the keywords are different.. for example: