[GRASS-dev] problem with creating areas from set of points with specific category
Moritz Lennert
mlennert at club.worldonline.be
Fri Nov 7 00:46:45 PST 2014
On 05/11/14 22:00, Anna Petrášová wrote:
> Hi,
>
> my problem is - I have polygons defined as a set of coordinates with
> assigned categories and I want to create vector areas where the centroid
> would have that category. I don't want to use PyGRASS because of ctypes.
> I wanted to write an ascii file (ascii vector format) but it allows me
> to write only boundaries and centroids (not areas). But I don't have
> centroids. So I can write boundaries and then use v.centroids afterwards
> but I don't know how to specify the correct category values for those
> new centroids.
You could try something like this:
- Import your boundaries with the correct cat values
- Create a table linked to your new centroids
- Add a cat2 column
- Use v.distance to get for each centroid the cat value of the closest
boundary and load it into cat2
- Use v.reclass to make cat2 into the actual cat values of the centroids
- Erase the cat values of the boundaries
> There doesn't seem to be any way to transfer categories
> from boundaries to centroids. So, am I missing something? Why vector
> ascii format doesn't support areas?
Because GRASS uses a topological vector format and areas do not exist as
such in that format. But I can understand that it would be nice to have
an easy way. If your polygons are not too complex you can always try the
simple average of the x and y coordinates of your points as coordinates
for a centroid, but you might have situations where these mean
coordinates do not lie within the polygon.
> Would it be difficult to add it?
No idea. At the very least, scripting the above process should be
possible...if it works ;-)
Moritz
>
> Thanks,
>
> Anna
>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
More information about the grass-dev
mailing list