Re: [GRASS-user] Converting raster to polygon creates too many polygons
Hanlie Pretorius wrote: > > I don't really know why the > resolution in the x and y directions are not the same. Even when I set > them explicitly, I get a slight difference: The -a flag is missing, see my previous post. > - > g.region -p vect=c83a_bor...@permanent nsres=25 ewres=25 > projection: 99 (Transverse Mercator) > zone: 0 > datum: ** unknown (default: WGS84) ** > ellipsoid: wgs84 > north: -319.69982072 > south: -3155672.30728643 > west: -66483.27873573 > east: -33474.90929218 > nsres: 24.99447494 > ewres: 25.00634049 > rows: 1338 > cols: 1320 > cells: 1766160 > - > > The original resolution of the DEM was at 25m resolution. I just > assumend that the differences in x and y resolutions are a result of > the projected surface being skew with respect to the cartesian axes. I > say this because vectors that looked square in a latlong GCS display > slightly skewed when projected to the Transverse Mercator PCS that I > use in this location. Ah, ok, set the computational region in the target location with Transverse Mercator PCS and align with g.region -a to the desired resolution, then reproject, then run r.watershed and r.to.vect. > > My reason for running r.watershed at a much finer resolution was that > I would get a smoother boundary when I then convert to vector. > Obviously not a good idea. > Someone still has to fix v.generalize for smoothing boundaries... Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Converting raster to polygon creates too many polygons
2010/9/29, Markus Metz : > > In GRASS, you have full control of the computational region, > consequently you must be able to explain (to the client/supervisor) > every aspect of the computational region. Why is the horizontal > resolution not only slightly off from exactly one meter, but also > different for north-south and east-west? If these are the settings of > the input DEM, why was the DEM created with these settings? If these > resolution settings are different from the DEM's settings, there is > again lots of explaining and justification to do. Life is much easier > with, in this case, exactly 1m resolution which might need to be set > when preprocessing and creating the high-res DEM. The resolution > settings are just slightly different from 1m which can cause rounding > errors later on (export, import, file formats storing resolution in > single and not double precision, other GIS software using single and > not double precision for resolution, etc.) Thanks for the extensive comments. I don't really know why the resolution in the x and y directions are not the same. Even when I set them explicitly, I get a slight difference: - g.region -p vect=c83a_bor...@permanent nsres=25 ewres=25 projection: 99 (Transverse Mercator) zone: 0 datum: ** unknown (default: WGS84) ** ellipsoid: wgs84 north: -319.69982072 south: -3155672.30728643 west: -66483.27873573 east: -33474.90929218 nsres: 24.99447494 ewres: 25.00634049 rows: 1338 cols: 1320 cells: 1766160 - The original resolution of the DEM was at 25m resolution. I just assumend that the differences in x and y resolutions are a result of the projected surface being skew with respect to the cartesian axes. I say this because vectors that looked square in a latlong GCS display slightly skewed when projected to the Transverse Mercator PCS that I use in this location. My reason for running r.watershed at a much finer resolution was that I would get a smoother boundary when I then convert to vector. Obviously not a good idea. > > Markus M > ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Converting raster to polygon creates too many polygons
Hanlie Pretoriuswrote: > Hi, > > I've created subcatchments using r.watershed and I would like to > convert these to polygons. My result at the moment contains too many > polygons - 194. The original raster had only 9 areas, which should all > have been contiguous seeing that they came from r.watershed. > > Here is the sequence of commands that I use, starting with r.report > for the information about the subcatchments raster: > - > | Type of Map: raster Number of Categories: 18 > | Data Type: CELL > | Rows: 33443 > | Columns: 33008 > | Total Cells: 1103886544 > | Projection: Transverse Mercator > | N: -319.69982072 S: -3155672.30728643 Res: 0.8826 > | E: -33474.90929218 W: -66483.27873573 Res: 1.1119 > | Range of data: min = 2 max = 18 > - In GRASS, you have full control of the computational region, consequently you must be able to explain (to the client/supervisor) every aspect of the computational region. Why is the horizontal resolution not only slightly off from exactly one meter, but also different for north-south and east-west? If these are the settings of the input DEM, why was the DEM created with these settings? If these resolution settings are different from the DEM's settings, there is again lots of explaining and justification to do. Life is much easier with, in this case, exactly 1m resolution which might need to be set when preprocessing and creating the high-res DEM. The resolution settings are just slightly different from 1m which can cause rounding errors later on (export, import, file formats storing resolution in single and not double precision, other GIS software using single and not double precision for resolution, etc.) > > # Set the resolution to 25m > g.region rast=c83a_border res=25 Note that this gives you nsres = 24.99447494 and ewres = 25.00634049, see comment above. Also note that after converting to vector, the vector will not match the catchment raster because of the changed resolution. If you are interested in catchments at 25 meter resolution, resample the DEM to 25 meter, set the computational region now, don't touch it later, run r.watershed again, convert catchments to vector. > > # Convert the subcatchment raster to vector > r.to.vect --overwrite > input=c83a_dem_25m_clipped_basins_10_clip...@permanent > output=c83a_subcatchme...@permanent feature=area If you use r.to.vect -v, the categories will correspond to cell values, making it easier to evaluate the vector. > > v.report for the resulting vector gives me 194 categories. The > original raster had only 9 areas, which should all have been > contiguous seeing that they come from r.watershed. The following 5x5 matrix, theoretical example for two basins 1 2 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 2 2 would be converted not to 2 but to 5 vector areas because the cells with value 1 are rendered as 4 separate square areas, if you use r.to.vect -v, with the same category i.e. belonging to the same basin. BTW, the pattern in the above sample matrix occurs more often with SFD than with MFD, particularly on such high resolution (roundabout 1m). Further on, I observed r.to.vect to create redundant areas which can be removed with v.dissolve. > > What am I doing wrong? Not much apart from messing with the resolution. g.region res=1 -a or g.region align=c83a_dem_25m_clipped_basins_10_clipped to cleanly align a clipped region to a raster map ;-) > I want an output vector with 9 polygons > corresponding to the original 9 areas in the subcatchment raster. You will likely get a vector map with more than 9 areas, but you can get a vector map with exactly 9 different categories. Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Converting raster to polygon creates too many polygons
On 09/29/2010 02:11 PM, Hanlie Pretorius wrote: Hi, I've created subcatchments using r.watershed and I would like to convert these to polygons. My result at the moment contains too many polygons - 194. The original raster had only 9 areas, which should all have been contiguous seeing that they came from r.watershed. Here is the sequence of commands that I use, starting with r.report for the information about the subcatchments raster: - | Type of Map: raster Number of Categories: 18 | Data Type:CELL | Rows: 33443 | Columns: 33008 | Total Cells: 1103886544 1.1 billion cells. Do you really need that ? |Projection: Transverse Mercator |N: -319.69982072S: -3155672.30728643 Res: 0.8826 |E: -33474.90929218W: -66483.27873573 Res: 1.1119 | Range of data:min = 2 max = 18 It's not 9 areas but 16 categories. - # Set the resolution to 25m g.region rast=c83a_border res=25 I don't think changing resolution here will make any difference. (Unless you rerun r.watershed after) # Convert the subcatchment raster to vector r.to.vect --overwrite input=c83a_dem_25m_clipped_basins_10_clip...@permanent output=c83a_subcatchme...@permanent feature=area v.report for the resulting vector gives me 194 categories. The original raster had only 9 areas, which should all have been contiguous seeing that they come from r.watershed. You might be getting many small areas around the edges that are not connected with any of the subcatchments. Displaying the resulting vector should show you where the 194 areas are. You might consider getting rid of these edge areas with v.clean c83a_subcatchments tool=rmsa thresh= out=c83a_subcatchments_clean (choose a threshold large enough to catch all the edge areas, but smaller than any of the real subcatchments) What am I doing wrong? I want an output vector with 9 polygons corresponding to the original 9 areas in the subcatchment raster. Thanks Hanlie ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user This mail was received via Mail-SeCure System. -- Micha Silver Arava Development Co. +972-52-3665918 http://surfaces.co.il ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Converting raster to polygon creates too many polygons
You might consider using -s flag to smooth the corners. Otherwise, I can't see why it doesn't work. R. Sab > Hi, > > I've created subcatchments using r.watershed and I would like to > convert these to polygons. My result at the moment contains too many > polygons - 194. The original raster had only 9 areas, which should all > have been contiguous seeing that they came from r.watershed. > > Here is the sequence of commands that I use, starting with r.report > for the information about the subcatchments raster: > - > | Type of Map: raster Number of Categories: 18 > | Data Type:CELL > | Rows: 33443 > | Columns: 33008 > | Total Cells: 1103886544 > |Projection: Transverse Mercator > |N: -319.69982072S: -3155672.30728643 Res: > 0.8826 > |E: -33474.90929218W: -66483.27873573 Res: 1.1119 > | Range of data:min = 2 max = 18 > - > > # Set the resolution to 25m > g.region rast=c83a_border res=25 > > # Convert the subcatchment raster to vector > r.to.vect --overwrite > input=c83a_dem_25m_clipped_basins_10_clip...@permanent > output=c83a_subcatchme...@permanent feature=area > > v.report for the resulting vector gives me 194 categories. The > original raster had only 9 areas, which should all have been > contiguous seeing that they come from r.watershed. > > What am I doing wrong? I want an output vector with 9 polygons > corresponding to the original 9 areas in the subcatchment raster. > > Thanks > Hanlie > ___ > grass-user mailing list > grass-user@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/grass-user > ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Converting raster to polygon creates too many polygons
Hi, I've created subcatchments using r.watershed and I would like to convert these to polygons. My result at the moment contains too many polygons - 194. The original raster had only 9 areas, which should all have been contiguous seeing that they came from r.watershed. Here is the sequence of commands that I use, starting with r.report for the information about the subcatchments raster: - | Type of Map: raster Number of Categories: 18 | Data Type:CELL | Rows: 33443 | Columns: 33008 | Total Cells: 1103886544 |Projection: Transverse Mercator |N: -319.69982072S: -3155672.30728643 Res: 0.8826 |E: -33474.90929218W: -66483.27873573 Res: 1.1119 | Range of data:min = 2 max = 18 - # Set the resolution to 25m g.region rast=c83a_border res=25 # Convert the subcatchment raster to vector r.to.vect --overwrite input=c83a_dem_25m_clipped_basins_10_clip...@permanent output=c83a_subcatchme...@permanent feature=area v.report for the resulting vector gives me 194 categories. The original raster had only 9 areas, which should all have been contiguous seeing that they come from r.watershed. What am I doing wrong? I want an output vector with 9 polygons corresponding to the original 9 areas in the subcatchment raster. Thanks Hanlie ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user